-------------------------------------------------------------------------------
--Constants
-------------------------------------------------------------------------------
CMP_TEST_MODE = false --Modes for testing...
CMP_TEST_NO_MULTIPLIER = false
--LUT tables...
CMP_LUT_DEFAULT = "none"
CMP_LUT_MISSION = "lut_completion_screen"
--Screen Layout
CMP_SCREEN_LAYOUT_LEFT = 0
CMP_SCREEN_LAYOUT_RIGHT = 1
--Screen types...
CMP_SCREEN_TITLE_INDEX = 1
CMP_SCREEN_TIERS_INDEX = 2
CMP_SCREEN_CASH_INDEX = 3
CMP_SCREEN_RESPECT_INDEX = 4
CMP_SCREEN_CONTROL_INDEX = 5
CMP_SCREEN_REWARD_INDEX = 6
CMP_SCREEN_COOP_WAIT_INDEX = 7
--Score types...
CMP_SCORE_TYPE_CASH = 1
CMP_SCORE_TYPE_TIME = 2
CMP_SCORE_TYPE_NAKED = 3
CMP_SCORE_TYPE_FRAUD = 4
--Hint button positions
CMP_HINT_Y = 380
CMP_TIERS_HINT_Y = 580
--Respect Constants...
local RESPECT_START_ANGLE = 2.51
local RESPECT_END_ANGLE = 2.65 -- This is really negative, but entering as positive to make equation work
local RESPECT_METER_UPDATE = 0
local RESPECT_METER_UPDATE_BONUS = 1
local RESPECT_METER_UPDATE_NO_BONUS = 2
-- District Control Constants...
local CONTROL_START_ANGLE = 2.43
local CONTROL_END_ANGLE = 2.27000 -- This is really negative, but entering as positive to make equation work
local RESPECT_METER_UPDATE = 0
local RESPECT_METER_UPDATE_BONUS = 1
local RESPECT_METER_UPDATE_NO_BONUS = 2
-- Cash/Respect Ramp Constants for Animation and Audio... (in Milliseconds)
local CMP_TIME_CASH = 1166
local CMP_TIME_CASH_BONUS = 1100
local CMP_TIME_CASH_NO_BONUS = 1166
local CMP_TIME_RESPECT = 1766
local CMP_TIME_RESPECT_BONUS = 1580
local CMP_TIME_RESPECT_NO_BONUS = 1166
local CMP_TIME_CONTROL = 1580
local CMP_TIME_SCORE = 1166
local CMP_COLOR_TEXT_PURPLE = {R=148/255, G=0/255, B=197/255}
local CMP_COLOR_TEXT_WHITE = {R=220/255, G=220/255, B=220/255}
local CMP_COLOR_TEXT_WHITE_2 = {R=180/255, G=180/255, B=180/255}
--Tiers
local CMP_COLOR_TIERS_BRONZE = {R=160/255, G=74/255, B=33/255}
local CMP_COLOR_TIERS_SILVER = {R=163/255, G=163/255, B=163/255}
local CMP_COLOR_TIERS_GOLD = {R=198/255, G=137/255, B=26/255}
local TIER_BRONZE = 1
local TIER_SILVER = 2
local TIER_GOLD = 3
---------------------------------------------------------------------------------------------------------------------------------------------------------
-- Globals
---------------------------------------------------------------------------------------------------------------------------------------------------------
Cmp_screen_idx = 0 -- Index of the current screen
Cmp_screen_sequence_started = false -- Bool determines if we have started the screen...
Cmp_screen_is_playing = false -- Bool determines whether the current screen is in an animation state.
Cmp_screen_is_skipped = false -- Bool determines wheter we've hit skip already
Cmp_screen_base_x = 0 -- Base position x
Cmp_screen_base_y = 0 -- Base position Y
Cmp_common_doc = -1 -- Handle of common document
Cmp_specific_doc = -1 -- Handle of specific completion screen doc(mission, activity, stronghold)
Cmp_image = 0 -- Used to store reference to loaded image for any completion screen format.
Cmp_common_has_image = false -- Used to determine if we have an image or not (cannot use the name because of the way we load the image)
Cmp_common_image_is_visible = true -- Used to determine if the completion image is visible or so we don't fade it out twice...
Cmp_common_bg_saints_active = false -- Used to determine if bg saints is active or not...
Cmp_common_shake_is_playing = false -- Did we shake the screen? Used to prevent multiple slams
Cmp_Input_tracker = -1 -- Input tracker
Cmp_common_input_is_blocked = true -- Flag to block input when needed
Cmp_common_input_delay_thread = -1 -- Delay input thread id
Cmp_common_coop_dialog_handle = 0 -- coop dialog for exiting early...
Cmp_sequence_data = -1 -- Data reference for screen, this is set through cmp_common_screen_set_data().
Cmp_hintbar = -1 -- Global for the Hintbar VDO used on all the screens.
Cmp_common_audio_ramp_id = -1 -- Reference to audio ramp
Cmp_common_audio_music_id = -1 -- Reference to completion screen music...
local Cmp_mouse_input_tracker -- Mouse input tracker
local Cmp_bg_image -- Handle for full screen bg image used for pc inputs
-- Audio flags to ensure events only play once
local Cmp_audio_title_done = false
local Cmp_audio_title_skip_done = false
local Cmp_audio_tiers_done = false
local Cmp_audio_tiers_skip_done = false
local Cmp_audio_cash_done = false
local Cmp_audio_cash_skip_done = false
local Cmp_audio_respect_done = false
local Cmp_audio_respect_skip_done = false
local Cmp_audio_control_done = false
local Cmp_audio_control_skip_done = false
--Stars
local Cmp_stars = {
[1] = "star_01",
[2] = "star_02",
[3] = "star_03",
[4] = "star_04",
[5] = "star_05",
[6] = "star_06",
[7] = "star_07",
[8] = "star_08",
[9] = "star_09",
[10] = "star_10",
[11] = "star_11",
[12] = "star_12",
}
--Tiers
local Tier_data = {}
--Cash count
Cmp_screen_cash_start = 0 --When the cash count starts this the starting value...
Cmp_screen_cash_end = 0 --When the cash count ends this is the ending value...
Cmp_screen_cash_total = 0 --The total amount of cash earned...
Cmp_screen_cash_skip_bonus = false --Determines whether or not we skip the multiplier stage...
Cmp_screen_cash_count_is_bonus = false --Determines whether we are doing the bonus stage or not...
Cmp_screen_cash_skip = 0 --Determines if the cash screen should be skipped
Cmp_common_cash_complete_cb = 0 --Callback for function after cash is completed...
--Score
Cmp_screen_score_start = 0
Cmp_screen_score_end = 0
Cmp_screen_score_total = 0
Cmp_screen_score_skip = false
Cmp_common_score_complete_cb = 0
--Respect
Cmp_screen_respect_queue = {}
Cmp_screen_respect_level_dif = 0 --Difference to the next level, this gets decremented every fill.
Cmp_screen_respect_target_pct = 0 --Target percentage for final fill, this is what the meter is set to after the last full fill.
Cmp_screen_respect_time_start = 0 --This is the fill time for the percent part of the meter....
Cmp_screen_respect_time_mid = 0
Cmp_screen_respect_time_end = 0
Cmp_screen_respect_level_cur = 0 --This is the current level of the respect, we will increment manually this every time the meter fills up...
Cmp_screen_respect_skip_bonus = false --Determines whether or not we skip the multiplier stage...
--Coop
Cmp_screen_coop_is_waiting = false --Determines whether or not we are on the coop waiting screen.
Cmp_screen_coop_gamer_tag = "PLAYER" --Coop gamer tag... this should get updated by c++ in cmp_common_coop_wait_start()
local continue_hint_data = {
{CTRL_MENU_BUTTON_A, "COMPLETION_CONTINUE"},
}
local coop_hint_data = {
{CTRL_MENU_BUTTON_BACK, "COMPLETION_COOP_DISCONNECT"},
}
Cmp_use_as_background = true
function cmp_common_init()
--Set common doc global...
Cmp_common_doc = vint_document_find("cmp_common")
pause_map_dump()
--special dlc cmp images
if (mission_is_active("dlc1_m04") == true) then
Cmp_image = "ui_cmp_dlc_paul"
elseif (mission_is_active("dlc1_m05") == true) then
Cmp_image = "ui_cmp_dlc_dino"
else
Cmp_image = "ui_cmp_crest"
end
game_peg_load_with_cb("cmp_common_pointless_callback", 1, Cmp_image)
local h = vint_object_find("screen_grp")
Cmp_screen_base_x, Cmp_screen_base_y = vint_get_property(h, "anchor")
--Init Hintbar
Cmp_hintbar = Vdo_hint_bar:new("hint_bar")
Cmp_hintbar:set_hints(continue_hint_data)
Cmp_hintbar:enable_text_shadow(true)
if( game_get_platform() ~= "PC" ) then
Cmp_hintbar:pulse(1)
end
Cmp_hintbar:set_alpha(0)
local coop_hintbar = Vdo_hint_bar:new("coop_hint_bar")
coop_hintbar:set_hints(coop_hint_data)
coop_hintbar:enable_text_shadow(true)
--Hide elements
local h = vint_object_find("background_base")
vint_set_property(h, "visible", false)
local h = vint_object_find("title_grp", 0, Cmp_common_doc)
vint_set_property(h, "alpha", 0)
local h = vint_object_find("tiers_grp", 0, Cmp_common_doc)
vint_set_property(h, "alpha", 0)
--Hide medal for now
local h = vint_object_find("big_medal_grp", 0, Cmp_common_doc)
vint_set_property(h, "visible", false)
local h = vint_object_find("cash_grp", 0, Cmp_common_doc)
vint_set_property(h, "alpha", 0)
local h = vint_object_find("cash_bonus_txt", 0, Cmp_common_doc)
vint_set_property(h, "alpha", 0)
local h = vint_object_find("respect_grp", 0, Cmp_common_doc)
vint_set_property(h, "alpha", 0)
local h = vint_object_find("control_grp", 0, Cmp_common_doc)
vint_set_property(h, "alpha", 0)
local h = vint_object_find("coop_wait_grp", 0, Cmp_common_doc)
vint_set_property(h, "alpha", 0)
local img_bg_grp_h = vint_object_find("img_bg_grp", 0, Cmp_common_doc)
vint_set_property(img_bg_grp_h, "visible", true)
local img_grp_h = vint_object_find("img_grp", 0, Cmp_common_doc)
vint_set_property(img_grp_h, "visible", false)
-- Dynamically Replace color on all elements...
local purple_elements = {
"title_txt",
"cash_txt",
"respect_meter",
"respect_txt",
}
local white_elements = {
"complete_txt",
"cash_amount_txt",
"respect_level_text",
}
local white_2_elements = {
"respect_bonus_txt",
"cash_bonus_txt",
}
--[[for idx, val in pairs(purple_elements) do
local h = vint_object_find(val)
vint_set_property(h, "tint", CMP_COLOR_TEXT_PURPLE.R, CMP_COLOR_TEXT_PURPLE.G, CMP_COLOR_TEXT_PURPLE.B)
end
for idx, val in pairs(white_elements) do
local h = vint_object_find(val)
vint_set_property(h, "tint", CMP_COLOR_TEXT_WHITE.R, CMP_COLOR_TEXT_WHITE.G, CMP_COLOR_TEXT_WHITE.B)
end
for idx, val in pairs(white_2_elements) do
local h = vint_object_find(val)
vint_set_property(h, "tint", CMP_COLOR_TEXT_WHITE_2.R, CMP_COLOR_TEXT_WHITE_2.G, CMP_COLOR_TEXT_WHITE_2.B)
end]]--
--Note: Cash will end on its own because it is run via thread...
--Enable Cash Callback...
cmp_common_cash_callback_enable(true)
--Enable Tiers Callback...
cmp_common_tiers_cb_enable(true)
--Enable Respect Callback...
cmp_common_respect_cb_enable(true)
--Enable Control Callback...
cmp_common_control_cb_enable(true)
--Enable sound callbacks
cmp_audio_cb_enable()
--Input
Cmp_Input_tracker = Vdo_input_tracker:new()
Cmp_Input_tracker:add_input("select", "cmp_process_input", 50)
Cmp_Input_tracker:add_input("back", "cmp_process_input", 50)
Cmp_Input_tracker:add_input("map", "cmp_process_input", 50)
Cmp_Input_tracker:add_input("pause", "cmp_process_input", 50)
Cmp_Input_tracker:add_input("all_unassigned", "cmp_common_do_nothing", 50)
Cmp_Input_tracker:subscribe(false)
if game_get_platform() == "PC" then
Cmp_bg_image = Vdo_base_object:new("background_bmp", 0, Cmp_common_doc)
Cmp_mouse_input_tracker = Vdo_input_tracker:new()
Cmp_mouse_input_tracker:add_mouse_input("mouse_move", "cmp_common_mouse_move", 0, Cmp_bg_image.handle)
Cmp_mouse_input_tracker:add_mouse_input("mouse_click", "cmp_common_mouse_click", 0, Cmp_bg_image.handle)
Cmp_mouse_input_tracker:subscribe(false)
end
vint_dataitem_add_subscription("completion_camera_shake", "update", "cmp_common_camera_shake_update")
end
function cmp_common_cleanup()
--unsubscribe inputs...
if Cmp_Input_tracker ~= nil then
Cmp_Input_tracker:subscribe(false)
end
if Cmp_mouse_input_tracker ~= nil then
Cmp_mouse_input_tracker:subscribe(false)
end
--Unload image if we had one.....
if Cmp_image ~= 0 then
game_peg_unload(Cmp_image)
end
cmp_common_lut_effect(CMP_LUT_DEFAULT)
pause_map_restore()
--Stop music...
game_audio_stop(Cmp_common_audio_music_id)
--stop any glitches
vint_set_glitch_preset("hub")
vint_spike_glitch(0, 0)
Cmp_hintbar:cleanup()
end
function cmp_common_screen_start(screen_layout)
--Play Intro Animation...(This is screen independant)
local intro_anim_h = vint_object_find("screen_in_anim", 0, Cmp_common_doc)
lua_play_anim(intro_anim_h, 0, Cmp_common_doc)
Cmp_use_as_background = true
--determine if we skipped a cutscene or if there is no final screen
local mission_doc_h = vint_document_find("cmp_mission")
local activity_doc_h = vint_document_find("cmp_activity")
local stronghold_doc_h = vint_document_find("cmp_stronghold")
local show_mission_image = false
local digits_grp_h = vint_object_find("digits_grp", 0, Cmp_common_doc)
local lines_grp_h = vint_object_find("lines_grp", 0, Cmp_common_doc)
local glow_h = vint_object_find("glow", 0, Cmp_common_doc)
local swish_color_grp_h = vint_object_find("swish_color_grp", 0, Cmp_common_doc)
--set the bg to blue for activities, purple for missions
if mission_doc_h ~= 0 then
vint_set_property(digits_grp_h, "tint", COLOR_CMP_BG_MISSION.R, COLOR_CMP_BG_MISSION.G, COLOR_CMP_BG_MISSION.B)
vint_set_property(lines_grp_h, "tint", COLOR_CMP_BG_MISSION.R, COLOR_CMP_BG_MISSION.G, COLOR_CMP_BG_MISSION.B)
vint_set_property(glow_h, "tint", COLOR_CMP_BG_MISSION.R, COLOR_CMP_BG_MISSION.G, COLOR_CMP_BG_MISSION.B)
vint_set_property(swish_color_grp_h, "tint", COLOR_CMP_BG_MISSION_SWISH.R, COLOR_CMP_BG_MISSION_SWISH.G, COLOR_CMP_BG_MISSION_SWISH.B)
elseif activity_doc_h ~=0 then
vint_set_property(digits_grp_h, "tint", COLOR_CMP_BG_ACTIVITY.R, COLOR_CMP_BG_ACTIVITY.G, COLOR_CMP_BG_ACTIVITY.B)
vint_set_property(lines_grp_h, "tint", COLOR_CMP_BG_ACTIVITY.R, COLOR_CMP_BG_ACTIVITY.G, COLOR_CMP_BG_ACTIVITY.B)
vint_set_property(glow_h, "tint", COLOR_CMP_BG_ACTIVITY.R, COLOR_CMP_BG_ACTIVITY.G, COLOR_CMP_BG_ACTIVITY.B)
vint_set_property(swish_color_grp_h, "tint", COLOR_CMP_BG_ACTIVITY_SWISH.R, COLOR_CMP_BG_ACTIVITY_SWISH.G, COLOR_CMP_BG_ACTIVITY_SWISH.B)
end
--check to see if we want to show the image for mission screens...
if mission_doc_h ~= 0 then
--first check if we had an active cutscene...
if completion_cutscene_was_active() then
--now check to see if we skipped the cutscene
if completion_cutscene_was_skipped() then
show_mission_image = true
end
end
if not completion_cutscene_was_active() then
show_mission_image = true
end
--Show black style screen if credits were active...(used in final cutscenes m23_out and m24_out)
if completion_cutscene_was_active() then
if completion_credits_were_active() then
show_mission_image = true
end
end
end
--Do not show image if its Jon's new Activity Cmp screen
if activity_doc_h ~= 0 then
show_mission_image = false
end
--Show the image if
if show_mission_image then
--reset screen layout...
screen_layout = CMP_SCREEN_LAYOUT_LEFT
--set image (this is loaded in with cmp_mission)
--local image = "ui_cmp_crest"
--Cmp_sequence_data[1].image = image
--Set global to image name and set image names to the objects via callback.
cmp_common_image_loaded()
--Clear out the global image name so we don't try to clean it up.
--Cmp_image = 0
Cmp_use_as_background = false
else
Cmp_use_as_background = true
end
--Show the cutscene slamout background
if show_mission_image ~= true and mission_doc_h ~= 0 then
local img_bg_grp_h = vint_object_find("img_bg_grp", 0, Cmp_common_doc)
vint_set_property(img_bg_grp_h, "visible", true)
end
--Show background_base...
local h = vint_object_find("background_base", 0, Cmp_common_doc)
vint_set_property(h, "visible", true)
vint_set_property(h, "background", Cmp_use_as_background)
--Right Justify screen if needed...
if screen_layout == CMP_SCREEN_LAYOUT_RIGHT then
--Align screen right (screen is default left aligned)
--TODO: Tweak this for right aligned screens
cmp_common_right_justification()
end
-- Advance first screen...
cmp_common_screen_advance(false)
--Set that we have started the sequence...
Cmp_screen_sequence_started = true
-- Unblock input.
Cmp_Input_tracker:subscribe(true)
if Cmp_mouse_input_tracker ~= nil then
Cmp_mouse_input_tracker:subscribe(true)
end
end
function cmp_common_screen_set_data(data)
Cmp_sequence_data = data
end
-- Advances screen to next screen in sequence.
-- @param force_advance bool determines if we force advance to the next screen...
function cmp_common_screen_advance(force_advance)
if force_advance == false or force_advance == nil then
if Cmp_screen_is_playing then
--A current screen is in progress... we should force it to the end...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
if screen_data ~= nil and Cmp_screen_is_skipped == false then
--Call Skip function for that particular screen type...
local screen_type = screen_data.type
Cmp_screens[screen_data.type].skip_func()
Cmp_screen_is_skipped = true
end
return
end
end
-- If we aren't force advancing, we will animate it out.
if force_advance == false or force_advance == nil then
--Animate out the previous screen...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
if screen_data ~= nil then
local screen_type = screen_data.type
Cmp_screens[screen_data.type].out_func()
end
end
--Increment the current screen to next...
Cmp_screen_idx = Cmp_screen_idx + 1
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
--if we are a screen before the final screen we should attemp to hide bg_saints_fade_anim
if screen_data ~= nil then
if screen_data.type == CMP_SCREEN_REWARD_INDEX then
--Make sure image is faded out...
cmp_common_image_fade_out()
end
if screen_data.type == CMP_SCREEN_COOP_WAIT_INDEX then
--Make sure image is faded out...
cmp_common_image_fade_out()
end
--Only for activity completion
local activity_doc_h = vint_document_find("cmp_activity")
if activity_doc_h ~= 0 then
if screen_data.type == CMP_SCREEN_REWARD_INDEX or screen_data.type == CMP_SCREEN_COOP_WAIT_INDEX then
--Wait for player exit animation to finish
if Player_exit_animation_has_played == false then
--While the animation is playing out block input...
Cmp_common_input_is_blocked = true
--Play the player exit animation...
cmp_activity_play_exit_anim()
--Delay the next screen start until the animation is completed.
thread_new("cmp_common_wait_for_player_anim_thread")
return
end
end
end
end
--Determine if we start the next screen or exit...
if screen_data ~= nil then
--Call Start function for that particular screen type...
local screen_type = screen_data.type
Cmp_screens[screen_data.type].start_func()
Cmp_screen_is_skipped = false
else
-- Do nothing... Final screen is always the coop screen
-- and will bypass itself automatically if not needed to display.
return
end
end
----------------------------------------------------------------
-- Screen based functions
----------------------------------------------------------------
----------------------------------------------------------------
-- Title screen
----------------------------------------------------------------
function cmp_common_title_start()
--Block input briefly to counteract button mashing
cmp_common_input_block_delay()
--We're playing an animation
Cmp_screen_is_playing = true
--Set properties from screen data...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
local title_string = screen_data.title_string
local title_txt_h = vint_object_find("title_txt", 0, Cmp_common_doc)
vint_set_property(title_txt_h, "text_tag", title_string)
--Setup up animation and callbacks
local title_anim_h = vint_object_find("title_in_anim", 0, Cmp_common_doc)
--Shake the camera and glitch the screen
local end_event_twn_h = vint_object_find("end_event_twn", title_anim_h)
vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large")
--Glitch the screen a small amount
local glitch_twn_h = vint_object_find("glitch_twn", title_anim_h)
vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")
--Control the game letterboxing (JAM: Do we still need this?)
--Load the LUT
local twn_h = vint_object_find("title_in_twn", title_anim_h)
vint_set_property(twn_h, "end_event", "cmp_common_title_slam")
--Show the hint bar, set Cmp_screen_is_playing to false
local twn_h = vint_object_find("title_end_twn", title_anim_h)
vint_set_property(twn_h, "end_event", "cmp_common_title_end")
lua_play_anim(title_anim_h, 0, Cmp_common_doc)
--Execute on start func if available...
if screen_data.on_start ~= nil and type(screen_data.on_start) == "function" then
screen_data.on_start()
end
end
function cmp_common_title_skip()
--Clear callbacks
local title_anim_h = vint_object_find("title_in_anim", 0, Cmp_common_doc)
--Shake the camera and glitch the screen
local end_event_twn_h = vint_object_find("end_event_twn", title_anim_h)
vint_set_property(end_event_twn_h, "end_event", nil)
--Glitch the screen a small amount
local glitch_twn_h = vint_object_find("glitch_twn", title_anim_h)
vint_set_property(glitch_twn_h, "end_event", nil)
--Move title anim to end...
local title_anim_h = vint_object_find("title_in_anim", 0, Cmp_common_doc)
lua_play_anim(title_anim_h, -2.5, Cmp_common_doc)
cmp_common_glitch_large()
end
function cmp_common_title_end()
--Show hints...
cmp_common_hint_bar_show()
--We're done playing
Cmp_screen_is_playing = false
end
--JAM: Not needed with new design, keeping for letterbox
function cmp_common_title_slam()
--cmp_common_lut_effect(CMP_LUT_MISSION)
game_letterbox_fade_out(true)
end
function cmp_common_title_out()
--Fade out title
local title_out_anim_h = vint_object_find("title_out_anim", 0, Cmp_common_doc)
lua_play_anim(title_out_anim_h, 0, Cmp_common_doc)
Cmp_common_shake_is_playing = false
--Hide hint bar
cmp_common_hint_bar_hide()
end
--Glitch the screen a lot and shake the camera
function cmp_common_glitch_large()
--Don't play if we're already animating
if Cmp_common_shake_is_playing == false then
Cmp_common_shake_is_playing = true
cmp_common_camera_shake()
--play animation of excellence
local slam_anim_h = vint_object_find("slam_anim", 0, Cmp_common_doc)
lua_play_anim(slam_anim_h)
glitch_cell()
--vint_set_glitch_preset( "falling_skies" )
--vint_set_glitch_percent( 1.0 )
--vint_spike_glitch( 500, 0 )
end
end
--Glitch the screen only a little
function cmp_common_glitch_small()
vint_set_glitch_preset("hub")
vint_spike_glitch( 50, .2 )
--vint_set_glitch_preset( "falling_skies" )
--vint_set_glitch_percent( .5 )
--vint_spike_glitch( 100, 0 )
end
-------------------------------------------------------------------------------
-- Special case function to change the scale if needed.
--
function cmp_common_title_resize(scale)
local title_txt_h = vint_object_find("title_txt", 0, Cmp_common_doc)
vint_set_property(title_txt_h, "text_scale", scale, scale)
end
----------------------------------------------------------------
-- Cash screen
----------------------------------------------------------------
function cmp_common_cash_start()
--Initialize cash stuff...
Cmp_screen_is_playing = true
--Get properties from screen data...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
if CMP_TEST_MODE then
screen_data.cash_reward = 2000
screen_data.cash_multiplier = 50
screen_data.cash_reward_inc_multiplier = 5000
if CMP_TEST_NO_MULTIPLIER then
screen_data.cash_multiplier = 0
end
end
if screen_data.cash_reward == 0 then
--skip this screen if no reward granted...
cmp_common_cash_callback_enable(false)
cmp_common_screen_advance(true)
return
end
--delay input...
cmp_common_input_block_delay()
local cash_reward = screen_data.cash_reward
local cash_multiplier = screen_data.cash_multiplier
local cash_reward_inc_multiplier = screen_data.cash_reward_inc_multiplier
Cmp_screen_cash_start = 0
Cmp_screen_cash_end = cash_reward
Cmp_screen_cash_total = cash_reward_inc_multiplier
--Update bonus text...
local bonus_txt_h = vint_object_find("cash_bonus_txt", 0, Cmp_common_doc)
local values = {[0] = cash_multiplier}
local bonus_string = vint_insert_values_in_string("COMPLETION_BONUS", values)
vint_set_property(bonus_txt_h, "text_tag", bonus_string)
local cash_in_anim_h = vint_object_find("cash_in_anim", 0, Cmp_common_doc)
--Shake the camera and glitch the screen
local end_event_twn_h = vint_object_find("end_event_twn", cash_in_anim_h)
vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large")
--Glitch the screen a small amount
local glitch_twn_h = vint_object_find("glitch_twn", cash_in_anim_h)
vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")
--Set callback for cash count complete
if cash_multiplier > 0 then
--Show bonus stage...
Cmp_common_cash_complete_cb = "cmp_common_cash_bonus_start"
Cmp_screen_cash_skip_bonus = false
else
--Skip bonus stage...
Cmp_common_cash_complete_cb = "cmp_common_cash_end"
Cmp_screen_cash_skip_bonus = true
end
local twn_h = vint_object_find("cash_bonus_twn", cash_in_anim_h)
vint_set_property(twn_h, "end_event", Cmp_common_cash_complete_cb)
--Start in the non bonus stage...
Cmp_screen_cash_count_is_bonus = false
--Start cash animation in...
lua_play_anim(cash_in_anim_h, 0, Cmp_common_doc)
--Start counting the cash...
local cash_count_thread = thread_new("cmp_common_cash_count_thread")
end
function cmp_common_cash_skip()
--Destroy callbacks
cmp_common_cash_callback_enable(false)
local cash_in_anim_h = vint_object_find("cash_in_anim", 0, Cmp_common_doc)
--Clear cash in callback.
local end_event_twn_h = vint_object_find("end_event_twn", cash_in_anim_h)
vint_set_property(end_event_twn_h, "end_event", nil)
--Clear Glitch callback.
local glitch_twn_h = vint_object_find("glitch_twn", cash_in_anim_h)
vint_set_property(glitch_twn_h, "end_event", nil)
--Clear out cash bonus tween callback
local twn_h = vint_object_find("cash_bonus_twn", cash_in_anim_h)
vint_set_property(twn_h, "end_event", nil)
cmp_common_glitch_large()
local cash_h = vint_object_find("cash_amount_txt", 0, Cmp_common_doc)
vint_set_property(cash_h, "text_tag", "{GAME_CASH}" .. format_cash(Cmp_screen_cash_total) .. "\n")
if Cmp_screen_cash_skip_bonus == false then
--Skip bonus cash...
local cash_bonus_anim_h = vint_object_find("cash_bonus_in_anim", 0, Cmp_common_doc)
local cash_bonus_end_twn_h = vint_object_find("cash_bonus_end_twn", cash_bonus_anim_h)
vint_set_property(cash_bonus_end_twn_h, "end_event", "cmp_common_cash_end")
lua_play_anim(cash_bonus_anim_h, -1, Cmp_common_doc)
else
--Clear out cash bonus tween callback
local twn_h = vint_object_find("cash_bonus_twn", cash_in_anim_h)
vint_set_property(twn_h, "end_event", "cmp_common_cash_end")
end
lua_play_anim(cash_in_anim_h, -2.5, Cmp_common_doc)
--Stop ramping audio...
--cmp_audio_stop_ramp()
Cmp_screen_cash_skip = true
end
function cmp_common_cash_slam()
if Cmp_screen_is_playing then
if Cmp_screen_cash_skip_bonus then
-- skipping bonus... so, start ramp...
-- and of course... no multiplier
--cmp_audio_cash_ramp_no_multiplier()
else
--Start ramp with bonus..
--cmp_audio_cash_ramp_multiplier()
end
end
end
function cmp_common_cash_end()
--Show hints...
-- Overriding y value because we share this screen with activities and missions
local new_hint_bar_y = CMP_HINT_Y
cmp_common_hint_bar_show(new_hint_bar_y)
Cmp_screen_is_playing = false
end
function cmp_common_cash_out()
--Fade out Cash
local cash_out_anim_h = vint_object_find("cash_out_anim", 0, Cmp_common_doc)
lua_play_anim(cash_out_anim_h, 0, Cmp_common_doc)
Cmp_common_shake_is_playing = false
cmp_common_hint_bar_hide()
end
function cmp_common_cash_count_thread()
--init stuff
local start_cash = Cmp_screen_cash_start -- $ amount to start cash from...
local cash_this_frame = -1 -- How much cash gets displayed in the current frame...
local is_complete = false -- Is the screen complete?
Cmp_screen_cash_skip = false -- Did we skip the cash?
--get the variables from the global
local cash = Cmp_screen_cash_end - start_cash
local cash_end = Cmp_screen_cash_end
local amt_min = 100
local amt_max = 33000
local time_min = CMP_TIME_CASH
local time_max = CMP_TIME_CASH
if Cmp_screen_cash_count_is_bonus then
time_min = CMP_TIME_CASH_BONUS
time_max = CMP_TIME_CASH_BONUS
elseif Cmp_screen_cash_skip_bonus then
time_min = CMP_TIME_CASH_NO_BONUS
time_max = CMP_TIME_CASH_NO_BONUS
end
local init_time = floor(vint_get_time_index() * 1000)
local cur_time = init_time
local time_to_count = floor(time_min + ((time_max - time_min) * (cash / amt_max)))
if time_to_count > time_max then
time_to_count = time_max
end
if cash > 0 then
while is_complete == false do
local cur_time = floor(vint_get_time_index() * 1000) - init_time
--set my values
cash_this_frame = cash * (cur_time / time_to_count) + start_cash
local cash_h = vint_object_find("cash_amount_txt", 0, Cmp_common_doc)
vint_set_property(cash_h, "text_tag", "{GAME_CASH}" .. format_cash(cash_this_frame) .. "\n")
--Advance time so we skip...
if Cmp_screen_cash_skip == true then
cur_time = time_to_count
cash_end = Cmp_screen_cash_total
end
if cur_time >= time_to_count then
is_complete = true
--force the values
vint_set_property(cash_h, "text_tag", "{GAME_CASH}" .. format_cash(cash_end))
end
thread_yield()
end
else
-- Start next screen?
cmp_common_cash_end()
end
end
function cmp_common_cash_bonus_start()
--Start Cash Bonus Screen
local cash_anim_h = vint_object_find("cash_bonus_in_anim", 0, Cmp_common_doc)
local cash_bonus_end_twn_h = vint_object_find("cash_bonus_end_twn", cash_anim_h)
vint_set_property(cash_bonus_end_twn_h, "end_event", "cmp_common_cash_end")
--Skip ahead if we skipped
local start_time = 0
if Cmp_screen_cash_skip == true then
start_time = -2.5
end
lua_play_anim(cash_anim_h, start_time, Cmp_common_doc)
end
function cmp_common_cash_bonus_slam()
--Initialize cash stuff...
--Get properties from screen data...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
local cash_reward = screen_data.cash_reward
local cash_multiplier = screen_data.cash_multiplier
local cash_reward_inc_multiplier = screen_data.cash_reward_inc_multiplier
Cmp_screen_cash_start = cash_reward
Cmp_screen_cash_end = cash_reward_inc_multiplier
--Cash Ramp Bonus
--cmp_audio_cash_bonus_ramp()
--Start in the bonus stage...
Cmp_screen_cash_count_is_bonus = true
--Start counting the cash...
local cash_count_thread = thread_new("cmp_common_cash_count_thread")
end
-- Easy way to initialize or clear out the cash callbacks.
function cmp_common_cash_callback_enable(is_enabled)
local cash_slam_cb = "cmp_common_cash_slam"
local cash_bonus_slam_cb = "cmp_common_cash_bonus_slam"
if is_enabled == false then
cash_slam_cb = nil
cash_bonus_slam_cb = nil
end
--local twn_h = vint_object_find("cash_slam_twn", 0, Cmp_common_doc)
--vint_set_property(twn_h, "end_event", cash_slam_cb)
local twn_h = vint_object_find("cash_bonus_slam_twn", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", cash_bonus_slam_cb)
end
----------------------------------------------------------------
--Respect screen
----------------------------------------------------------------
function cmp_common_respect_start()
Cmp_screen_is_playing = true
--Get properties from screen data...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
--respect is always displayed as one level up... (internally respect starts at 0...
screen_data.respect_level_old = screen_data.respect_level_old + 1
screen_data.respect_level_new = screen_data.respect_level_new + 1
screen_data.respect_level_multiplier = screen_data.respect_level_multiplier + 1
if CMP_TEST_MODE then
screen_data.respect_pct_old = .1
screen_data.respect_level_old = 1
screen_data.respect_pct_new = .6
screen_data.respect_level_new = 2
screen_data.respect_multiplier = 40
screen_data.respect_pct_multiplier = .9
screen_data.respect_level_multiplier = 3
end
local respect_pct_old = screen_data.respect_pct_old
local respect_level_old = screen_data.respect_level_old
local respect_pct_new = screen_data.respect_pct_new
local respect_level_new = screen_data.respect_level_new
local respect_multiplier = screen_data.respect_multiplier
local respect_pct_multiplier = screen_data.respect_pct_multiplier
local respect_level_multiplier = screen_data.respect_level_multiplier
if respect_level_old == respect_pct_new and screen_data.respect_level_old == screen_data.respect_level_new then
--Force skip this scren... no respect to ad...
cmp_common_respect_cb_enable(false)
cmp_common_screen_advance(true)
return
end
--Delay input...
cmp_common_input_block_delay()
--Set bonus text...
local bonus_txt_h = vint_object_find("respect_bonus_txt", 0, Cmp_common_doc)
local values = {[0] = respect_multiplier}
local bonus_string = vint_insert_values_in_string("COMPLETION_BONUS", values)
vint_set_property(bonus_txt_h, "text_tag", bonus_string)
--figure out how long we are going to process the time...
local base_time = CMP_TIME_RESPECT
local respect_end_cb
if respect_multiplier ~= 0 then
respect_end_cb = "cmp_common_respect_bonus_start"
--We have respect Multiplier
base_time = CMP_TIME_RESPECT
--Ramp audio..
--cmp_audio_respect_ramp_multiplier()
else
respect_end_cb = "cmp_common_respect_end"
Cmp_screen_respect_skip_bonus = true
--No multiplier
base_time = CMP_TIME_RESPECT_NO_BONUS
--Ramp audio..
--cmp_audio_respect_ramp_no_multiplier()
end
--Start meter fill!
cmp_common_respect_meter_update(respect_pct_old, respect_pct_new, respect_level_old, respect_level_new, base_time)
local respect_in_anim_h = vint_object_find("respect_in_anim", 0, Cmp_common_doc)
--Shake the camera and glitch the screen
local end_event_twn_h = vint_object_find("end_event_twn", respect_in_anim_h)
vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large")
--Glitch the screen a small amount
local glitch_twn_h = vint_object_find("glitch_twn", respect_in_anim_h)
vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")
--Show the hint bar, set Cmp_screen_is_playing to false
local twn_h = vint_object_find("respect_end_twn", respect_in_anim_h)
vint_set_property(twn_h, "end_event", respect_end_cb)
lua_play_anim(respect_in_anim_h, 0, Cmp_common_doc)
end
function cmp_common_respect_skip()
--Stop any tween callbacks from happening...
cmp_common_respect_cb_enable(false)
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
local respect_pct_multiplier = screen_data.respect_pct_multiplier
local respect_level_multiplier = screen_data.respect_level_multiplier
cmp_common_respect_fill_meter(0, respect_pct_multiplier, false)
--Force meter level
local level = max(screen_data.respect_level_new, screen_data.respect_level_multiplier)
--Force level of respect meter...
local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc)
vint_set_property(txt_h, "text_tag", level)
local respect_in_anim_h = vint_object_find("respect_in_anim", 0, Cmp_common_doc)
--Clear respect cb
local end_event_twn_h = vint_object_find("end_event_twn", respect_in_anim_h)
vint_set_property(end_event_twn_h, "end_event", nil)
--Clear glitch cb
local glitch_twn_h = vint_object_find("glitch_twn", respect_in_anim_h)
vint_set_property(glitch_twn_h, "end_event", nil)
local twn_h = vint_object_find("respect_end_twn", respect_in_anim_h)
vint_set_property(twn_h, "end_event", "cmp_common_respect_end")
cmp_common_glitch_large()
lua_play_anim(respect_in_anim_h, -2.5, Cmp_common_doc)
if Cmp_screen_respect_skip_bonus == false then
--fast forward bonus animation...
local respect_bonus_in_anim_h = vint_object_find("respect_bonus_in_anim", 0, Cmp_common_doc)
lua_play_anim(respect_bonus_in_anim_h, -2.5)
end
--Stop ramping audio...
--cmp_audio_stop_ramp()
Cmp_screen_is_skipped = true
end
function cmp_common_respect_bonus_start()
local start_time = 0
if Cmp_screen_is_skipped == true then
start_time = -2.5
end
local respect_bonus_in_anim_h = vint_object_find("respect_bonus_in_anim", 0, Cmp_common_doc)
local twn_h = vint_object_find("respect_bonus_end_twn", respect_bonus_in_anim_h)
vint_set_property(twn_h, "end_event", "cmp_common_respect_end")
lua_play_anim(respect_bonus_in_anim_h, start_time, Cmp_common_doc)
end
function cmp_common_respect_end()
cmp_common_hint_bar_show()
Cmp_screen_is_playing = false
end
function cmp_common_respect_out()
--Fade out Respect
local respect_out_anim_h = vint_object_find("respect_out_anim", 0, Cmp_common_doc)
lua_play_anim(respect_out_anim_h, 0, Cmp_common_doc)
Cmp_common_shake_is_playing = false
--Hide hint button
cmp_common_hint_bar_hide()
end
--respect_up_level_up_cb_twn
function cmp_common_respect_slam()
end
--Bonus slam callback...
function cmp_common_respect_slam_bonus()
if Cmp_screen_is_playing then
--Get properties from screen data...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
local respect_pct_old = screen_data.respect_pct_old
local respect_level_old = screen_data.respect_level_old
local respect_pct_new = screen_data.respect_pct_new
local respect_level_new = screen_data.respect_level_new
local respect_multiplier = screen_data.respect_multiplier
local respect_pct_multiplier = screen_data.respect_pct_multiplier
local respect_level_multiplier = screen_data.respect_level_multiplier
--Do fillup to multiplier level...
cmp_common_respect_meter_update(respect_pct_new,respect_pct_multiplier, respect_level_new, respect_level_multiplier, CMP_TIME_RESPECT_BONUS)
--Set this flag so we don't play the bonus twice...
Cmp_screen_respect_skip_bonus = true
--Ramp audio...
--cmp_audio_respect_bonus_ramp()
end
end
-- Update/animate the respect meter
--
-- @param total_respect current total amount of respect player has
-- @param respect_pct % the player is towards their next rank level
-- @param level: player rank level
-- @param base Base time it should take to fill up the meter from start to finish
function cmp_common_respect_meter_update(old_respect_pct, respect_pct, old_level, new_level, base_time)
--Get differences between the levels
local level_dif = new_level - old_level
Cmp_screen_respect_level_cur = old_level
--Initialize the level of the meter...
local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc)
vint_set_property(txt_h, "text_tag", old_level)
--If the difference is greater than 0 then we are going to level up...
if level_dif > 0 then
--Store to global...
Cmp_screen_respect_level_dif = level_dif
--Store target percentage for the meter...
Cmp_screen_respect_target_pct = respect_pct
local first_ramp_pct = 1 - old_respect_pct
local final_ramp_pct = respect_pct
local level_dif = level_dif
--Calculate levels per second (total percentage / times the thing passes 0)
local revolutions_per_ms = base_time / (first_ramp_pct + (level_dif - 1) + final_ramp_pct)
Cmp_screen_respect_time_start = revolutions_per_ms * first_ramp_pct
Cmp_screen_respect_time_mid = revolutions_per_ms * 1
Cmp_screen_respect_time_end = revolutions_per_ms * final_ramp_pct
--Setup callback so it can be filled again and again...
local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_cb")
--Modify time to fill...
cmp_common_respect_set_time(Cmp_screen_respect_time_start)
cmp_common_respect_fill_meter(old_respect_pct, 1, true)
else
--No leveling, so do a standard one meter cycle increase.
Cmp_screen_respect_level_dif = 0
--Reset time to fill
cmp_common_respect_set_time(base_time)
--Fill meter anim...
cmp_common_respect_fill_meter(old_respect_pct, respect_pct, true)
end
end
---------------------------------------------------------------------------
-- Fills up the meter and plays added respect animation.
-- After animation is complete it does a callback which checks if we've
-- Increased a level and calls that animation...
--
-- @param old_respect_pct
-- @param respect_pct Percentage to transition too...
-- @param do_animation Text string for header
---------------------------------------------------------------------------
function cmp_common_respect_fill_meter(old_respect_pct, respect_pct, do_animation)
-- min/max for a percentage
respect_pct = limit(respect_pct, 0, 1)
local start_respect_angle = RESPECT_START_ANGLE - ((RESPECT_START_ANGLE + RESPECT_END_ANGLE) * old_respect_pct)
local end_respect_angle = RESPECT_START_ANGLE - ((RESPECT_START_ANGLE + RESPECT_END_ANGLE) * respect_pct)
if do_animation == true then
-- Animate Meter
local respect_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc)
local meter_tween_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc)
local meter_bg_tween_h = vint_object_find("respect_meter_bg_tween", 0, Cmp_common_doc)
-- Animate from previous to new
vint_set_property(meter_tween_h, "start_value", start_respect_angle)
vint_set_property(meter_tween_h, "end_value", end_respect_angle)
vint_set_property(meter_bg_tween_h, "start_value", start_respect_angle - .03)
vint_set_property(meter_bg_tween_h, "end_value", end_respect_angle - .03)
lua_play_anim(respect_up_anim_h, 0, Cmp_common_doc)
else
--Stop Animation...
local respect_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc)
vint_set_property(respect_up_anim_h, "is_paused", true)
--Manually set bars...
local respect_meter_h = vint_object_find("respect_meter", 0, Cmp_common_doc)
local respect_meter_bg_h = vint_object_find("respect_meter_bg", 0, Cmp_common_doc)
vint_set_property(respect_meter_h, "end_angle", end_respect_angle)
vint_set_property(respect_meter_bg_h, "end_angle", end_respect_angle - .03)
end
end
function cmp_common_respect_fill_cb()
--Decrement the level difference...
Cmp_screen_respect_level_dif = Cmp_screen_respect_level_dif - 1
--Swap the level
local anim_h = vint_object_find("respect_level_up_anim", 0, Cmp_common_doc)
lua_play_anim(anim_h, 0, Cmp_common_doc)
--Determine if we are going to fill up again?
if Cmp_screen_respect_level_dif <= 0 then
--Setup callback for this is the last time its going to be filled...
local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_end")
--Set the the target fill time to something we calculated earlier..
cmp_common_respect_set_time(Cmp_screen_respect_time_end)
--This is the last fill so lets fill it up to the target percent...
cmp_common_respect_fill_meter(0, Cmp_screen_respect_target_pct, true)
else
--reset callback to call this function again after meter fills.
local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_cb")
--Set the the target fill time to something we calculated earlier..
cmp_common_respect_set_time(Cmp_screen_respect_time_mid)
--Do normal fill animation to the top...
cmp_common_respect_fill_meter(0, 1, true)
end
end
function cmp_common_respect_fill_end()
-- Do we go into bonus?
if Cmp_screen_respect_skip_bonus == false then
--Lets not skip the bonus...
local respect_bonus_anim_in_h = vint_object_find("respect_bonus_in_anim", 0, Cmp_common_doc)
lua_play_anim(respect_bonus_anim_in_h, 0, Cmp_common_doc)
else
--End Screen
--cmp_common_respect_end(nil, true)
end
end
-- Upgrades the current level of the respect meter.
-- This happens via callback of the respect level up animation...
function cmp_common_respect_next_level()
Cmp_screen_respect_level_cur = Cmp_screen_respect_level_cur + 1
local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc)
vint_set_property(txt_h, "text_tag", Cmp_screen_respect_level_cur)
end
---------------------------------------------------------------------------
-- Sets the duration tweens for filling up the meter...
--
-- @param t Time it takes to fill up the meter...
---------------------------------------------------------------------------
function cmp_common_respect_set_time(t)
t = t * .001
local meter_tween_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc)
local meter_bg_tween_h =vint_object_find("respect_meter_bg_tween", 0, Cmp_common_doc)
vint_set_property(meter_tween_h, "duration", t)
vint_set_property(meter_bg_tween_h, "duration", t)
end
-- Easy way to initialize or clear out the respect callbacks.
function cmp_common_respect_cb_enable(is_enabled)
local respect_slam_cb = "cmp_common_respect_slam"
local respect_bonus_cb = "cmp_common_respect_slam_bonus"
local respect_level_cb = "cmp_common_respect_next_level"
if is_enabled == false then
respect_slam_cb = nil
respect_bonus_cb = nil
respect_level_cb = nil
end
--Respect Tween callbacks...
--local twn_h = vint_object_find("respect_slam_twn", 0, Cmp_common_doc)
--vint_set_property(twn_h, "end_event", respect_slam_cb)
local twn_h = vint_object_find("respect_bonus_twn", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", respect_bonus_cb)
-- when it is time to update the cash...
local twn_h = vint_object_find("respect_level_up_twn", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", respect_level_cb)
end
----------------------------------------------------------------
-- City Control screen
----------------------------------------------------------------
function cmp_common_control_start()
Cmp_screen_is_playing = true
--Get properties from screen data...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
if CMP_TEST_MODE then
-- do nothing...
end
local district_pct_old = screen_data.district_pct_old
local district_pct_new = screen_data.district_pct_new
local district_cash_per_day = screen_data.district_cash_per_day
local district_team_name = screen_data.district_team_name
if district_pct_new == 0 or district_pct_new == nil then
--Force skip this scren...
cmp_common_screen_advance(true)
return
end
if district_pct_new == district_pct_old then
-- Skip screen if there is no gained district.
cmp_common_screen_advance(true)
return
end
--Delay input...
cmp_common_input_block_delay()
--Set text...
local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc)
local values_1 = {[0] = floor(district_pct_old * 1000) * .1 }
local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1)
vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string)
local control_txt = vint_object_find("control_txt", 0, Cmp_common_doc)
local values_2 = {[0] = district_team_name}
local control_string = vint_insert_values_in_string("COMPLETION_CONTROL", values_2)
vint_set_property(control_txt, "text_tag", control_string)
local ctrl_width, ctrl_height = element_get_actual_size(control_txt)
local ctrl_width_max = 383 --HD
if vint_is_std_res() then
ctrl_width_max = 312
end
if ctrl_width > ctrl_width_max then
local scale = ctrl_width_max/ctrl_width
vint_set_property(control_txt, "scale", scale, scale)
end
local control_cash_txt_h = vint_object_find("control_cash_txt", 0, Cmp_common_doc)
local values_3 = {[0] = format_cash(district_cash_per_day)}
local control_cash_string = vint_insert_values_in_string("COMPLETION_CONTROL_PER_DAY", values_3)
vint_set_property(control_cash_txt_h, "text_tag", control_cash_string)
--figure out how long we are going to process the time...
local base_time = CMP_TIME_CONTROL * .001
--Ramp audio..
--cmp_audio_control_ramp()
--Start meter fill!
cmp_common_control_meter_update(0, district_pct_new, base_time)
local control_in_anim_h = vint_object_find("control_in_anim", 0, Cmp_common_doc)
--Shake the camera and glitch the screen
local end_event_twn_h = vint_object_find("end_event_twn", control_in_anim_h)
vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large")
--Glitch the screen a small amount
local glitch_twn_h = vint_object_find("glitch_twn", control_in_anim_h)
vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")
--Show the hint bar, set Cmp_screen_is_playing to false
local twn_h = vint_object_find("control_end_twn", control_in_anim_h)
vint_set_property(twn_h, "end_event", "cmp_common_control_end")
lua_play_anim(control_in_anim_h, 0, Cmp_common_doc)
--Slam in numbers
local control_level_up_anim_h = vint_object_find("control_level_up_anim", 0, Cmp_common_doc)
lua_play_anim(control_level_up_anim_h, 0, Cmp_common_doc)
end
function cmp_common_control_skip()
if Cmp_screen_is_playing then
--Stop any tween callbacks from happening...
cmp_common_control_cb_enable(false)
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
local district_pct_new = screen_data.district_pct_new
--Force meter level
cmp_common_control_fill_meter(0, district_pct_new, false)
-- Force text into meter...
local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc)
local values_1 = {[0] = floor(district_pct_new * 1000) * .1 }
local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1)
vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string)
--prevent audio callback from playing twice... I don't like this but its the only way (JMH 8/23/2011)
--Control Cash Slam
local twn_h = vint_object_find("control_cash_audio_slam_twn", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", nil)
local control_in_anim_h = vint_object_find("control_in_anim", 0, Cmp_common_doc)
--Shake the camera and glitch the screen
local end_event_twn_h = vint_object_find("end_event_twn", control_in_anim_h)
vint_set_property(end_event_twn_h, "end_event", nil)
--Glitch the screen a small amount
local glitch_twn_h = vint_object_find("glitch_twn", control_in_anim_h)
vint_set_property(glitch_twn_h, "end_event", nil)
--Show the hint bar, set Cmp_screen_is_playing to false
local twn_h = vint_object_find("control_end_twn", control_in_anim_h)
vint_set_property(twn_h, "end_event", "cmp_common_control_end")
cmp_common_glitch_large()
lua_play_anim(control_in_anim_h, -3.5, Cmp_common_doc)
--stop ramping audio...
--cmp_audio_stop_ramp()
end
end
function cmp_common_control_end()
cmp_common_hint_bar_show()
Cmp_screen_is_playing = false
end
function cmp_common_control_out()
--Fade out Respect
local control_out_anim_h = vint_object_find("control_out_anim", 0, Cmp_common_doc)
lua_play_anim(control_out_anim_h, 0, Cmp_common_doc)
cmp_common_hint_bar_hide()
end
-------------------------------------------------------------------------------
--Acitivies only...
--Delays the next start function until the player exit animation has completed...
--
function cmp_common_wait_for_player_anim_thread()
local delay_time = 0
while Player_exit_animation_done == false do
delay(0.1)
delay_time = delay_time + 0.1
if delay_time > 5 then
break
end
end
--Reset the block flag here to false, to possibly gain input back to the controller.s
Cmp_common_input_is_blocked = false
--Determine if we start the next screen or exit...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
if screen_data ~= nil then
--Call Start function for that particular screen type...
local screen_type = screen_data.type
Cmp_screens[screen_data.type].start_func()
Cmp_screen_is_skipped = false
else
-- Do nothing... Final screen is always the coop screen
-- and will bypass itself automatically if not needed to display.
return
end
end
-- When the meter flys in and stops we do this via tween cb...
function cmp_common_control_slam()
if Cmp_screen_is_playing then
cmp_common_camera_shake()
cmp_common_star_power_start()
end
end
-- Update/animate the respect meter
--
-- @param old_pct current total amount of control player has over district
-- @param new_pct current total amount of control player has over district
-- @param base_time Base time it should take to fill up the meter from start to finish
function cmp_common_control_meter_update(pct_old, pct_new, base_time)
--Reset time to fill
cmp_common_control_set_time(base_time)
--Setup callback for this is the only time its going to be filled...
local twn_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", "cmp_common_control_fill_end")
--Fill meter anim...
cmp_common_control_fill_meter(pct_old, pct_new, true)
end
---------------------------------------------------------------------------
-- Fills up the meter and plays added respect animation.
-- After animation is complete it does a callback which checks if we've
-- Increased a level and calls that animation...
--
-- @param pct_old
-- @param pct_new Percentage to transition too...
-- @param do_animation Text string for header
---------------------------------------------------------------------------
function cmp_common_control_fill_meter(pct_old, pct_new, do_animation)
-- min/max for a percentage
pct_old = limit(pct_old, 0, 1)
pct_new = limit(pct_new, 0, 1)
local start_angle = CONTROL_START_ANGLE - ((CONTROL_START_ANGLE + CONTROL_END_ANGLE) * pct_old)
local end_angle = CONTROL_START_ANGLE - ((CONTROL_START_ANGLE + CONTROL_END_ANGLE) * pct_new)
if do_animation == true then
-- Animate Meter
local control_up_anim_h = vint_object_find("control_up_anim", 0, Cmp_common_doc)
local meter_tween_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc)
local meter_bg_tween_h = vint_object_find("control_meter_bg_tween", 0, Cmp_common_doc)
-- Animate from previous to new
vint_set_property(meter_tween_h, "start_value", start_angle)
vint_set_property(meter_tween_h, "end_value", end_angle)
vint_set_property(meter_bg_tween_h, "start_value", start_angle - .03)
vint_set_property(meter_bg_tween_h, "end_value", end_angle - .03)
lua_play_anim(control_up_anim_h, 0, Cmp_common_doc)
else
--Stop Animation...
local control_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc)
vint_set_property(control_up_anim_h, "is_paused", true)
--Manually set bars...
local respect_meter_h = vint_object_find("respect_meter", 0, Cmp_common_doc)
local respect_meter_bg_h = vint_object_find("respect_meter_bg", 0, Cmp_common_doc)
vint_set_property(respect_meter_h, "end_angle", end_angle)
vint_set_property(respect_meter_bg_h, "end_angle", end_angle - .03)
end
-- Force text into meter...
local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc)
local values_1 = {[0] = floor(pct_new * 1000) * .1 }
local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1)
vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string)
end
function cmp_common_control_fill_end()
end
---------------------------------------------------------------------------
-- Sets the duration tweens for filling up the meter...
--
-- @param t Time it takes to fill up the meter...
---------------------------------------------------------------------------
function cmp_common_control_set_time(t)
local meter_tween_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc)
local meter_bg_tween_h = vint_object_find("control_meter_bg_tween", 0, Cmp_common_doc)
vint_set_property(meter_tween_h, "duration", t)
vint_set_property(meter_bg_tween_h, "duration", t)
end
-- Easy way to initialize or clear out the control callbacks.
function cmp_common_control_cb_enable(is_enabled)
local control_slam_cb = "cmp_common_control_slam"
if is_enabled == false then
control_slam_cb = nil
end
--Respect Tween callbacks...
--local twn_h = vint_object_find("control_slam_twn", 0, Cmp_common_doc)
--vint_set_property(twn_h, "end_event", control_slam_cb)
end
----------------------------------------------------------------
-- Rewards screen
----------------------------------------------------------------
function cmp_common_rewards_start()
Cmp_screen_is_playing = true
cmp_common_input_block_delay()
--Get properties from screen data...
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
local rewards_count = screen_data.rewards_count
--Set rewards count so it knows how many screens to display...
reward_granted_set_reward_count(rewards_count)
--Set callback on the reward screen, so we know when it is over...
set_reward_granted_end_cb(cmp_common_rewards_end)
--Start reward screen...
reward_granted_start()
end
function cmp_common_rewards_skip()
end
function cmp_common_rewards_end()
--Bring in background full black. so when we exit the reward screen we don't fade anything
--weird uncleaned up...
--hide the completion bg
local h = vint_object_find("background_bmp", 0, Cmp_common_doc)
vint_set_property(h, "alpha", 1)
vint_set_property(h, "depth", -4000)
--hide the character
h = vint_object_find("background_base", 0, Cmp_common_doc)
vint_set_property(h, "background", false)
--Hide everything local to the common screen... afterwards we should always transition back to game,
--So nothing else should display here from the main screen. This cleans up any
--Stars or stuff leftover, this does not fix the player popping back in. (JMH 3/24/2011)
local screen_h = vint_object_find("screen_grp", 0, Cmp_common_doc)
local stars_h = vint_object_find("stars", 0, Cmp_common_doc)
vint_set_property(screen_h, "visible", false)
vint_set_property(stars_h, "visible", false)
Cmp_screen_is_playing = false
cmp_common_screen_advance(false)
end
function cmp_common_rewards_out()
end
--------------------------------------------------------------------------------------------
-- Tiers Screen
--------------------------------------------------------------------------------------------
function cmp_common_tiers_slam()
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
--Cmp_screen_score_end = screen_data.current_score
Cmp_common_score_complete_cb = cmp_common_tiers_end
local tiers_anim_h = vint_object_find("tiers_in_anim", 0, Cmp_common_doc)
local score_type = CMP_SCORE_TYPE_CASH
--Create table for tier elements
for idx, tier in pairs(screen_data.tier_data) do
local twn_h = vint_object_find("tier_meter_twn_".. idx, tiers_anim_h, Cmp_common_doc)
local grp_h = vint_object_find("tier_grp_".. idx, 0, Cmp_common_doc)
local medal_img_h = vint_object_find("medal_img_".. idx, grp_h, Cmp_common_doc)
local title_h = vint_object_find("tier_title_txt_".. idx, grp_h, Cmp_common_doc)
local value_h = vint_object_find("tier_value_txt_".. idx, grp_h, Cmp_common_doc)
local anim_h = vint_object_find("tier_reached_anim_".. idx, 0, Cmp_common_doc)
local goal = tier.tier_goal
local fill_pct = tier.percent
-- Determine if we are time or cash
if tier.score_type == CMP_SCORE_TYPE_TIME then
if goal ~= 0 then
--format_time(time_in_seconds, show_ms, show_units)
vint_set_property(value_h, "text_tag", format_time(goal, false, false, nil, true))
else
vint_set_property(value_h, "text_tag", "ACTIVITY_COMPLETED")
end
score_type = CMP_SCORE_TYPE_TIME
elseif tier.score_type == CMP_SCORE_TYPE_NAKED then
vint_set_property(value_h, "text_tag", format_cash(goal).."")
elseif tier.score_type == CMP_SCORE_TYPE_FRAUD then
vint_set_property(value_h, "text_tag", format_cash(goal).."")
score_type = CMP_SCORE_TYPE_FRAUD
else
vint_set_property(value_h, "text_tag", "{GAME_CASH}" .. format_cash(goal))
end
--Set meter value
vint_set_property(twn_h, "end_value", fill_pct, 1)
--If medal was reached then show medal image
vint_set_property(medal_img_h, "visible", false)
if fill_pct >= 1 then
vint_set_property(medal_img_h, "visible", true)
end
--Set end event
--JM: disabling tier reached anims for now
--vint_set_property(twn_h, "end_event", "cmp_common_tier_reached_cb")
--Save off handles
Tier_data[idx] = {
twn_h = twn_h,
grp_h = grp_h,
title_h = title_h,
value_h = value_h,
anim_h = anim_h,
goal = goal,
percent = tier.percent
}
end
-- Determine which title to set: "SCORE" or "TIME REMAINING"
local score_label_txt_h = vint_object_find("score_label_txt", 0, Cmp_common_doc)
if score_type == CMP_SCORE_TYPE_TIME then
vint_set_property(score_label_txt_h, "text_tag", "COMPLETION_ACTIVITY_TIME_REMAINING")
elseif score_type == CMP_SCORE_TYPE_FRAUD then
vint_set_property(score_label_txt_h, "text_tag", "ACT_FRAUD_SCORE_UNIT")
else
vint_set_property(score_label_txt_h, "text_tag", "COMPLETION_ACTIVITY_SCORE")
end
end
--Callback for each tier twn. Kicks off a separate anim when a tier is completed
function cmp_common_tier_reached_cb(tween_handle)
for idx, tier in pairs(Tier_data) do
local anim_h = tier.anim_h
local twn_h = tier.twn_h
if twn_h == tween_handle and tier.percent == 1 then
lua_play_anim(anim_h, 0)
end
end
end
function cmp_common_tiers_start()
--Block input briefly
cmp_common_input_block_delay()
--We're playing an animation
Cmp_screen_is_playing = true
local tiers_in_anim_h = vint_object_find("tiers_in_anim", 0, Cmp_common_doc)
--Shake the camera and glitch the screen
local end_event_twn_h = vint_object_find("end_event_twn", tiers_in_anim_h)
vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large")
--Glitch the screen a small amount
local glitch_twn_h = vint_object_find("glitch_twn", tiers_in_anim_h)
vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")
--Show the hint bar, set Cmp_screen_is_playing to false
local twn_h = vint_object_find("tiers_end_twn", tiers_in_anim_h)
vint_set_property(twn_h, "end_event", "cmp_common_tiers_end")
lua_play_anim(tiers_in_anim_h, 0, Cmp_common_doc)
--Start counting the score...
local score_count_thread = thread_new("cmp_common_score_count_thread")
--Awarding new medal script---------------------------------------------------------------
--if tier_is_new == true then
--local end_event_twn = vint_object_find("tiers_big_twn", 0, Cmp_common_doc)
--vint_set_property(end_event_twn, "end_event", "cmp_common_tiers_play_progress")
--lua_play_anim(tiers_big_anim_h, 0, Cmp_common_doc)
--end
--lua_play_anim(tiers_progress_anim_h, 0, Cmp_common_doc)
--end
------------------------------------------------------------------------------------------
end
function cmp_common_tiers_skip()
--Clear callbacks
local tiers_in_anim_h = vint_object_find("tiers_in_anim", 0, Cmp_common_doc)
--Shake the camera and glitch the screen
local end_event_twn_h = vint_object_find("end_event_twn", tiers_in_anim_h)
vint_set_property(end_event_twn_h, "end_event", nil)
--Glitch the screen a small amount
local glitch_twn_h = vint_object_find("glitch_twn", tiers_in_anim_h)
vint_set_property(glitch_twn_h, "end_event", nil)
--Move animation to end...
lua_play_anim(tiers_in_anim_h, -2.5, Cmp_common_doc)
cmp_common_glitch_large()
end
function cmp_common_tiers_end()
--Show hints...
cmp_common_hint_bar_show()
--We're done playing
Cmp_screen_is_playing = false
end
function cmp_common_tiers_out()
--Fade out tiers
local tiers_out_anim_h = vint_object_find("tiers_out_anim", 0, Cmp_common_doc)
lua_play_anim(tiers_out_anim_h, 0, Cmp_common_doc)
Cmp_common_shake_is_playing = false
--Hide hint button
cmp_common_hint_bar_hide()
end
function cmp_common_tiers_play_progress(tween_h)
local tiers_progress_anim_h = vint_object_find("tiers_progress_anim", 0, Cmp_common_doc)
lua_play_anim(tiers_progress_anim_h, 0, Cmp_common_doc)
end
-- Easy way to initialize or clear out the control callbacks.
function cmp_common_tiers_cb_enable(is_enabled)
local tiers_slam_cb = "cmp_common_tiers_slam"
if is_enabled == false then
tiers_slam_cb = nil
end
--Tiers Tween callbacks...
local twn_h = vint_object_find("tiers_slam_twn", 0, Cmp_common_doc)
vint_set_property(twn_h, "end_event", tiers_slam_cb)
end
function cmp_common_score_count_thread()
--Get score
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
Cmp_screen_score_end = screen_data.current_score
local score_type = screen_data.tier_data[1].score_type
local score_h = vint_object_find("score_txt", 0, Cmp_common_doc)
--init stuff
local start_score = Cmp_screen_score_start -- score amount to start score from...
local score_this_frame = -1 -- How much score gets displayed in the current frame...
local is_complete = false -- Is the screen complete?
Cmp_screen_score_skip = false -- Did we skip the score?
--get the variables from the global
local score = Cmp_screen_score_end - start_score
local score_end = Cmp_screen_score_end
local amt_min = 100
local amt_max = 33000
local time_min = CMP_TIME_SCORE
local time_max = CMP_TIME_SCORE
local init_time = floor(vint_get_time_index() * 1000)
local cur_time = init_time
local time_to_count = floor(time_min + ((time_max - time_min) * (score / amt_max)))
if time_to_count > time_max then
time_to_count = time_max
end
if score > 0 then
while is_complete == false do
local cur_time = floor(vint_get_time_index() * 1000) - init_time
--set my values
score_this_frame = floor( score * (cur_time / time_to_count) + start_score )
-- Determine what score type we are CASH, PERCENT or TIME
if score_type == CMP_SCORE_TYPE_TIME then
vint_set_property(score_h, "text_tag", format_time(score_this_frame, false, false, nil, true))
elseif score_type == CMP_SCORE_TYPE_NAKED then
vint_set_property(score_h, "text_tag", format_cash(score_this_frame).."")
elseif score_type == CMP_SCORE_TYPE_CASH then
vint_set_property(score_h, "text_tag", "{GAME_CASH}"..format_cash(score_this_frame).."\n")
elseif score_type == CMP_SCORE_TYPE_FRAUD then
vint_set_property(score_h, "text_tag", format_cash(score_this_frame).."")
else
vint_set_property(score_h, "text_tag", format_cash(score_this_frame).."\n")
end
--Advance time so we skip...
if Cmp_screen_score_skip == true then
cur_time = time_to_count
cash_end = Cmp_screen_score_total
--Cmp_common_score_complete_cb = cmp_common_tiers_end
end
if cur_time >= time_to_count then
is_complete = true
-- Determine what score type we are CASH, PERCENT or TIME
if score_type == CMP_SCORE_TYPE_TIME then
vint_set_property(score_h, "text_tag", format_time(score_end, false, false, nil, true))
elseif score_type == CMP_SCORE_TYPE_NAKED then
vint_set_property(score_h, "text_tag", format_cash(score_end).."")
elseif score_type == CMP_SCORE_TYPE_CASH then
vint_set_property(score_h, "text_tag", "{GAME_CASH}"..format_cash(score_end).."\n")
elseif score_type == CMP_SCORE_TYPE_FRAUD then
vint_set_property(score_h, "text_tag", format_cash(score_end).."")
else
vint_set_property(score_h, "text_tag", format_cash(score_end).."\n")
end
--Cmp_common_score_complete_cb()
end
thread_yield()
end
else
-- Start next screen?
cmp_common_tiers_skip()
end
end
----------------------------------------------------------------
-- Unlock screen
----------------------------------------------------------------
----------------------------------------------------------------
-- Coop Wait screen
----------------------------------------------------------------
--Fades in an start coop wait screen...
function cmp_common_coop_wait_start()
Completion_user_is_done_viewing() -- Notify other player that we're ready to move on
if Completion_should_wait_for_coop() then
--Play Fade In anim...
local coop_anim_h = vint_object_find("coop_in_anim", 0, Cmp_common_doc)
lua_play_anim(coop_anim_h, 0, Cmp_common_doc)
--Play Pulse Anim...
local coop_anim_h = vint_object_find("coop_waiting_pulse_anim", 0, Cmp_common_doc)
lua_play_anim(coop_anim_h, 0, Cmp_common_doc)
--Set Coop Player Gamer tag
Cmp_screen_coop_gamer_tag = Completion_get_other_player_name()
local values = {[0] = Cmp_screen_coop_gamer_tag}
local waiting_string = vint_insert_values_in_string("COMPLETION_COOP_WAITING", values)
local waiting_txt_h = vint_object_find("coop_waiting_txt", 0, Cmp_common_doc)
vint_set_property(waiting_txt_h,"text_tag", waiting_string)
Cmp_screen_is_playing = true
Cmp_screen_coop_is_waiting = true
else
-- Do nothing... the game will call cmp_common_exit when we want to leave...
end
end
function cmp_common_coop_wait_skip()
--Does nothing...
end
--Fade out coop wait screen...
function cmp_common_coop_wait_out()
--only fade out if we had the coop screen up...
if Cmp_screen_coop_is_waiting then
local coop_anim_h = vint_object_find("coop_in_anim", 0, Cmp_common_doc)
vint_set_property(coop_anim_h, "is_paused", true)
local coop_anim_h = vint_object_find("coop_out_anim", 0, Cmp_common_doc)
lua_play_anim(coop_anim_h, 0, Cmp_common_doc)
end
end
function cmp_common_coop_wait_dialog()
local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" }
Cmp_common_coop_dialog_handle = dialog_box_open("MENU_TITLE_WARNING", "DIALOG_PAUSE_DISCONNECT_PROMPT", options, "cmp_common_coop_disconnect", 1, DIALOG_PRIORITY_SYSTEM_CRITICAL, true, nil, false, false)
end
function cmp_common_coop_disconnect(result, action)
if result == 0 then
dialog_box_disconnect()
--WHAT SHOULD I DO HERE?
cmp_common_exit()
end
Cmp_common_coop_dialog_handle = 0
end
----------------------------------------------------------------
-- Tables for packing screen based functions and constants
----------------------------------------------------------------
Cmp_screens = {
[CMP_SCREEN_TITLE_INDEX] = {
start_func = cmp_common_title_start,
skip_func = cmp_common_title_skip,
out_func = cmp_common_title_out,
hint_bar_y = CMP_HINT_Y, --1, --set via cmp_common_title_start()...
},
[CMP_SCREEN_TIERS_INDEX] = {
start_func = cmp_common_tiers_start,
skip_func = cmp_common_tiers_skip,
out_func = cmp_common_tiers_out,
hint_bar_y = CMP_TIERS_HINT_Y,
},
[CMP_SCREEN_CASH_INDEX] = {
start_func = cmp_common_cash_start,
skip_func = cmp_common_cash_skip,
out_func = cmp_common_cash_out,
hint_bar_y = CMP_HINT_Y,
},
[CMP_SCREEN_RESPECT_INDEX] = {
start_func = cmp_common_respect_start,
skip_func = cmp_common_respect_skip,
out_func = cmp_common_respect_out,
hint_bar_y = CMP_HINT_Y,
},
[CMP_SCREEN_CONTROL_INDEX] = {
start_func = cmp_common_control_start,
skip_func = cmp_common_control_skip,
out_func = cmp_common_control_out,
hint_bar_y = CMP_HINT_Y,
},
[CMP_SCREEN_REWARD_INDEX] = {
start_func = cmp_common_rewards_start,
skip_func = cmp_common_rewards_skip,
out_func = cmp_common_rewards_out,
hint_bar_y = nil,
},
[CMP_SCREEN_COOP_WAIT_INDEX] = {
start_func = cmp_common_coop_wait_start,
skip_func = cmp_common_coop_wait_skip,
out_func = cmp_common_coop_wait_out,
hint_bar_y = nil,
},
}
----------------------------------------------------------------
-- Common Screen functions
----------------------------------------------------------------
-- Hint bar
function cmp_common_hint_bar_move(x,y)
Cmp_hintbar:set_anchor(x,y)
end
function cmp_common_hint_bar_show(new_y)
--Move hintbar
--Get values from the hintbar and screen type table...
local x, y = Cmp_hintbar:get_anchor()
y = Cmp_screens[Cmp_screen_idx].hint_bar_y
-- Override y value if new value is sent in
if new_y ~= nil then
y = new_y
end
Cmp_hintbar:set_anchor(x,y)
local anim_h = vint_object_find("hint_bar_out_anim", 0, Cmp_common_doc)
vint_set_property(anim_h, "is_paused", true)
local anim_h = vint_object_find("hint_bar_in_anim", 0, Cmp_common_doc)
lua_play_anim(anim_h, 0, Cmp_common_doc)
end
function cmp_common_hint_bar_hide()
local anim_h = vint_object_find("hint_bar_in_anim", 0, Cmp_common_doc)
vint_set_property(anim_h, "is_paused", true)
local anim_h = vint_object_find("hint_bar_out_anim", 0, Cmp_common_doc)
lua_play_anim(anim_h, 0, Cmp_common_doc)
end
--Plays the star power animation...
local Cmp_screen_star_power_screen = -1
function cmp_common_star_power_start()
--Only play the star power if we aren't playing already...
if Cmp_screen_star_power_screen ~= Cmp_screen_idx then
--Check if we aren't already playing for the screen
local anim_h = vint_object_find("star_explode_anim", 0, Cmp_common_doc)
lua_play_anim(anim_h, 0, Cmp_common_doc)
game_set_refraction_situation("screen_cmp")
--[[
for i = 1, #Cmp_stars do
local h = vint_object_find(Cmp_stars[i], 0, Cmp_common_doc)
local scale = rand_float(0.7, 1.1)
local rotation = rand_float(0.1,0.3)
local rotation_og = vint_get_property(h, "rotation")
vint_set_property(h, "scale", scale, scale)
vint_set_property(h, "rotation", rotation_og)
end
]]
Cmp_screen_star_power_screen = Cmp_screen_idx
end
end
--Exit screen
function cmp_common_exit()
--Tell game that we are done with the completion screen...
completion_screen_finished()
end
----------------------------------------------------------------
-- Input Processing
----------------------------------------------------------------
function cmp_process_input(event, acceleration)
--only allow input if input isn't blocked...
if Cmp_common_input_is_blocked == false then
--Only process input if the screen has started...
if Cmp_screen_sequence_started then
--Last minute hack!! if somehow inputs are not set in reward granted, we will pass input from this screen to the reward granted screen.
--looks like occassionaly reward_granted does not claim input, and we don't know why. (Jeff/Sean)
local screen_data = Cmp_sequence_data[Cmp_screen_idx]
if screen_data ~= nil then
--Call Skip function for that particular screen type...
local screen_type = screen_data.type
if screen_type == CMP_SCREEN_REWARD_INDEX then
reward_granted_button_press()
return
end
end
if event == "select" then
cmp_common_screen_advance(false)
elseif event == "map" then
--If we are waiting on the coop screen the bring up the dialog box...
if Cmp_screen_coop_is_waiting then
cmp_common_coop_wait_dialog()
end
elseif event == "back" then
--Do nothing...
--cmp_common_screen_advance()
else
--Do nothing...
end
end
end
end
----------------------------------------------------------------
-- Camera Shake...
--
-- @di_param x Horizontal offset
-- @di_param y Vertical offset
----------------------------------------------------------------
function cmp_common_camera_shake_update(di_h)
local x, y = vint_dataitem_get(di_h)
local screen_h = vint_object_find("screen_grp", 0, Cmp_common_doc)
--Invert parameters and multiply by 2, then add to base position...
x = Cmp_screen_base_x + (x * -1)
y = Cmp_screen_base_y + (y * -1)
vint_set_property(screen_h, "anchor", x, y)
end
----------------------------------------------------------------
-- Wrappers for C Based functions...
----------------------------------------------------------------
--Wrapper for c++ camera shake function...
function cmp_common_camera_shake(shake_type)
completion_camera_shake()
vint_set_glitch_preset( "falling_skies" )
vint_set_glitch_percent( 1.0 )
vint_spike_glitch( 500, 0 )
end
--Wrapper for c++ lut swap function...
function cmp_common_lut_effect(lut_table_string)
if lut_table_string ~= CMP_LUT_DEFAULT then
local platform = game_get_platform()
local lut_platform_string = ""
if platform == "PS3" then
lut_platform_string = "_ps3"
elseif platform == "XBOX360" then
lut_platform_string = "_xbox2"
elseif platform == "XBOX3" then
lut_platform_string = "_xbox3"
elseif platform == "PS4" then
lut_platform_string = "_ps4"
elseif platform == "PC" then
lut_platform_string = "_pc"
end
completion_load_lut(lut_table_string .. lut_platform_string)
else
completion_load_lut(lut_table_string)
end
end
function cmp_common_bitmap_loaded()
end
-------------------------------------------------------------------
-- AUDIO
-------------------------------------------------------------------
--Callbacks for audio placed directly on tweens...
function cmp_audio_cb_enable()
--Title intro... ("title_in_anim")
local twn_h = vint_object_find("audio_twn_title_intro", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_title_intro_cb")
--Title skip... ("title_in_anim")
local twn_h = vint_object_find("audio_twn_title_skip", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_title_skip_cb")
--Title music... ("title_in_anim")
local twn_h = vint_object_find("audio_twn_title_music", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_music_cb")
--Tiers intro...("tiers_in_anim")
local twn_h = vint_object_find("audio_twn_tiers_intro", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_tiers_intro_cb")
--Tiers skip...("cash_anim_in")
local twn_h = vint_object_find("audio_twn_tiers_skip", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_tiers_skip_cb")
--Cash intro...("cash_anim_in")
local twn_h = vint_object_find("audio_twn_cash_intro", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_cash_intro_cb")
--Cash skip...("cash_anim_in")
local twn_h = vint_object_find("audio_twn_cash_skip", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_cash_skip_cb")
--Cash Bonus...("cash_bonus_anim_in")
local twn_h = vint_object_find("audio_twn_cash_bonus", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_cash_bonus_cb")
--Respect intro...("respect_in_anim")
local twn_h = vint_object_find("audio_twn_respect_intro", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_respect_intro_cb")
--Respect skip...("respect_in_anim")
local twn_h = vint_object_find("audio_twn_respect_skip", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_respect_skip_cb")
--Respect Bonus...("respect_bonus_in_anim")
local twn_h = vint_object_find("audio_twn_respect_bonus", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_respect_bonus_cb")
--Control intro...("control_in_anim")
local twn_h = vint_object_find("audio_twn_control_intro", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_control_intro_cb")
--Control skip...("control_in_anim")
local twn_h = vint_object_find("audio_twn_control_skip", 0, Cmp_common_doc)
vint_set_property(twn_h, "start_event", "cmp_audio_control_skip_cb")
end
--Audio callbacks...
function cmp_audio_title_intro_cb()
if Cmp_audio_title_done == false then
ui_audio_post_event("UI_Mission_Complete_Banner")
end
Cmp_audio_title_done = true
end
function cmp_audio_title_skip_cb()
if Cmp_audio_title_skip_done == false then
ui_audio_post_event("UI_Mission_Complete_Slam")
end
Cmp_audio_title_skip_done = true
end
function cmp_audio_music_cb()
--Ensure that music only plays once
if Cmp_common_audio_music_id == -1 then
Cmp_common_audio_music_id = game_audio_play("UI_Music", "UI_Music", "Mission_Completion")
end
end
function cmp_audio_tiers_intro_cb()
if Cmp_audio_tiers_done == false then
ui_audio_post_event("UI_Activity_Medal_Banner")
end
Cmp_audio_tiers_done = true
end
function cmp_audio_tiers_skip_cb()
if Cmp_audio_tiers_skip_done == false then
ui_audio_post_event("UI_Activity_Medal_Slam")
end
Cmp_audio_tiers_skip_done = true
end
function cmp_audio_cash_intro_cb()
if Cmp_audio_cash_done == false then
ui_audio_post_event("UI_Cache_Ramp")
end
Cmp_audio_cash_done = true
end
function cmp_audio_cash_skip_cb()
if Cmp_audio_cash_skip_done == false then
ui_audio_post_event("UI_Cache_Slam")
end
Cmp_audio_cash_skip_done = true
end
function cmp_audio_cash_bonus_cb()
ui_audio_post_event("UI_Cache_Bonus_Ramp")
end
function cmp_audio_respect_intro_cb()
if Cmp_audio_respect_done == false then
ui_audio_post_event("UI_XP_Ramp")
end
Cmp_audio_respect_done = true
end
function cmp_audio_respect_skip_cb()
if Cmp_audio_respect_skip_done == false then
ui_audio_post_event("UI_XP_Slam")
end
Cmp_audio_respect_skip_done = true
end
function cmp_audio_respect_bonus_cb()
ui_audio_post_event("UI_XP_Bonus_Ramp")
end
function cmp_audio_control_intro_cb()
if Cmp_audio_control_done == false then
ui_audio_post_event("UI_District_Ramp")
end
Cmp_audio_control_done = true
end
function cmp_audio_control_skip_cb()
if Cmp_audio_control_skip_done == false then
ui_audio_post_event("UI_Cache_Slam") --CHANGE THIS
end
Cmp_audio_control_skip_done = true
end
--Ramps...
function cmp_audio_cash_ramp_no_multiplier()
--CashRamLong 2sec 09 frames...
Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp")
end
function cmp_audio_cash_ramp_multiplier()
--short Cash Ramp
Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp_Base")
end
function cmp_audio_cash_bonus_ramp()
--Bonus Ramp...
Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp_Bonus")
end
function cmp_audio_respect_ramp_no_multiplier()
--respect ramp full 3
Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp")
end
function cmp_audio_respect_ramp_multiplier()
--respect ramp base 1sec 22...
Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Base")
end
function cmp_audio_respect_bonus_ramp()
--respect ramp Bonus 1sec 14...
Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Bonus")
end
function cmp_audio_control_ramp()
--respect ramp Bonus 1sec 14...
Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Bonus")
end
function cmp_audio_stop_ramp()
game_audio_stop(Cmp_common_audio_ramp_id)
end
function cmp_common_mouse_click(event, target_handle)
if target_handle == Cmp_bg_image.handle then
if Cmp_screen_coop_is_waiting == true then
cmp_process_input("back")
else
cmp_process_input("select")
end
end
end
function cmp_common_mouse_move(event, target_handle)
end
-------------------------------------------------------------------------------
-- Sets up the screen for right justification
-------------------------------------------------------------------------------
function cmp_common_right_justification()
--Adjust base screen coords
Cmp_screen_base_x = 25
Cmp_screen_base_y = -100
--If standard definition we need to adjust some more even...
if vint_is_std_res() then
Cmp_screen_base_x = -50
Cmp_screen_base_y = -75
end
local global_conversion_table = {
--Screen Group Rotation...
{
name = "screen_grp",
prop = "rotation",
val_1 = 0.13962634, -- 8 degrees.
},
--Shift screen around...
{
name = "screen_grp",
prop = "anchor",
val_1 = Cmp_screen_base_x,
val_2 = Cmp_screen_base_y,
}
}
local title_converstion_table = {
--Title Alignments
{
name = "complete_txt",
prop = "auto_offset",
val_1 = "ne",
},
{
name = "title_txt",
prop = "auto_offset",
val_1 = "ne",
},
{
name = "title_txt",
prop = "horz_align",
val_1 = "right",
},
--Title Tweens
{
name = "title_in_twn",
prop = "start_value_x",
val_1 = -20,
},
{
name = "complete_txt_slide_twn",
prop = "start_value_x",
val_1 = -20,
},
--End position overrides...
{
name = "title_in_twn",
prop = "end_value_x",
val_1 = 647.0,
},
}
local cash_conversion_table = {
--Cash Alignments
{
name = "cash_txt",
prop = "auto_offset",
val_1 = "ne",
},
{
name = "cash_bonus_txt",
prop = "auto_offset",
val_1 = "ne",
},
{
name = "cash_amount_txt",
prop = "auto_offset",
val_1 = "ne",
},
--Cash Tweens
{
name = "cash_amount_slide_twn",
prop = "start_value_x",
val_1 = -20,
},
{
name = "cash_slam_twn",
prop = "start_value_x",
val_1 = -20,
},
{
name = "cash_bonus_slam_twn",
prop = "start_value_x",
val_1 = -20,
},
--End position overrides
{
name = "cash_amount_slide_twn",
prop = "end_value_x",
val_1 = 646,
},
{
name = "cash_slam_twn",
prop = "end_value_x",
val_1 = 646,
},
}
local respect_conversion_table = {
--Respect Alignments
{
name = "respect_bonus_txt",
prop = "auto_offset",
val_1 = "ne",
},
{
name = "respect_txt",
prop = "auto_offset",
val_1 = "ne",
},
--Respect Tweens Start
{
name = "respect_slam_twn",
prop = "start_value_x",
val_1 = -20,
},
{
name = "respect_txt_twn",
prop = "start_value_x",
val_1 = -20,
},
{
name = "respect_bonus_twn",
prop = "start_value_x",
val_1 = -20,
},
--Respect Tweens End
{
name = "respect_slam_twn",
prop = "end_value_x",
val_1 = 600,
},
{
name = "respect_txt_twn",
prop = "end_value_x",
val_1 = 470,
},
{
name = "respect_bonus_twn",
prop = "end_value_x",
val_1 = 472,
},
}
local control_conversion_table = {
--Control Alignments
{
name = "control_cash_txt",
prop = "auto_offset",
val_1 = "ne",
},
{
name = "control_txt",
prop = "horz_align",
val_1 = "right",
},
{
name = "control_txt",
prop = "auto_offset",
val_1 = "ne",
},
--Control Tweens Start
{
name = "control_slam_twn",
prop = "start_value_x",
val_1 = -20,
},
{
name = "control_txt_twn",
prop = "start_value_x",
val_1 = -20,
},
{
name = "control_cash_twn",
prop = "start_value_x",
val_1 = -20,
},
--Control Tweens End
{
name = "control_slam_twn",
prop = "end_value_x",
val_1 = 600,
},
{
name = "control_txt_twn",
prop = "end_value_x",
val_1 = 470,
},
{
name = "control_cash_twn",
prop = "end_value_x",
val_1 = 472,
},
}
local conversion_tables = {
global_conversion_table,
title_converstion_table,
cash_conversion_table,
respect_conversion_table,
control_conversion_table,
}
local h
local value_1, value_2
--Loop through all the conversion tables
for i, conversion_table in pairs(conversion_tables) do
--Get specific conversion table
for idx, val in pairs(conversion_table) do
--Go through each item and start converting properties...
h = vint_object_find(val.name, 0, Cmp_common_doc)
local prop = val.prop
if h ~= 0 then
--Check for "special properties" so we can maintain variables on certain vectors.
if prop == "start_value_x" then
local x, y = vint_get_property(h, "start_value")
vint_set_property(h, "start_value", val.val_1, y)
elseif prop == "end_value_x" then
local x, y = vint_get_property(h, "end_value")
vint_set_property(h, "end_value", val.val_1, y)
elseif prop == "anchor" then
vint_set_property(h, "anchor", val.val_1, val.val_2)
else
vint_set_property(h, val.prop, val.val_1)
end
else
--can't find object...
debug_print("vint", "Item in conversion table is missing\n")
end
end
end
--Shift button hint over...
local x, y = Cmp_hintbar:get_anchor()
local width, height = Cmp_hintbar:get_size()
Cmp_hintbar:set_anchor(x - width - 15, y)
end
-------------------------------------------------------------------------------
-- Callback for when we have our completion image fully loaded...
--
function cmp_common_image_loaded()
--image is loaded...
local h = vint_object_find("background_base")
vint_set_property(h, "visible", true)
local img_bg_grp_h = vint_object_find("img_bg_grp", 0, Cmp_common_doc)
vint_set_property(img_bg_grp_h, "visible", true)
local img_grp_h = vint_object_find("img_grp", 0, Cmp_common_doc)
vint_set_property(img_grp_h, "visible", true)
--replace all 3 images for rgb shift...
local screen_image_r = vint_object_find("screen_image_r", 0, Cmp_common_doc)
local screen_image_g = vint_object_find("screen_image_g", 0, Cmp_common_doc)
local screen_image_b = vint_object_find("screen_image_b", 0, Cmp_common_doc)
local screen_image_black = vint_object_find("screen_image_black", 0, Cmp_common_doc)
vint_set_property(screen_image_r, "image", Cmp_image)
vint_set_property(screen_image_g, "image", Cmp_image)
vint_set_property(screen_image_b, "image", Cmp_image)
vint_set_property(screen_image_black, "image", Cmp_image)
--make sure they don't pop in before the intro anim
vint_set_property(screen_image_r, "scale", 0, 0)
vint_set_property(screen_image_g, "scale", 0, 0)
vint_set_property(screen_image_b, "scale", 0, 0)
vint_set_property(screen_image_black, "alpha", 0)
Cmp_common_has_image = true
end
function cmp_common_pointless_callback()
end
function cmp_common_image_fade_out()
if Cmp_common_has_image and Cmp_common_image_is_visible then
local image_fade_out_anim_h = vint_object_find("image_fade_out_anim", 0, Cmp_common_doc)
lua_play_anim(image_fade_out_anim_h, 0, Cmp_common_doc)
Cmp_common_image_is_visible = false
end
end
function cmp_common_input_block_delay()
Cmp_common_input_is_blocked = true
if Cmp_common_input_delay_thread ~= -1 then
thread_kill(Cmp_common_input_delay_thread)
end
if Cmp_common_input_delay_thread == -1 then
Cmp_common_input_delay_thread = thread_new("cmp_common_input_block_thread")
end
end
function cmp_common_input_block_thread()
delay(.75)
Cmp_common_input_is_blocked = false
Cmp_common_input_delay_thread = -1
end
--Debug stuff put in for jon bruer JMH(3/24/2011)
function cmp_bg_hide()
local h = vint_object_find("background_base")
vint_set_property(h, "visible", false)
end
function cmp_common_do_nothing()
local x = 0
end