sr2lua/hud_race_start.lua

  1. Hud_race_start = {	 
  2.  
  3. 	handles = {}, 
  4.  
  5. } 
  6.  
  7.  
  8. Hud_race_start_sound = { 
  9.  
  10. 	one = "SFX_DEMODERBY_1", 
  11. 	two = "SFX_DEMODERBY_2", 
  12. 	three = "SFX_DEMODERBY_3", 
  13. 	go = "SFX_DEMODERBY_GO", 
  14.  
  15. } 
  16.  
  17. AUDIO_COUNTDOWN_3_ID = 0 
  18. AUDIO_COUNTDOWN_2_ID = 0 
  19. AUDIO_COUNTDOWN_1_ID = 0 
  20. AUDIO_COUNTDOWN_GO_ID = 0 
  21.  
  22. function hud_race_start_init() 
  23. 	debug_print("vint", "HUD_RACE_START init\n") 
  24. 	 
  25. 	--elements 
  26. 	Hud_race_start.handles.n1_grp_h = vint_object_find("n1_grp") 
  27. 	Hud_race_start.handles.n2_grp_h = vint_object_find("n2_grp") 
  28. 	Hud_race_start.handles.n3_grp_h = vint_object_find("n3_grp") 
  29. 	Hud_race_start.handles.go_grp_h = vint_object_find("go_grp") 
  30. 	 
  31. 	--anims 
  32. 	Hud_race_start.handles.n1_anim_h = vint_object_find("n1_anim") 
  33. 	Hud_race_start.handles.n2_anim_h = vint_object_find("n2_anim") 
  34. 	Hud_race_start.handles.n3_anim_h = vint_object_find("n3_anim") 
  35. 	Hud_race_start.handles.go_anim_h = vint_object_find("go_anim") 
  36. 	 
  37. 	--pause em 
  38. 	vint_set_property(Hud_race_start.handles.n1_anim_h, "is_paused", true) 
  39. 	vint_set_property(Hud_race_start.handles.n2_anim_h, "is_paused", true) 
  40. 	vint_set_property(Hud_race_start.handles.n3_anim_h, "is_paused", true) 
  41. 	vint_set_property(Hud_race_start.handles.go_anim_h, "is_paused", true) 
  42.  
  43. 	--initialize our audio ids 
  44. 	AUDIO_COUNTDOWN_3_ID = 0 
  45. 	AUDIO_COUNTDOWN_2_ID = 0 
  46. 	AUDIO_COUNTDOWN_1_ID = 0 
  47. 	AUDIO_COUNTDOWN_GO_ID = 0 
  48. 	 
  49. 	local twn_h = 0 
  50. 	 
  51. 	--twns 
  52. 	twn_h = vint_object_find("go_scale", Hud_race_start.handles.go_anim_h)			 
  53. 	vint_set_property(twn_h, "end_event", "hud_race_start_invisible") 
  54. 	vint_set_property(twn_h, "start_event",  "hud_race_start_sound_go"); 
  55.  
  56. 	twn_h = vint_object_find("3_anchor_twn_2", Hud_race_start.handles.n3_anim_h)			 
  57. 	vint_set_property(twn_h, "start_event",  "hud_race_start_sound_3"); 
  58.  
  59. 	twn_h = vint_object_find("2_anchor_twn_2", Hud_race_start.handles.n2_anim_h)			 
  60. 	vint_set_property(twn_h, "start_event",  "hud_race_start_sound_2"); 
  61.  
  62. 	twn_h = vint_object_find("1_anchor_twn_2", Hud_race_start.handles.n1_anim_h)			 
  63. 	vint_set_property(twn_h, "start_event",  "hud_race_start_sound_1"); 
  64. 	 
  65. 	Hud_race_start.handles.current_num = -1 
  66.  
  67. 	AUDIO_COUNTDOWN_3_ID = audio_prepare("SFX_DEMODERBY_3") 
  68. end 
  69.  
  70.  
  71. function hud_race_start_1() 
  72. 	vint_set_property(Hud_race_start.handles.n1_grp_h, "visible", true) 
  73. 	lua_play_anim(Hud_race_start.handles.n1_anim_h, 0) 
  74. 	Hud_race_start.handles.current_num = 1 
  75. --	local twn_h = vint_object_find("1_anchor_twn_3", Hud_race_start.handles.n1_anim_h)			 
  76. --	vint_set_property(twn_h, "end_event", "hud_race_start_go") 
  77. end 
  78.  
  79. function hud_race_start_2() 
  80. 	vint_set_property(Hud_race_start.handles.n2_grp_h, "visible", true) 
  81. 	lua_play_anim(Hud_race_start.handles.n2_anim_h, 0) 
  82. 	Hud_race_start.handles.current_num = 2 
  83. --	local twn_h = vint_object_find("2_anchor_twn_3", Hud_race_start.handles.n2_anim_h)			 
  84. --	vint_set_property(twn_h, "end_event", "hud_race_start_1") 
  85.  
  86. end 
  87.  
  88. function hud_race_start_3() 
  89. 	vint_set_property(Hud_race_start.handles.n3_grp_h, "visible", true) 
  90. 	lua_play_anim(Hud_race_start.handles.n3_anim_h, 0) 
  91. 	Hud_race_start.handles.current_num = 3 
  92. 	 
  93. --	local twn_h = vint_object_find("3_anchor_twn_3", Hud_race_start.handles.n3_anim_h)			 
  94. --	vint_set_property(twn_h, "end_event", "hud_race_start_2") 
  95. end 
  96.  
  97. function hud_race_start_go() 
  98. 	vint_set_property(Hud_race_start.handles.go_grp_h, "visible", true) 
  99. 	lua_play_anim(Hud_race_start.handles.go_anim_h, 0) 
  100. 	Hud_race_start.handles.current_num = 0 
  101. end 
  102.  
  103.  
  104. function hud_race_start_invisible() 
  105. 	vint_set_property(Hud_race_start.handles.n1_grp_h, "visible", false) 
  106. 	vint_set_property(Hud_race_start.handles.n2_grp_h, "visible", false) 
  107. 	vint_set_property(Hud_race_start.handles.n3_grp_h, "visible", false) 
  108. 	vint_set_property(Hud_race_start.handles.go_grp_h, "visible", false)	 
  109. end 
  110.  
  111. function hud_race_start_visible() 
  112. 	vint_set_property(Hud_race_start.handles.n1_grp_h, "visible", true) 
  113. 	vint_set_property(Hud_race_start.handles.n2_grp_h, "visible", true) 
  114. 	vint_set_property(Hud_race_start.handles.n3_grp_h, "visible", true) 
  115. 	vint_set_property(Hud_race_start.handles.go_grp_h, "visible", true)	 
  116. end 
  117.  
  118.  
  119. function hud_race_start_cleanup() 
  120. 	debug_print("vint", "HUD_RACE_START cleanup\n") 
  121.  
  122. 	--make sure all of the audio stops 
  123. 	if AUDIO_COUNTDOWN_3_ID ~= 0 then 
  124. 		audio_fade_out(AUDIO_COUNTDOWN_3_ID, 0) 
  125. 		AUDIO_COUNTDOWN_3_ID = 0 
  126. 	end 
  127. 	if AUDIO_COUNTDOWN_2_ID ~= 0 then 
  128. 		audio_fade_out(AUDIO_COUNTDOWN_2_ID, 0) 
  129. 		AUDIO_COUNTDOWN_2_ID = 0 
  130. 	end 
  131. 	if AUDIO_COUNTDOWN_1_ID ~= 0 then 
  132. 		audio_fade_out(AUDIO_COUNTDOWN_1_ID, 0) 
  133. 		AUDIO_COUNTDOWN_1_ID = 0 
  134. 	end 
  135. 	if AUDIO_COUNTDOWN_GO_ID ~= 0 then 
  136. 		audio_fade_out(AUDIO_COUNTDOWN_GO_ID, 0) 
  137. 		AUDIO_COUNTDOWN_GO_ID = 0 
  138. 	end 
  139.  
  140. 	--just in case, turn all invisible 
  141. 	vint_set_property(Hud_race_start.handles.n1_anim_h, "visible", false) 
  142. 	vint_set_property(Hud_race_start.handles.n2_anim_h, "visible", false) 
  143. 	vint_set_property(Hud_race_start.handles.n3_anim_h, "visible", false) 
  144. 	vint_set_property(Hud_race_start.handles.go_anim_h, "visible", false)	 
  145. end 
  146.  
  147. --my fake test function 
  148. function hud_race_start_fake() 
  149. 	hud_race_start_3() 
  150. end 
  151.  
  152. function hud_race_start_sound_3() 
  153. 	if AUDIO_COUNTDOWN_2_ID == 0 then 
  154. 		AUDIO_COUNTDOWN_2_ID = audio_prepare("SFX_DEMODERBY_2") 
  155. 	end 
  156. 	audio_play_prepared(AUDIO_COUNTDOWN_3_ID) 
  157. 	AUDIO_COUNTDOWN_3_ID = 0 
  158. 	--audio_play(Hud_race_start_sound.three) 
  159. end 
  160.  
  161. function hud_race_start_sound_2() 
  162. 	if AUDIO_COUNTDOWN_1_ID == 0 then 
  163. 		AUDIO_COUNTDOWN_1_ID = audio_prepare("SFX_DEMODERBY_1") 
  164. 	end 
  165. 	audio_play_prepared(AUDIO_COUNTDOWN_2_ID) 
  166. 	AUDIO_COUNTDOWN_2_ID = 0 
  167. 	--audio_play(Hud_race_start_sound.two) 
  168. end 
  169.  
  170. function hud_race_start_sound_1() 
  171. 	if AUDIO_COUNTDOWN_GO_ID == 0 then 
  172. 		AUDIO_COUNTDOWN_GO_ID = audio_prepare("SFX_DEMODERBY_GO") 
  173. 	end 
  174. 	audio_play_prepared(AUDIO_COUNTDOWN_1_ID) 
  175. 	AUDIO_COUNTDOWN_1_ID = 0 
  176. 	--audio_play(Hud_race_start_sound.one) 
  177. end 
  178.  
  179. function hud_race_start_sound_go() 
  180. 	audio_play_prepared(AUDIO_COUNTDOWN_GO_ID) 
  181. 	AUDIO_COUNTDOWN_GO_ID = 0 
  182. 	--audio_play(Hud_race_start_sound.go) 
  183. end 
  184.  
  185. function hud_race_start_pause_all() 
  186. 	hud_race_start_invisible() 
  187. 	vint_set_property(Hud_race_start.handles.n1_anim_h, "is_paused", true) 
  188. 	vint_set_property(Hud_race_start.handles.n2_anim_h, "is_paused", true) 
  189. 	vint_set_property(Hud_race_start.handles.n3_anim_h, "is_paused", true) 
  190. 	vint_set_property(Hud_race_start.handles.go_anim_h, "is_paused", true)	 
  191. end 
  192.  
  193. function hud_race_start_unpause_all() 
  194. 	if Hud_race_start.handles.current_num == 0 then 
  195. 		vint_set_property(Hud_race_start.handles.go_grp_h, "visible", true) 
  196. 		vint_set_property(Hud_race_start.handles.go_anim_h, "is_paused", false)	 
  197. 	elseif Hud_race_start.handles.current_num == 1 then 
  198. 		vint_set_property(Hud_race_start.handles.n1_grp_h, "visible", true) 
  199. 		vint_set_property(Hud_race_start.handles.n1_anim_h, "is_paused", false)	 
  200. 	elseif Hud_race_start.handles.current_num == 2 then 
  201. 		vint_set_property(Hud_race_start.handles.n2_grp_h, "visible", true) 
  202. 		vint_set_property(Hud_race_start.handles.n2_anim_h, "is_paused", false)	 
  203. 	elseif Hud_race_start.handles.current_num == 3 then 
  204. 		vint_set_property(Hud_race_start.handles.n3_grp_h, "visible", true) 
  205. 		vint_set_property(Hud_race_start.handles.n3_anim_h, "is_paused", false)	 
  206. 	end 
  207. end 
  208.  
  209.