--Enums for events
RM_FIRE_TRAP = 1
RM_ELECTRIC_TRAP = 2
RM_FIRE_TRAP_KILL = 3
RM_ELECTRIC_TRAP_KILL = 4
RM_PRESENT_AWARDED = 5
RM_PRESENT_SPAWN = 6
RM_PRESENT_EXPLODED = 7
RM_PRESENT_WARNING = 8
RM_MULTI_5X = 9
RM_HUNTER_SPAWN = 10
RM_HUNTER_KILLED = 11
RM_HUNTER_KILL_PLAYER = 12
RM_ENEMY_TRAP = 13
RM_HUMAN_SHIELD = 14
RM_TARGET_ETHICAL = 15
RM_TARGET_UNETHICAL = 16
RM_TARGET_MONEY = 17
RM_TARGET_TIME_BONUS = 18
RM_TARGET_HEALTH = 19
RM_HEAD_SHOT = 20
RM_NUT_SHOT = 21
RM_TIME_LOW = 22
RM_EXIT_SPAWN = 23
RM_START_MATCH = 24
Data = {
[RM_FIRE_TRAP] = {
animation = "fire_anim",
tween = "end_event_twn",
grps = {"fire_grp"},
sfx = "RM_HUD_Fire_Trap"
},
[RM_ELECTRIC_TRAP] = {
animation = "trap_electric_anim",
tween = "end_event_twn",
grps = { "trap_electric_grp" },
sfx = "RM_HUD_Electricity_Trap",
},
[RM_FIRE_TRAP_KILL] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Player_Killed_by_Fire_Trap",
},
[RM_ELECTRIC_TRAP_KILL] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Player_Killed_by_Fire_Trap",
},
[RM_PRESENT_AWARDED] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Player_Gets_Present",
},
[RM_PRESENT_SPAWN] = {
animation = "present_anim",
tween = "end_event_twn",
grps = { "present_grp" },
sfx = "RM_Present_Spawned",
},
[RM_PRESENT_EXPLODED] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Player_Damaged_by_Present",
},
[RM_PRESENT_WARNING] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Present_About_to_Explode",
},
[RM_MULTI_5X] = {
animation = "5x_anim",
tween = "end_event_twn",
grps = { "fan_grp", "multiplier_grp" },
sfx = "RM_5X_Multiplier",
},
[RM_HUNTER_SPAWN] = {
animation = "hunter_anim",
tween = "end_event_twn",
grps = { "hunter_grp" },
sfx = "RM_Hunters_Spawned",
},
[RM_HUNTER_KILLED] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Kills_Hunter",
},
[RM_HUNTER_KILL_PLAYER] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Killed_by_Hunter",
},
[RM_ENEMY_TRAP] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Kill_Enemy_With_Trap",
},
[RM_HUMAN_SHIELD] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Take_Human_Shield",
},
[RM_TARGET_ETHICAL] = {
animation = "ethical_anim",
tween = "end_event_twn",
grps = { "ethical_grp" },
sfx = "RM_HUD_Ethical",
},
[RM_TARGET_UNETHICAL] = {
animation = "unethical_anim",
tween = "end_event_twn",
grps = { "unethical_grp" },
sfx = "RM_HUD_Unethical",
},
[RM_TARGET_MONEY] = {
animation = "money_shot_anim",
tween = "end_event_twn",
grps = { "money_shot_grp" },
sfx = "RM_Shoot_Money_Target",
},
[RM_TARGET_TIME_BONUS] = {
animation = "time_bonus_anim",
tween = "end_event_twn",
grps = { "time_bonus_grp", "genki_head_grp" },
sfx = "RM_HUD_Time_Bonus",
},
[RM_TARGET_HEALTH] = {
animation = "health_anim",
tween = "end_event_twn",
grps = { "health_grp" },
sfx = "RM_HUD_Health",
},
[RM_HEAD_SHOT] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Headshot",
},
[RM_NUT_SHOT] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Nutshot",
},
[RM_TIME_LOW] = {
animation = "time_low_anim",
tween = "end_event_twn",
grps = { "timer_grp", "fan_grp", "genki_head_grp" },
sfx = "RM_HUD_Timer",
},
[RM_EXIT_SPAWN] = {
animation = "exit_spawn_anim",
tween = "end_event_twn",
grps = { "exit_spawned_grp" },
sfx = "RM_Exiting",
},
[RM_START_MATCH] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Start_Match",
},
}
Hud_running_man_doc_handle = -1
local Event_played = -1
local Timer_audio = 0
local Event_is_playing = false
local Running_man_peg_loaded = false
local Panda_is_sad = false
local Rm_hud_event_audio_id = -1
function hud_running_man_init()
Hud_running_man_doc_handle = vint_document_find("hud_running_man")
-- unload the full screen map to pillage memory
pause_map_dump()
-- Jon, uncomment this line if you want to test outside the activity.. but remember to comment it back before you check in.
-- Love, Darryl
--thread_new("test_running_man")
for key, event in pairs(Data) do
local anim_h = vint_object_find(event.animation)
local tween_h = vint_object_find(event.tween, anim_h)
vint_set_property(tween_h, "end_event", "end_event_anim")
vint_apply_start_values(anim_h)
for key2, group_name in pairs (event.grps) do
local group_h = vint_object_find(group_name)
vint_set_property(group_h, "visible", false)
end
end
-- Set up looping tweens
local unethical_anim = Vdo_anim_object:new("unethical_anim", 0, Hud_running_man_doc_handle)
local trap_electric_anim = Vdo_anim_object:new("trap_eletric_anim", 0, Hud_running_man_doc_handle)
local health_anim = Vdo_anim_object:new("health_anim", 0, Hud_running_man_doc_handle)
local money_shot_anim = Vdo_anim_object:new("money_shot_anim", 0, Hud_running_man_doc_handle)
local panda_shock_twn = Vdo_tween_object:new("panda_shock_twn", trap_electric_anim.handle)
panda_shock_twn:set_end_event("hud_running_man_switch_panda")
local panda_twn = Vdo_tween_object:new("panda_twn", unethical_anim.handle)
panda_twn:set_end_event("hud_running_man_switch_panda")
end
function test_running_man()
delay(1)
hud_running_man_load_complete()
end
function hud_running_man_load_complete()
game_peg_load_with_cb("hud_running_man_peg_loaded", 1, "ui_bms_rm")
end
function hud_running_man_peg_loaded()
Running_man_peg_loaded = true
hud_running_man_event_update(RM_START_MATCH)
end
function hud_running_man_event_update(event_idx, timer)
-- check if we're using the time low event
if event_idx == RM_TIME_LOW then
hud_running_man_play_time_low(event_idx, timer)
return
end
if Running_man_peg_loaded == false then
return
end
--Always interrupt an existing event to play something newer
if Event_is_playing then
end_event_anim()
end
-- DEBUG TEXT MESSAGE
-- local do_nothing_txt = Vdo_base_object:new("do_nothing_txt", 0, Hud_running_man_doc_handle)
-- do_nothing_txt:set_text("Event "..event_idx.." fired")
for key, group_name in pairs(Data[event_idx].grps) do
local group_h = vint_object_find(group_name)
vint_set_property(group_h, "visible", true)
end
local anim_h = vint_object_find(Data[event_idx].animation)
lua_play_anim(anim_h)
if Data[event_idx].sfx ~= nil then
Rm_hud_event_audio_id = audio_object_post_event("Activity", {"Activity_Type","Running_Man"}, {"Running_Man",Data[event_idx].sfx})
end
Event_is_playing = true
Event_played = event_idx
end
function end_event_anim()
-- hide grps that were used and stop animation
for key, group_name in pairs(Data[Event_played].grps) do
local group_h = vint_object_find(group_name)
vint_set_property(group_h, "visible", false)
end
-- stop animation
vint_set_property(vint_object_find(Data[Event_played].animation),"is_paused", true)
-- Mark it ended
Event_is_playing = false
end
function hud_running_man_cleanup()
game_peg_unload("ui_bms_rm")
pause_map_restore()
end
function hud_running_man_switch_panda(twn_handle)
local anim_h = vint_object_parent(twn_handle)
local unethical_anim_h = vint_object_find("unethical_anim")
local trap_electric_anim_h = vint_object_find("trap_electric_anim")
local panda_img
if anim_h == unethical_anim_h then
panda_img = Vdo_base_object:new("panda_img", 0, Hud_running_man_doc_handle)
if Panda_is_sad then
panda_img:set_image("ui_rm_nuetral_panda")
Panda_is_sad = false
else
panda_img:set_image("ui_rm_sad_panda")
Panda_is_sad = true
end
elseif anim_h == trap_electric_anim_h then
panda_img = Vdo_base_object:new("panda_shocked", 0, Hud_running_man_doc_handle)
if Panda_is_sad then
panda_img:set_image("ui_rm_panda_shocked")
Panda_is_sad = false
else
panda_img:set_image("ui_rm_panda_skeleton")
Panda_is_sad = true
end
end
end
function hud_running_man_play_time_low(event_idx, timer)
local timer_grp = Vdo_base_object:new("timer_grp", 0, Hud_running_man_doc_handle)
local genki_head_grp = Vdo_base_object:new("genki_head_grp", 0, Hud_running_man_doc_handle)
local anim_h = vint_object_find("time_low_anim")
local timer_txt = Vdo_base_object:new("timer_txt", 0, Hud_running_man_doc_handle)
if Event_is_playing == false and timer > -1 then
timer_txt:set_text(format_time(timer/1000), false, false)
lua_play_anim(anim_h)
Timer_audio = audio_object_post_event("Activity", {"Activity_Type","Running_Man"}, {"Running_Man","RM_HUD_Timer"})
timer_grp:set_visible(true)
genki_head_grp:set_visible(true)
Event_is_playing = true
elseif timer > -1 then
timer_txt:set_text(format_time(timer/1000), false, false)
if timer <= 0 then
if Timer_audio > 0 then
audio_stop(Timer_audio)
Timer_audio = 0
end
end
elseif timer == -1 then
timer_grp:set_visible(false)
genki_head_grp:set_visible(true)
vint_set_property(anim_h, "is_paused", true)
if Timer_audio > 0 then
audio_stop(Timer_audio)
Timer_audio = 0
end
Event_is_playing = false
end
end