local COUNTDOWN_DISPLAY_1 = 3
local COUNTDOWN_DISPLAY_2 = 2
local COUNTDOWN_DISPLAY_3 = 1
local COUNTDOWN_DISPLAY_GO = 0
local COUNTDOWN_DISPLAY_DATA = {
[COUNTDOWN_DISPLAY_1] = { sfx = "UI_HUD_Countdown", txt = "3", header_anim = "header_in_anim"},
[COUNTDOWN_DISPLAY_2] = { sfx = "UI_HUD_Countdown", txt = "2"},
[COUNTDOWN_DISPLAY_3] = { sfx = "UI_HUD_Countdown", txt = "1"},
[COUNTDOWN_DISPLAY_GO] = { sfx = "UI_HUD_Countdown_End", txt = "COUNTDOWN_GO", header_anim = "header_out_anim"},
}
local Countdown_title = false --no countdown title by default...
local Countdown_anims_playing = {} --storage for all of our animations...
--Init
function countdown_init()
--Hide Everything
local h = vint_object_find("header_txt")
vint_set_property(h, "alpha", 0)
local h = vint_object_find("number_txt")
vint_set_property(h, "alpha", 0)
end
function countdown_cleanup()
end
-------------------------------------------------------------------------------
-- Sets the countdown title
-- @param title_str String for title
--
function countdown_set_title(title_str)
local h = vint_object_find("header_txt")
vint_set_property(h, "text_tag", title_str)
Countdown_title = true
end
-------------------------------------------------------------------------------
-- Plays a number count...
-- @parem id COUNTDOWN_DISPLAY_1, COUNTDOWN_DISPLAY_2, COUNTDOWN_DISPLAY_3, COUNTDOWN_DISPLAY_GO
function countdown_display(id)
local data = COUNTDOWN_DISPLAY_DATA[id]
--Set text tag of countdown "#" or "GO!"
local number_txt_h = vint_object_find("number_txt")
vint_set_property(number_txt_h, "text_tag", data.txt)
--always play number in animation...
local anim_h = vint_object_find("number_anim")
lua_play_anim(anim_h)
Countdown_anims_playing[1] = anim_h
--play custom anim if needed... (fade in or out of title)
if Countdown_title == true then
if data.header_anim ~= nil then
local anim_h = vint_object_find(data.header_anim)
lua_play_anim(anim_h)
Countdown_anims_playing[2] = anim_h
end
end
--play sound...
if data.sfx ~= nil then
game_UI_audio_play(data.sfx)
end
end
-------------------------------------------------------------------------------
-- Pauses animations and hides the screen...
--
function countdown_pause()
local h = vint_object_find("countdown_grp")
vint_set_property(h, "visible", false)
countdown_pause_anims(true)
end
-------------------------------------------------------------------------------
-- Unpauses animations and shows the screen... (called from c++)
--
function countdown_unpause()
local h = vint_object_find("countdown_grp")
vint_set_property(h, "visible", true)
countdown_pause_anims(false)
end
-------------------------------------------------------------------------------
-- Pauses or unpaused all animations...
-- @param is_paused True if you want to pause, false if you do not...
--
function countdown_pause_anims(is_paused)
for i=1, #Countdown_anims_playing do
vint_set_property(Countdown_anims_playing[i], "is_paused", is_paused)
end
end
function test_countdown_1()
countdown_display(COUNTDOWN_DISPLAY_1)
end
function test_countdown_2()
countdown_display(COUNTDOWN_DISPLAY_2)
end
function test_countdown_3()
countdown_display(COUNTDOWN_DISPLAY_3)
end
function test_countdown_4()
countdown_display(COUNTDOWN_DISPLAY_GO)
end
function test_countdown_title()
countdown_set_title("WAVE 15")
end