--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
GENKI_FLY_TOP_OF_COOL = 30
GENKI_FLY_SUPER_ETHICAL = 31
GENKI_FLY_CLEARED = 32
GENKI_FLY_ETHICAL = 33
GENKI_FLY_UNETHICAL = 34
GENKI_RUN_SHARK = 40
GENKI_ESCORT_FIRE = 50
GENKI_BALL_BOUNCE = 60
--find enums for each mode
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 = { "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", "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",
},
[GENKI_FLY_TOP_OF_COOL] = {
animation = "top_of_cool_anim",
tween = "end_event_twn",
grps = { "top_of_cool_grp" },
sfx = "Panda_HUD_Cool",
no_switch_sfx = true,
},
[GENKI_FLY_SUPER_ETHICAL] = {
animation = "super_ethical_anim",
tween = "end_event_twn",
grps = { "super_ethical_grp" },
sfx = "Panda_HUD_Super_Ethical",
no_switch_sfx = true,
},
[GENKI_FLY_CLEARED] = {
animation = "cleared_anim",
tween = "end_event_twn",
grps = { "cleared_grp" },
sfx = "Panda_HUD_Cleared",
no_switch_sfx = true,
},
[GENKI_FLY_ETHICAL] = {
animation = "ethical_anim",
tween = "end_event_twn",
grps = { "ethical_grp" },
sfx = "Panda_HUD_Ethical",
no_switch_sfx = true,
},
[GENKI_FLY_UNETHICAL] = {
animation = "unethical_anim",
tween = "end_event_twn",
grps = { "unethical_grp" },
sfx = "Panda_HUD_Unethical",
no_switch_sfx = true,
},
[GENKI_RUN_SHARK] = {
animation = "shark_anim",
tween = "end_event_twn",
grps = { "shark_grp" },
sfx = "Jungle_HUD_Water_Bear",
no_switch_sfx = true,
},
[GENKI_ESCORT_FIRE] = {
animation = "fire_car_anim",
tween = "end_event_twn",
grps = { "fire_car_grp" },
sfx = "Escort_HUD_Flame",
no_switch_sfx = true,
},
[GENKI_BALL_BOUNCE] = {
animation = "bounce_anim",
tween = "end_event_twn",
grps = { "bounce_grp" },
sfx = "Yarnball_HUD_Shockwave",
no_switch_sfx = true,
},
}
Genki_run_doc_handle = -1
Genki_ball_doc_handle = -1
Genki_fly_doc_handle = -1
Genki_escort_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
Genki_common_doc_handle = -1
function genki_ball_init()
genki_common_init()
end
function genki_escort_init()
genki_common_init()
end
function genki_fly_init()
genki_common_init()
end
function genki_run_init()
genki_common_init()
end
function genki_common_init()
--assign doc handle
Genki_run_doc_handle = vint_document_find("genki_run")
Genki_ball_doc_handle = vint_document_find("genki_ball")
Genki_fly_doc_handle = vint_document_find("genki_fly")
Genki_escort_doc_handle = vint_document_find("genki_escort")
if Genki_run_doc_handle ~= nil and Genki_run_doc_handle > 0 then
Genki_common_doc_handle = Genki_run_doc_handle
-- unload the full screen map to pillage memory
pause_map_dump()
elseif Genki_ball_doc_handle ~= nil and Genki_ball_doc_handle > 0 then
Genki_common_doc_handle = Genki_ball_doc_handle
elseif Genki_fly_doc_handle ~= nil and Genki_fly_doc_handle > 0 then
Genki_common_doc_handle = Genki_fly_doc_handle
pause_map_dump()
elseif Genki_escort_doc_handle ~= nil and Genki_escort_doc_handle > 0 then
Genki_common_doc_handle = Genki_escort_doc_handle
end
-- 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 that need to switch images
local unethical_anim = Vdo_anim_object:new("unethical_anim", 0, Genki_common_doc_handle)
local trap_electric_anim = Vdo_anim_object:new("trap_eletric_anim", 0, Genki_common_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
---------------------
--testing stuff start
---------------------
function test_running_man()
delay(1)
hud_running_man_load_complete()
end
function hud_running_man_load_complete()
if Genki_common_doc_handle == Genki_run_doc_handle or Genki_common_doc_handle == Genki_fly_doc_handle then
game_peg_load_with_cb("hud_running_man_peg_loaded", 1, "ui_bms_rm")
end
end
function hud_running_man_peg_loaded()
Running_man_peg_loaded = true
hud_running_man_event_update(RM_START_MATCH)
end
-------------------
--testing stuff 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
if Genki_common_doc_handle == Genki_run_doc_handle or Genki_common_doc_handle == Genki_fly_doc_handle then
return
end
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, Genki_common_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
if Data[event_idx].no_switch_sfx then
Rm_hud_event_audio_id = audio_object_post_event(Data[event_idx].sfx)
else
Rm_hud_event_audio_id = audio_object_post_event("Activity", {"Activity_Type","Running_Man"}, {"Running_Man",Data[event_idx].sfx})
end
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 genki_ball_cleanup()
genki_common_cleanup()
end
function genki_escort_cleanup()
genki_common_cleanup()
end
function genki_fly_cleanup()
genki_common_cleanup()
end
function genki_run_cleanup()
genki_common_cleanup()
end
function genki_common_cleanup()
if Genki_common_doc_handle == Genki_run_doc_handle or Genki_common_doc_handle == Genki_fly_doc_handle then
game_peg_unload("ui_bms_rm")
pause_map_restore()
end
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, Genki_common_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, Genki_common_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, Genki_common_doc_handle)
local genki_head_grp = Vdo_base_object:new("genki_head_grp", 0, Genki_common_doc_handle)
local anim_h = vint_object_find("time_low_anim")
local timer_txt = Vdo_base_object:new("timer_txt", 0, Genki_common_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(false)
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