-------------------------------------------------------------------------------
-- Whored mode countdown between waves
-- Shows countdown timer, wave and wave description.
-------------------------------------------------------------------------------
function whored_countdown_init()
local countdown_in_anim_h = vint_object_find("countdown_in_anim")
lua_play_anim(countdown_in_anim_h)
local go_txt_h = vint_object_find("go_txt")
vint_set_property(go_txt_h, "alpha", 0)
local countdown_grp_h = vint_object_find("countdown_grp")
vint_set_property(countdown_grp_h, "alpha", 0)
--start bg saints loop.
local bg_saints_loop_anim_h = vint_object_find("bg_saints_loop_anim")
lua_play_anim(bg_saints_loop_anim_h)
ui_audio_post_event("ui_whr_cnt_anim_in")
vint_dataresponder_request("whored_countdown_populate", "whored_countdown_text_update", 0)
vint_dataitem_add_subscription("game_paused_item", "update", "whored_countdown_paused_game") --to check if game is paused...
end
-------------------------------------------------------------------------------
-- Update text for countdown update...
-- @param wave_str current wave "WAVE 11"
-- @param wave_title_str wave title "ZOMBIE WHORED FUCK EM UP"
-- @param wave_description_str description
--
function whored_countdown_text_update(wave_str, wave_title_str, wave_description_str)
local wave_title_txt_h = vint_object_find("wave_title_txt")
local wave_txt_h = vint_object_find("wave_txt")
local wave_description_txt_h = vint_object_find("wave_description_txt")
--Set strings...
vint_set_property(wave_txt_h, "text_tag", wave_str)
vint_set_property(wave_title_txt_h, "text_tag_crc", wave_title_str)
vint_set_property(wave_description_txt_h, "text_tag_crc", wave_description_str)
--Align objects to screen
local title_x, title_y = vint_get_property(wave_title_txt_h, "anchor")
local wave_x, wave_y = vint_get_property(wave_title_txt_h, "anchor")
local title_width, title_height = element_get_actual_size(wave_title_txt_h)
local wave_width, wave_height = element_get_actual_size(wave_txt_h)
local description_width, description_height = element_get_actual_size(wave_description_txt_h)
--Move the wave title text so the dialects do not overlap
local language = game_get_language()
if language ~= "US" and language ~= "JP" then
vint_set_property(wave_title_txt_h, "text_scale", 0.45, 0.45)
local x, y = vint_get_property(wave_title_txt_h, "anchor")
vint_set_property(wave_title_txt_h, "anchor", x, y + 3)
end
--Is the title or wave wider? also include the x position in width because these are offset by the timer...
local width = max(title_width + title_x, wave_width + wave_x )
--Compare the title widths against the description width...
width = max(description_width, width)
--now we can center the group...
local text_grp_h = vint_object_find("text_grp")
local txt_grp_x, txt_grp_y = vint_get_property(text_grp_h, "anchor")
txt_grp_x = 640 - (width/2)
vint_set_property(text_grp_h, "anchor", txt_grp_x, txt_grp_y)
--Set size of background
local background_h = vint_object_find("background_mask")
local background_width, background_height = element_get_actual_size(background_h)
local description_x, description_y = vint_get_property(wave_description_txt_h, "anchor")
--Background height will be where the description, height of description, plus some padding...
background_height = description_y + description_height + 10
element_set_actual_size(background_h, background_width, background_height)
-- Set Shadows
local bottom_shadow_h = vint_object_find("bottom_shadow")
local x, y = vint_get_property(bottom_shadow_h, "anchor")
vint_set_property(bottom_shadow_h, "anchor", x, background_height)
end
function whored_countdown_timer_update(seconds_left)
local timer_txt_h = vint_object_find("timer_txt")
local seconds_time_string = seconds_left
if seconds_left == 0 then
--transitions from countdown to the go animation...
local countdown_to_go_anim_h = vint_object_find("countdown_to_go_anim")
local go_alpha_twn_h = vint_object_find("go_alpha_twn")
vint_set_property(go_alpha_twn_h, "start_event", "whored_countdown_play_go_audio")
lua_play_anim(countdown_to_go_anim_h)
--set complete callback...
local go_end_twn_h = vint_object_find("go_end_twn")
vint_set_property(go_end_twn_h, "end_event", "whored_countdown_complete")
else
if seconds_time_string == 1 then
ui_audio_post_event("ui_whr_cnt_one")
elseif seconds_time_string == 2 then
ui_audio_post_event("ui_whr_cnt_two")
end
ui_audio_post_event("ui_whr_cnt_digit")
vint_set_property(timer_txt_h, "text_tag", seconds_time_string)
end
end
function whored_countdown_play_go_audio()
ui_audio_post_event("ui_whr_cnt_GO")
end
-------------------------------------------------------------------------------
-- Shows/Hides the countdown screen
--
function whored_countdown_paused_game(di_h)
local is_paused = vint_dataitem_get(di_h)
local is_visible = true
if is_paused == true then
is_visible = false
end
local countdown_doc_h = vint_document_find("whored_countdown")
local safe_frame_h = vint_object_find("safe_frame", 0, countdown_doc_h)
vint_set_property(safe_frame_h, "visible", is_visible)
end
function whored_countdown_complete()
whored_countdown_finished()
end
function whored_countdown_cleanup()
end