--Enums for events
SS_GO_ARROW = 1
SS_PLAYER_1_HEALTH = 2
SS_PLAYER_2_HEALTH = 3
SS_SHOW_HUD = 4
--SS_PLAYER_1_HEALTH_GAIN = 4 --Handled automatically by health update
--SS_PLAYER_2_HEALTH_GAIN = 5
SS_INTRO_SPLASH = 6
SS_STAGE_COMPLETE_1 = 7
SS_STAGE_COMPLETE_2 = 8
SS_STAGE_COMPLETE_3 = 9
SS_BOSS_INTRO_1 = 10
SS_BOSS_INTRO_2 = 11
SS_COMPLETION = 12
SS_INTRO_SPLASH_2 = 13
SS_STAGE_START_1 = 15
SS_STAGE_START_2 = 16
SS_STAGE_START_3 = 17
SS_INTRO_SPLASH_OUT = 18
--Position constants for pc lives digits
local LIVES_NUM_1_X = -26
local LIVES_NUM_2_X = 0
local LIVES_NUM_Y = 0
local Ss_event_data = {
[SS_GO_ARROW] = {
name = "go!",
anim_data = {
[1] = {
anim = "go_color_anim",
cb = "loop"
},
[2] = {
--This anim uses a bounce cycle, no need for cb
anim = "go_fade_move_anim",
},
},
image_data = {
[1] = {
image_element = "go_arrow_img",
image = "ui_ss_go_arrow"
},
[2] = {
image_element = "go_arrow_blend_img",
image = "ui_ss_go_arrow"
},
},
grp = "go_grp"
},
[SS_SHOW_HUD] = {
name = "show_hud",
anim_data = {
[1] = {
anim = "static_anim",
},
},
grp = "static_grp"
},
[SS_STAGE_COMPLETE_1] = {
name = "stage_complete_1",
anim_data = {
[1] = {
anim = "stage_complete_anim",
}
},
image_data = {
[1] = {
image_element = "stage_img",
image = "ui_ss_stage"
},
[2] = {
image_element = "complete_img",
image = "ui_ss_complete"
},
},
grp = "stage_complete_grp"
},
[SS_STAGE_COMPLETE_2] = {
name = "stage_complete_2",
anim_data = {
[1] = {
anim = "stage_complete_anim",
}
},
image_data = {
[1] = {
image_element = "stage_img",
image = "ui_ss_stage"
},
[2] = {
image_element = "complete_img",
image = "ui_ss_complete"
},
},
grp = "stage_complete_grp"
},
[SS_STAGE_COMPLETE_3] = {
name = "stage_complete_3",
anim_data = {
[1] = {
anim = "stage_complete_anim",
}
},
image_data = {
[1] = {
image_element = "stage_img",
image = "ui_ss_stage"
},
[2] = {
image_element = "complete_img",
image = "ui_ss_complete"
},
},
grp = "stage_complete_grp"
},
[SS_BOSS_INTRO_1] = {
name = "boss_intro_1",
anim_data = {
[1] = {
anim = "boss_intro_jyn_anim",
cb = "show_static_grp",
}
},
image_data = {
[1] = {
image_element = "gat_img",
image = "ui_ss_boss_gat",
},
[2] = {
image_element = "jyn_img",
image = "ui_ss_boss_warren",
},
[3] = {
image_element = "boss_title_img",
image = "ui_ss_boss_title_warren",
},
},
grp = "boss_jyn_grp"
},
[SS_BOSS_INTRO_2] = {
name = "boss_intro_2",
anim_data = {
[1] = {
anim = "boss_intro_jyn_anim",
cb = "show_static_grp",
}
},
image_data = {
[1] = {
image_element = "gat_img",
image = "ui_ss_boss_gat",
},
[2] = {
image_element = "jyn_img",
image = "ui_ss_boss_jyn",
},
[3] = {
image_element = "boss_title_img",
image = "ui_ss_boss_title_jyn",
},
},
grp = "boss_jyn_grp"
},
[SS_INTRO_SPLASH] = {
name = "intro_splash",
anim_data = {
[1] = {
anim = "winners_anim",
cb = "load_peg_ss_intro",
},
},
image_data = {
[1] = {
image_element = "intro_img",
image = "ui_ss_winners_dont_use_drugs",
},
},
grp = "winners_grp"
},
[SS_INTRO_SPLASH_2] = {
name = "press_start",
anim_data = {
[1] = {
anim = "intro_anim",
cb = "intro_anim_done",
},
},
image_data = {
[1] = {
image_element = "city_bg_img",
image = "ui_ss_intro_bg",
},
[2] = {
image_element = "johnny_img",
image = "ui_ss_gat_intro",
},
[3] = {
image_element = "logo_img",
image = "ui_ss_rage_logo",
},
},
grp = "intro_grp"
},
[SS_INTRO_SPLASH_OUT] = {
name = "intro_splash_out",
anim_data = {
[1] = {
anim = "intro_fade_anim",
},
},
image_data = {
[1] = {
image_element = "city_bg_img",
image = "ui_ss_intro_bg",
},
[2] = {
image_element = "johnny_img",
image = "ui_ss_gat_intro",
},
[3] = {
image_element = "logo_img",
image = "ui_ss_rage_logo",
},
},
grp = "intro_grp"
},
[SS_COMPLETION] = {
name = "completion",
anim_data = {
[1] = {
anim = "end_anim",
}
},
image_data = {
[1] = {
image_element = "end_gat_img",
image = "ui_gat_end",
},
[2] = {
image_element = "end_aisha_img",
image = "ui_aisha_end",
},
},
grp = "end_grp"
},
[SS_STAGE_START_1] = {
name = "stage_start_1",
anim_data = {
[1] = {
anim = "stage_complete_anim",
cb = "show_static_grp",
}
},
image_data = {
[1] = {
image_element = "stage_img",
image = "ui_ss_stage"
},
[2] = {
image_element = "complete_img",
image = "ui_ss_stage_num_1"
},
},
grp = "stage_complete_grp"
},
[SS_STAGE_START_2] = {
name = "stage_start_2",
anim_data = {
[1] = {
anim = "stage_complete_anim",
cb = "show_static_grp",
}
},
image_data = {
[1] = {
image_element = "stage_img",
image = "ui_ss_stage"
},
[2] = {
image_element = "complete_img",
image = "ui_ss_stage_num_2"
},
},
grp = "stage_complete_grp"
},
[SS_STAGE_START_3] = {
name = "stage_start_3",
anim_data = {
[1] = {
anim = "stage_complete_anim",
cb = "show_static_grp",
}
},
image_data = {
[1] = {
image_element = "stage_img",
image = "ui_ss_stage"
},
[2] = {
image_element = "complete_img",
image = "ui_ss_stage_num_3"
},
},
grp = "stage_complete_grp"
},
}
--Boss images
local BOSS_NONE = 0
local BOSS_WARREN_WILLIAMS = 1
local BOSS_JYN = 2
local BOSS_SUPER_JYN = 3
local Boss_data = {
[BOSS_WARREN_WILLIAMS] = {
icon = "ui_ss_boss_icon_warren",
title = "ui_ss_boss_text_warren",
},
[BOSS_JYN] = {
icon = "ui_ss_boss_icon_jyn",
title = "ui_ss_boss_text_jyn",
},
[BOSS_SUPER_JYN] = {
icon = "ui_ss_boss_icon_jyn",
title = "ui_ss_boss_text_super_jyn",
},
}
local Msn_side_scroller_doc_h = -1
local Event_listener_h = -1
local Ss_peg_is_loaded = false
local Ss_intro_peg_is_loaded = false
local Ss_winners_peg_is_loaded = false
local Input_tracker = -1
local Mouse_input_tracker = -1
local P1_score = 0
local P2_score = 0
local P1_health = 0
local P2_health = 0
local Player_lives = 0
local Boss_health = 0
local Boss_id = 0
local Ss_loaded_from_checkpoint = false
local Ss_intro_anim_is_done = false
local Ss_press_start_called = false
local Ss_thread_peg_load_h = 0
local Ss_thread_sim_stop_event_h = 0
local Ss_thread_test_lives_h = 0
local Combo_counter = 0
function msn_side_scroller_init()
Msn_side_scroller_doc_h = vint_document_find("msn_side_scroller")
-- JAM 5/16/13 : Removing press start because of co-op, localization, PC, etc. - it was a cool feature :(
--[[Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("all_unassigned", "msn_side_scroller_press_start", 50)
Input_tracker:add_input("pause", "msn_side_scroller_press_start", 50)
Input_tracker:add_input("select", "msn_side_scroller_press_start", 50)
-- PC inputs
if game_get_platform() == "PC" then
-- Use full screen bg image as target handle
local city_bg_img_h = vint_object_find("city_bg_img", 0, Msn_side_scroller_doc_h)
Mouse_input_tracker = Vdo_input_tracker:new()
Mouse_input_tracker:add_mouse_input("mouse_click", "msn_side_scroller_mouse_click", 0, city_bg_img_h)
end
msn_side_scroller_controls_lock()
]]
--Hide screen until peg is loaded
local screen_grp_h = vint_object_find("screen_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(screen_grp_h, "alpha", 0)
--Hide all grps
--Loop through event data and hide all grps
for idx, grp in pairs( Ss_event_data ) do
if grp ~= nil then
local grp_h = vint_object_find(Ss_event_data[idx].grp, 0, Msn_side_scroller_doc_h)
vint_set_property(grp_h, "visible", false)
end
end
--Hide individual grps
local combo_grp_h = vint_object_find("combo_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(combo_grp_h, "alpha", 0)
local boss_health_grp_h = vint_object_find("boss_health_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(boss_health_grp_h, "alpha", 0)
local lives_grp_h = vint_object_find("lives_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(lives_grp_h, "visible", false)
local multi_img_h = vint_object_find("multi_img", 0, Msn_side_scroller_doc_h)
vint_set_property(multi_img_h, "visible", false)
local p2_grp_h = vint_object_find("p2_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(p2_grp_h, "visible", false)
--Localize end text
local end_txt_1_h = vint_object_find("end_txt_1", 0, Msn_side_scroller_doc_h)
local end_txt_2_h = vint_object_find("end_txt_2", 0, Msn_side_scroller_doc_h)
local end_txt_3_h = vint_object_find("end_txt_3", 0, Msn_side_scroller_doc_h)
vint_set_property(end_txt_1_h, "text_tag", "M15_ENDING_LINE_01")
vint_set_property(end_txt_2_h, "text_tag", "M15_ENDING_LINE_02")
vint_set_property(end_txt_3_h, "text_tag", "M15_ENDING_LINE_03")
--Set end event to advance the press start screen automatically after ~8 secs
local press_start_anim_h = vint_set_property(Ss_event_data[SS_INTRO_SPLASH_2].anim_data[1].anim, 0, Msn_side_scroller_doc_h)
local press_start_done_twn_h = vint_object_find("press_start_done_twn", press_start_anim_h)
vint_set_property(press_start_done_twn_h, "end_event", "msn_side_scroller_press_start")
vint_dataitem_add_subscription( "msn_side_scroll", "update", "msn_side_scroller_data_update" )
Event_listener_h = vint_scriptevent_listen( "msn_side_scroll", "msn_side_scroller_event" )
--Set score at 0 to hide all number graphics initially
msn_side_scroller_score_update(0, 0)
end
function msn_side_scroller_unload()
game_peg_list_unload_wait( { "ui_bms_ss", "ui_bms_ss_intro", "ui_ss_intro_bg", "ui_ss_winners_dont_use_drugs" } )
end
function msn_side_scroller_cleanup()
pause_map_restore()
vint_scriptevent_stop_listening( Event_listener_h )
thread_kill(Ss_thread_peg_load_h)
thread_kill(Ss_thread_sim_stop_event_h)
thread_kill(Ss_thread_test_lives_h)
Ss_thread_peg_load_h = 0
Ss_thread_sim_stop_event_h = 0
Ss_thread_test_lives_h = 0
end
function msn_side_scroller_intro_load()
Ss_thread_peg_load_h = thread_new("msn_side_scroller_load_peg_delay_intro")
--msn_side_scroller_controls_unlock()
end
function msn_side_scroller_hud_load()
Ss_loaded_from_checkpoint = true
Ss_thread_peg_load_h = thread_new("msn_side_scroller_load_peg_delay_hud")
end
-------------------------------------------------------------------------------
-- Function msn_side_scroller_load_peg_delay_intro()
--
-- Dump pause map and loads intro peg a.k.a "Winners Don't Use Drugs" peg
--
-------------------------------------------------------------------------------
function msn_side_scroller_load_peg_delay_intro()
pause_map_dump(true)
--msn_side_scroller_load_peg_ss()
msn_side_scroller_load_peg_winners()
end
-------------------------------------------------------------------------------
-- Function msn_side_scroller_load_peg_delay_hud()
--
-- Dump pause map and loads intro hud peg ui_bms_ss
--
-------------------------------------------------------------------------------
function msn_side_scroller_load_peg_delay_hud()
pause_map_dump(true)
--msn_side_scroller_load_peg_ss()
msn_side_scroller_load_peg_ss()
end
-------------------------------------------------------------------------------
-- Function msn_side_scroller_load_peg_winners()
--
-- Loads intro peg a.k.a "Winners Don't Use Drugs" peg
--
-------------------------------------------------------------------------------
function msn_side_scroller_load_peg_winners()
game_peg_load_with_cb("msn_side_scroller_complete_load", 1, "ui_ss_winners_dont_use_drugs")
end
-------------------------------------------------------------------------------
-- Function msn_side_scroller_load_peg_ss()
--
-- Unloads intro peg and loads the sheet for the sidescroller
--
-------------------------------------------------------------------------------
function msn_side_scroller_load_peg_ss()
-- Unload intro peg if loaded
if Ss_intro_peg_is_loaded then
game_peg_unload_wait("ui_bms_ss_intro")
game_peg_unload_wait("ui_ss_intro_bg")
Ss_intro_peg_is_loaded = false
end
-- Unload winners peg if it's loaded
if Ss_winners_peg_is_loaded then
game_peg_unload_wait("ui_ss_winners_dont_use_drugs")
Ss_winners_peg_is_loaded = false
end
-- Load ui_bms_ss used for the side scroller HUD
game_peg_load_with_cb("msn_side_scroller_peg_complete_load_ss", 1, "ui_bms_ss")
end
-------------------------------------------------------------------------------
-- Function msn_side_scroller_load_peg_ss_intro()
--
-- Unloads winners peg and loads intro pegs
--
-------------------------------------------------------------------------------
function msn_side_scroller_load_peg_ss_intro()
game_peg_unload_wait("ui_ss_winners_dont_use_drugs")
Ss_winners_peg_is_loaded = false
--Wait for intro peg to unload, then load ui_bms_ss
game_peg_load_with_cb("msn_side_scroller_peg_complete_load_ss_intro", 2, "ui_bms_ss_intro", "ui_ss_intro_bg")
end
-------------------------------------------------------------------------------
-- Function msn_side_scroller_peg_complete_load_ss()
--
-- Sets flag that side scroller peg is loaded
--
-------------------------------------------------------------------------------
function msn_side_scroller_peg_complete_load_ss()
Ss_peg_is_loaded = true
--Peg is loaded, show screen
local screen_grp_h = vint_object_find("screen_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(screen_grp_h, "alpha", 1)
end
-------------------------------------------------------------------------------
-- Function msn_side_scroller_peg_complete_load_ss_intro()
--
-- Kicks off intro screen anim
--
-------------------------------------------------------------------------------
function msn_side_scroller_peg_complete_load_ss_intro()
Ss_intro_peg_is_loaded = true
msn_side_scroller_update(SS_INTRO_SPLASH_2, true)
end
function test_side_scroller_stop_event()
delay(5)
msn_side_scroller_update(SS_GO_ARROW)
end
function test_lives()
--msn_side_scroller_update(SS_BOSS_INTRO_1)
--for i = 0, 100 do
-- delay(.05)
-- msn_side_scroller_health_update(0 + i/100, 0 + i/100, 0.2, i)
--end
--[[for i=100, 0, -1 do
delay(.05)
debug_print("vint","Msn_side_scroller :::::::::::::: lives::::::::::: "..var_to_string(i).."\n\n")
msn_side_scroller_health_update(0.5, 0.5, 0.2, i)
end]]--
end
function msn_side_scroller_complete_load()
Ss_winners_peg_is_loaded = true
--Peg is loaded, show screen
local screen_grp_h = vint_object_find("screen_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(screen_grp_h, "alpha", 1)
--For test only
--msn_side_scroller_update(SS_COMPLETION, true)
--msn_side_scroller_health_update(0.5,0.5,0.5,0)
--msn_side_scroller_health_update(0.5, 0.5, 0.3, 9)
end
function msn_side_scroller_data_update( di_h )
local p1_health, p2_health, player_lives, boss_health, boss_id, p1_score, p2_score, combo = vint_dataitem_get(di_h)
--If nothing changed return
if p1_health == nil or p2_health == nil or player_lives == nil or boss_health == nil or boss_id == nil or p1_score == nil or p2_score == nil or combo == nil then
return
end
if boss_id ~= Boss_id then
Boss_id = boss_id
end
--If score changed update the score
if p1_score ~= P1_score or p2_score ~= P2_score then
msn_side_scroller_score_update(p1_score, p2_score)
end
--Update combo
if combo ~= 0 then
msn_side_scroller_combo_update(combo)
end
--Update health and lives
if p1_health ~= P1_health or p2_health ~= P2_health or player_lives ~= Player_lives or Boss_health ~= boss_health then
msn_side_scroller_health_update(p1_health, p2_health, boss_health, player_lives)
end
end
--Listener for events from code
function msn_side_scroller_event( event_name, param )
local event = nil
if event_name == "intro_load" then
msn_side_scroller_intro_load()
end
if event_name == "checkpoint_restart" then
msn_side_scroller_hud_load()
end
for k, i in pairs( Ss_event_data ) do
if i.name == event_name then
event = k
break
end
end
if event == nil then
return
end
msn_side_scroller_update( event, param )
end
-------------------------------------------------------------------------------
-- Function msn_side_scroller_update()
--
-- Plays or stops all events for the sidescroller mission
--
-- @param event -- event to play or stop
-- @param play_event -- play or stop the event
--
-------------------------------------------------------------------------------
function msn_side_scroller_update(event, play_event)
-- If we're trying to show the hud and the peg isn't loaded, then load it
if (event == SS_SHOW_HUD or event == SS_STAGE_START_1) and Ss_peg_is_loaded == false then
msn_side_scroller_load_peg_ss()
--msn_side_scroller_controls_unlock()
end
local curr_event = Ss_event_data[event]
--Show group and set images
local grp_h = vint_object_find(curr_event.grp, 0, Msn_side_scroller_doc_h)
if play_event ~= nil then
vint_set_property(grp_h, "visible", play_event)
end
--Loop through all images and set them now that the peg is loaded
if curr_event.image_data ~= nil then
for i = 1, #curr_event.image_data do
local curr_image_data = curr_event.image_data[i]
local image_h = vint_object_find(curr_image_data.image_element, grp_h, Msn_side_scroller_doc_h)
vint_set_property(image_h, "image", curr_image_data.image)
end
end
--Loop through all anims and play them
for i = 1, #curr_event.anim_data do
local curr_anim_data = curr_event.anim_data[i]
local anim_h = vint_object_find(curr_anim_data.anim, 0, Msn_side_scroller_doc_h)
local end_event_twn_h = vint_object_find("end_event_twn", anim_h)
--Handle callbacks or play only once
if curr_anim_data.cb == "loop" then
--Loop anim
vint_set_property(end_event_twn_h, "end_event", "msn_side_scroller_loop_anim_cb")
elseif curr_anim_data.cb ~= nil then
--Go to a specific callback
vint_set_property(end_event_twn_h, "end_event", "msn_side_scroller_"..curr_anim_data.cb)
else
vint_set_property(end_event_twn_h, "end_event", nil)
end
vint_apply_start_values(anim_h)
--Start/Stop event anim
if play_event == false then
vint_set_property(anim_h, "is_paused", true)
--Return after we stop the last anim
if i == #curr_event.anim_data then
return
end
else
lua_play_anim(anim_h, 0, Msn_side_scroller_doc_h)
end
end
--Special cases-------------------------------------------------------
--For stage complete hide all other grps
--Turn back on when animation is finished
if event ~= SS_PLAYER_1_HEALTH and event ~= SS_PLAYER_2_HEALTH and event ~= SS_GO_ARROW and event ~= SS_SHOW_HUD then
local static_grp_h = vint_object_find("static_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(static_grp_h, "visible", false)
end
end
-------------------------------------------------------------------------------
-- Looping callback
--
function msn_side_scroller_loop_anim_cb(tween_handle)
local animation = vint_object_parent(tween_handle)
lua_play_anim(animation, 0, Msn_side_scroller_doc_h)
end
-------------------------------------------------------------------------------
-- Show hud callback
--
function msn_side_scroller_show_static_grp()
local static_grp_h = vint_object_find("static_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(static_grp_h, "visible", true)
end
function msn_side_scroller_health_update(p1_health, p2_health, boss_health, lives)
--Did we gain health? If so, play health up animation
local p1_meter_fill_grp_h = vint_object_find("p1_meter_fill_grp", 0, Msn_side_scroller_doc_h)
local p2_meter_fill_grp_h = vint_object_find("p2_meter_fill_grp", 0, Msn_side_scroller_doc_h)
local p1_meter_fill_up_h = vint_object_find("p1_health_meter_up_img", p1_meter_fill_grp_h, Msn_side_scroller_doc_h)
local p2_meter_fill_up_h = vint_object_find("p2_health_meter_up_img", p2_meter_fill_grp_h, Msn_side_scroller_doc_h)
vint_set_property(p1_meter_fill_up_h, "alpha", 0)
vint_set_property(p2_meter_fill_up_h, "alpha", 0)
if p1_health > P1_health then
local p1_health_up_anim_h = vint_object_find("p1_health_up_anim")
lua_play_anim(p1_health_up_anim_h, 0)
end
if p2_health > P2_health then
local p2_health_up_anim_h = vint_object_find("p2_health_up_anim")
lua_play_anim(p2_health_up_anim_h, 0)
end
--Save states
P1_health = p1_health
Boss_health = boss_health
Player_lives = lives
debug_print( "vint", "msn_side_scroller_health_update()\n" )
--Set p1's health
local meter_mask_h = vint_object_find("health_meter_mask_img", p1_meter_fill_grp_h, Msn_side_scroller_doc_h)
local METER_FULL_PCT = 325
local meter_mask_x, meter_mask_y = vint_get_property(meter_mask_h, "anchor")
local new_x = METER_FULL_PCT * p1_health
vint_set_property(meter_mask_h, "anchor", new_x, meter_mask_y)
--Set p2's health
if p2_health ~= -1 and p2_health ~= nil then
local p2_grp_h = vint_object_find("p2_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(p2_grp_h, "visible", true)
local meter_mask_h = vint_object_find("health_meter_mask_img", p2_meter_fill_grp_h, Msn_side_scroller_doc_h)
local METER_FULL_PCT = 325
local meter_mask_x, meter_mask_y = vint_get_property(meter_mask_h, "anchor")
local new_x = METER_FULL_PCT * p2_health
vint_set_property(meter_mask_h, "anchor", new_x, meter_mask_y)
end
--Set boss health
if boss_health ~= -1 then
local boss_health_grp_h = vint_object_find("boss_health_grp", 0, Msn_side_scroller_doc_h)
local boss_meter_mask_h = vint_object_find("boss_meter_mask_img", 0, Msn_side_scroller_doc_h)
local boss_meter_mask_x, boss_meter_mask_y = vint_get_property(boss_meter_mask_h, "anchor")
new_x = METER_FULL_PCT * boss_health
vint_set_property(boss_meter_mask_h, "anchor", new_x, boss_meter_mask_y)
vint_set_property(boss_health_grp_h, "alpha", 1)
else
local boss_health_grp_h = vint_object_find("boss_health_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(boss_health_grp_h, "alpha", 0)
end
--Set boss icon and name
local boss_icon_img_h = vint_object_find("boss_icon_img", 0, Msn_side_scroller_doc_h)
local boss_txt_img_h = vint_object_find("boss_txt_img", 0, Msn_side_scroller_doc_h)
if Boss_id ~= 0 then
vint_set_property(boss_icon_img_h, "image", Boss_data[Boss_id].icon)
vint_set_property(boss_txt_img_h, "image", Boss_data[Boss_id].title)
vint_set_property(boss_icon_img_h, "visible", true)
vint_set_property(boss_txt_img_h, "visible", true)
else
vint_set_property(boss_icon_img_h, "visible", false)
vint_set_property(boss_txt_img_h, "visible", false)
end
--Set player's lives
--lives are shared by both players in co-op
local lives_grp_h = vint_object_find("lives_grp", 0, Msn_side_scroller_doc_h)
vint_set_property(lives_grp_h, "visible", true)
local multi_img_h = vint_object_find("multi_img", 0, Msn_side_scroller_doc_h)
vint_set_property(multi_img_h, "visible", true)
if lives < 0 or lives == nil then
--Hide the lives because there aren't any
vint_set_property(lives_grp_h, "visible", false)
vint_set_property(multi_img_h, "visible", false)
elseif lives >= 0 and lives < 10 then
--Position the digits for 1 digit
vint_set_property(lives_grp_h, "anchor", LIVES_NUM_1_X, LIVES_NUM_Y)
msn_side_scroller_set_number(lives, "lives")
elseif lives >= 10 and lives < 100 then
--Shift the digits over by 1 to make room for 2 digits
vint_set_property(lives_grp_h, "anchor", LIVES_NUM_2_X, LIVES_NUM_Y)
msn_side_scroller_set_number(lives, "lives")
elseif lives >= 100 then
--Player should never have more than 99 lives
--If they do cap it at 99
vint_set_property(lives_grp_h, "anchor", LIVES_NUM_2_X, LIVES_NUM_Y)
msn_side_scroller_set_number(99, "lives")
end
end
function msn_side_scroller_score_update(p1_new_score, p2_new_score)
--Update the score
P1_score = p1_new_score
msn_side_scroller_set_number(P1_score, "p1_score")
if p2_new_score ~= nil and p2_new_score ~= -1 then
P2_score = p2_new_score
msn_side_scroller_set_number(P2_score, "p2_score")
end
end
function msn_side_scroller_combo_update(combo)
--Update combo txt
msn_side_scroller_set_number(combo, "combo")
--Only play if the player gets a combo of 3 or more
if combo > 2 then
local combo_anim_h = vint_object_find("combo_anim", 0, Msn_side_scroller_doc_h)
local combo_end_event_twn_h = vint_object_find("end_event_twn", combo_anim_h)
vint_set_property(combo_end_event_twn_h, "end_event", "msn_side_scroller_combo_reset")
lua_play_anim(combo_anim_h, 0)
end
end
function msn_side_scroller_combo_reset()
--Update Score
--msn_side_scroller_score_update(Combo_counter)
--Reset combo
Combo_counter = 0
end
----------------------------------------------------------------------------------------------------
-- Function: msn_side_scroller_set_number
--
-- Description: Divide a number into separate digits so we can invdividually set images to a custom
-- pixel number font
--
-- Params:
-- num --The number to separate
-- grp --Score or combo grp
----------------------------------------------------------------------------------------------------
function msn_side_scroller_set_number(num, grp)
local nums = {}
--Reusing this function for combo and score. Make sure a parent grp is present to determine
--which numbers to set.
local parent_grp_h
local max_digits
local max_score
if grp == "p1_score" then
parent_grp_h = vint_object_find("p1_score_grp", 0, Msn_side_scroller_doc_h)
max_digits = 6
max_score = 999999
elseif grp == "p2_score" then
parent_grp_h = vint_object_find("p2_score_grp", 0, Msn_side_scroller_doc_h)
max_digits = 6
max_score = 999999
elseif grp == "combo" then
parent_grp_h = vint_object_find("combo_grp", 0, Msn_side_scroller_doc_h)
max_digits = 6
max_score = 999999
elseif grp == "lives" then
parent_grp_h = vint_object_find("lives_grp", 0, Msn_side_scroller_doc_h)
max_digits = 2
max_score = 99
end
for i=1, max_digits do
nums[i] = vint_object_find("num_img_"..i, parent_grp_h, Msn_side_scroller_doc_h)
vint_set_property(nums[i], "visible", false)
end
local num_temp = num
if num_temp > max_score then
num_temp = max_score
end
--Handle negative numbers
if num_temp < 0 then
return
end
--Handle 0
if num_temp == 0 and ( grp == "p1_score" or grp == "p2_score" or grp == "lives" ) then
vint_set_property(nums[max_digits], "image", "ui_ss_num_"..num_temp)
vint_set_property(nums[max_digits], "visible", true)
end
--Handle everything else
for n = 1, max_digits do
if num_temp == 0 then
break
else
local d = num_temp - ( floor( num_temp / 10 ) * 10 )
-- set the bmp for digit n to be number d
vint_set_property(nums[(max_digits + 1) -n], "image", "ui_ss_num_"..d)
vint_set_property(nums[(max_digits + 1)-n], "visible", true)
end
num_temp = floor( num_temp / 10 )
end
end
function msn_side_scroller_nav_a(event)
--For test only
Combo_counter = Combo_counter + 1
msn_side_scroller_combo_update(Combo_counter)
end
function msn_side_scroller_intro_anim_done()
Ss_intro_anim_is_done = true
end
-------------------------------------------------------------------------------
-- Fades out the press start screen. Gives controls back to game.
--
function msn_side_scroller_press_start()
if Ss_intro_anim_is_done and Ss_press_start_called == false then
msn_side_scroller_update(SS_INTRO_SPLASH_OUT, true)
--Input_tracker:remove_all()
--if game_get_platform() == "PC" then
-- Mouse_input_tracker:remove_all()
--end
--msn_side_scroller_controls_lock()
Ss_press_start_called = true
--script event post here
vint_scriptevent_post("intro_complete")
end
end
function msn_side_scroller_controls_lock()
--[[Input_tracker:subscribe(false)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(false)
end]]
end
function msn_side_scroller_controls_unlock()
--[[Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(true)
end]]
end
function msn_side_scroller_mouse_click(event, target_handle)
--[[-- Use full screen bg image as target handle
local city_bg_img_h = vint_object_find("city_bg_img", 0, Msn_side_scroller_doc_h)
if target_handle == city_bg_img_h then
msn_side_scroller_press_start()
end]]
end