./whored_countdown.lua

  1. ------------------------------------------------------------------------------- 
  2. -- Whored mode countdown between waves 
  3. -- Shows countdown timer, wave and wave description. 
  4. ------------------------------------------------------------------------------- 
  5.  
  6. function whored_countdown_init() 
  7. 	local countdown_in_anim_h = vint_object_find("countdown_in_anim") 
  8. 	lua_play_anim(countdown_in_anim_h) 
  9. 	 
  10. 	local go_txt_h = vint_object_find("go_txt") 
  11. 	vint_set_property(go_txt_h, "alpha", 0) 
  12. 	 
  13. 	local countdown_grp_h = vint_object_find("countdown_grp") 
  14. 	vint_set_property(countdown_grp_h, "alpha", 0) 
  15. 	 
  16. 	--start bg saints loop. 
  17. 	local bg_saints_loop_anim_h = vint_object_find("bg_saints_loop_anim") 
  18. 	lua_play_anim(bg_saints_loop_anim_h) 
  19. 	 
  20. 	ui_audio_post_event("ui_whr_cnt_anim_in") 
  21. 	 
  22. 	vint_dataresponder_request("whored_countdown_populate", "whored_countdown_text_update", 0) 
  23. 	 
  24. 	vint_dataitem_add_subscription("game_paused_item", "update", "whored_countdown_paused_game")	--to check if game is paused... 
  25. end 
  26.  
  27. ------------------------------------------------------------------------------- 
  28. -- Update text for countdown update... 
  29. -- @param	wave_str						current wave "WAVE 11" 
  30. -- @param	wave_title_str				wave title "ZOMBIE WHORED FUCK EM UP" 
  31. -- @param	wave_description_str		description	 
  32. -- 
  33. function whored_countdown_text_update(wave_str, wave_title_str, wave_description_str) 
  34. 	local wave_title_txt_h		 		= vint_object_find("wave_title_txt") 
  35. 	local wave_txt_h						= vint_object_find("wave_txt") 
  36. 	local wave_description_txt_h		= vint_object_find("wave_description_txt") 
  37. 	 
  38. 	--Set strings... 
  39. 	vint_set_property(wave_txt_h, "text_tag", wave_str) 
  40. 	vint_set_property(wave_title_txt_h, "text_tag_crc", wave_title_str) 
  41. 	vint_set_property(wave_description_txt_h, "text_tag_crc", wave_description_str) 
  42. 	 
  43. 	--Align objects to screen 
  44. 	local title_x, title_y = vint_get_property(wave_title_txt_h, "anchor") 
  45. 	local wave_x, wave_y = vint_get_property(wave_title_txt_h, "anchor") 
  46. 	local title_width, title_height = element_get_actual_size(wave_title_txt_h) 
  47. 	local wave_width, wave_height = element_get_actual_size(wave_txt_h) 
  48. 	local description_width, description_height = element_get_actual_size(wave_description_txt_h) 
  49.  
  50. 	 
  51. 	--Move the wave title text so the dialects do not overlap 
  52. 	local language = game_get_language() 
  53. 	if language ~= "US" and language ~= "JP" then 
  54. 		vint_set_property(wave_title_txt_h, "text_scale", 0.45, 0.45) 
  55. 		local x, y = vint_get_property(wave_title_txt_h, "anchor") 
  56. 		vint_set_property(wave_title_txt_h, "anchor", x, y + 3) 
  57. 	end 
  58. 	 
  59. 	--Is the title or wave wider? also include the x position in width because these are offset by the timer... 
  60. 	local width = max(title_width + title_x, wave_width + wave_x ) 
  61. 	 
  62. 	--Compare the title widths against the description width... 
  63. 	width = max(description_width, width) 
  64. 	 
  65. 	--now we can center the group... 
  66. 	local text_grp_h = vint_object_find("text_grp") 
  67. 	local txt_grp_x, txt_grp_y = vint_get_property(text_grp_h, "anchor") 
  68. 	txt_grp_x = 640 - (width/2) 
  69. 	vint_set_property(text_grp_h, "anchor", txt_grp_x, txt_grp_y) 
  70. 	 
  71. 	--Set size of background 
  72. 	local background_h = vint_object_find("background_mask") 
  73. 	local background_width, background_height = element_get_actual_size(background_h) 
  74. 	local description_x, description_y = vint_get_property(wave_description_txt_h, "anchor") 
  75. 	 
  76. 	--Background height will be where the description, height of description, plus some padding... 
  77. 	background_height = description_y + description_height  + 10 
  78. 	element_set_actual_size(background_h, background_width, background_height) 
  79. 	 
  80. 	-- Set Shadows 
  81. 	local bottom_shadow_h = vint_object_find("bottom_shadow") 
  82. 	local x, y = vint_get_property(bottom_shadow_h, "anchor") 
  83. 	vint_set_property(bottom_shadow_h, "anchor", x, background_height) 
  84. end 
  85.  
  86. function whored_countdown_timer_update(seconds_left) 
  87. 	local timer_txt_h					= vint_object_find("timer_txt") 
  88. 	local seconds_time_string = seconds_left 
  89.  
  90. 	if seconds_left == 0 then 
  91. 		--transitions from countdown to the go animation... 
  92. 		local countdown_to_go_anim_h = vint_object_find("countdown_to_go_anim") 
  93. 		local go_alpha_twn_h = vint_object_find("go_alpha_twn") 
  94. 		vint_set_property(go_alpha_twn_h, "start_event", "whored_countdown_play_go_audio") 
  95. 		lua_play_anim(countdown_to_go_anim_h) 
  96. 		 
  97. 		--set complete callback... 
  98. 		local go_end_twn_h = vint_object_find("go_end_twn") 
  99. 		vint_set_property(go_end_twn_h, "end_event", "whored_countdown_complete") 
  100. 	else 
  101. 		if seconds_time_string == 1 then 
  102. 			ui_audio_post_event("ui_whr_cnt_one") 
  103. 		elseif seconds_time_string == 2 then 
  104. 			ui_audio_post_event("ui_whr_cnt_two") 
  105. 		end 
  106. 		ui_audio_post_event("ui_whr_cnt_digit") 
  107. 		vint_set_property(timer_txt_h, "text_tag", seconds_time_string) 
  108. 	end 
  109. end 
  110.  
  111. function whored_countdown_play_go_audio() 
  112. 	ui_audio_post_event("ui_whr_cnt_GO") 
  113. end 
  114.  
  115.  
  116. ------------------------------------------------------------------------------- 
  117. -- Shows/Hides the countdown screen 
  118. -- 
  119. function whored_countdown_paused_game(di_h) 
  120. 	local is_paused = vint_dataitem_get(di_h) 
  121. 	local is_visible = true 
  122. 	if is_paused == true then 
  123. 		is_visible = false 
  124. 	end 
  125. 	local countdown_doc_h = vint_document_find("whored_countdown") 
  126. 	local safe_frame_h = vint_object_find("safe_frame", 0, countdown_doc_h) 
  127. 	vint_set_property(safe_frame_h, "visible", is_visible) 
  128. end 
  129.  
  130. function whored_countdown_complete() 
  131. 	whored_countdown_finished() 
  132. end 
  133.  
  134. function whored_countdown_cleanup() 
  135. end