-- -- Autor: BenjamÌn de la Fuente Ranea -- Fecha: 28-11-2008 -- -- Script de carga inicial -- g_FirstRacePress = false -- Creación del menú principal function coverFadeOut() SetActorAnim('Cover', {anim = 'menu/cover_fadeout.anm', loop = false}) EnqueueExecuteScript("Cover", "DestroyActor('Cover')") end function enqueueSecondCoverAnim() SetActorAnim("Cover", { anim = "menu/cover.anm" }) EnqueueExecuteScript("Cover", "loadGameAndStart()") end function setIngameMusic() Sound.SetMusicVolume(LoadPreference("MusicSlider", 1000) * 0.35 / 1000) --[[if CupSelected == 1 then Sound.PlayMusic(g_cupMusic1) elseif CupSelected == 2 then Sound.PlayMusic(g_cupMusic2) else Sound.PlayMusic(g_cupMusic3) end--]] end function loadGameAndStart() -- hay que lanzar --IsBada = true if ShowSoundOptions and not g_SoundOptionsShowed then launchMsg('Enable Sound?','No', 'Yes', [[ Sound.SetMasterVolume(0) loadGameAndStart() ]], [[ loadGameAndStart() ]] ) g_SoundOptionsShowed = true return end -- Comprueba si ya se ha desbloqueado algo, en cuyo caso no hay q mostrar el tutorial if false and LoadPreference("TutorialFinished", 0) == 0 and not HasPlayedBefore() then coverFadeOut() execute("menu/tutorialBegin.lua") else SavePreference("TutorialFinished", 1) if IsThereSavedGame() then launchMsg('Load Saved Game?','No', 'Yes', [[ RemoveSavedGame() coverFadeOut() execute("menu/mainStart.lua") ]], [[ if not LoadSavedGame() then coverFadeOut() execute("menu/mainStart.lua") else setIngameMusic() DestroyActor('Cover') end ]] ) else coverFadeOut() execute("menu/mainStart.lua") end end end function initMenu() --[[ if g_currentState == nil then g_currentState = TRootState:new() log("!!!!!!!!g_currentState ~= nil") g_currentState:begin() else log("!!!!!!!!!!!!!!!!!!VUELTA AL ESTADO DE MENU!!!") log("estado actual: " .. g_currentState.m_name) log("estado actual tiene siguiente: " .. g_currentState.m_nextState.m_name) g_currentState:changeCurrentState() end --]] local prueba = 0 if(prueba == 1) then CupSelected = 3 TrackSelected = 1 g_TextOverlap = -18 execute("menu/garageRace_execute.lua") CreateActor("ActorGeom", {name = "CenteredText", model = "HUD/centeredtext.mesh", camera = HUD}) SetActorAnim("CenteredText", { anim = "HUD/race_finished.anm", loop = false, }) EnqueueExecuteScript("CenteredText", 'execute("menu/tournamentResults.lua")') return end if (prueba == 2) then --prueba del menu de fin de carrera de tournament... (pantalla siguiente a la carrera...) CupSelected = 1 TrackSelected = 1 g_TextOverlap = -18 execute("menu/tournamentFinalResults.lua") initMenu() return end if( prueba == 3 ) then ScreenType = 1 UserLevel = 2 CupSelected = 2 TrackSelected = 1 g_TextOverlap = -18 execute("menu/prize_and_unlocks.lua") return end if prueba == 4 then ScreenType = 2 CupSelected = 1 TrackSelected = 1 g_TextOverlap = -18 CreateActorGeom("Background", "garage/garage2D.mesh", "default") SetActorAnim("Background", { anim = "garage/cup" .. CupSelected .. "_fade_in.anm", loop = false, }) execute("menu/garageBegin.lua") return end if( prueba == 5) then g_TextOverlap = -18 execute("menu/interruption.lua") return end if( prueba == 6) then g_TextOverlap = -18 execute("menu/message.lua") return end if( prueba == 7) then CupSelected = 1 TrackSelected = 6 SelectedCar = 1 g_TextOverlap = -18 execute("menu/garageRace.lua") return end if( prueba == 8) then CupSelected = 0 g_TextOverlap = -18 execute("menu/difficultyOk.lua") --setDollAnim(0,1) return end if( prueba == 9) then CupSelected = 0 g_TextOverlap = -18 execute("menu/credits.lua") --setDollAnim(0,1) return end if(prueba == 10) then --prueba del menu de fin de carrera de tournament... (coches llegando) CupSelected = 3 TrackSelected = 1 g_TextOverlap = -18 execute("menu/garageRace_execute.lua") CreateActor("ActorGeom", {name = "CenteredText", model = "HUD/centeredtext.mesh", camera = HUD}) CreateActor("ActorGeom", {name = "Menu", model = "menu/tournament_results.mesh", camera = HUD}) DeactivateActor("Menu") SetActorAnim("CenteredText", { anim = "HUD/race_finished.anm", loop = false, }) EnqueueExecuteScript("CenteredText", 'execute("menu/timeTrialRaceResults.lua");timeTrialRaceResults()') return end if (prueba == 11) then --prueba del menu de fin de carrera de tournament... (pantalla siguiente a la carrera...) CupSelected = 2 TrackSelected = 5 g_TextOverlap = -18 execute("menu/tournamentResults.lua") return end if g_backFromFadeBlack == nil then g_backFromFadeBlack = false -- es la primera vez que ejecutamos esto. --creo la portada y la capa del fade to black sobre ella if(IsBada) then CreateActor("ActorGeom", { name = "Cover2", model = "menu/cover.mesh", layer = LF_PANELS+2, materials = { splash = { g_diffuseTexture = "samsung_splash.png"}, cover = { g_diffuseTexture = "default.png"}, }} ) CreateActor("ActorGeom", { name = "Cover", model = "menu/cover.mesh", layer = LF_PANELS+2, materials = { splash = { g_diffuseTexture = "default.png"}, cover = { g_diffuseTexture = "cover.png"}, }} ) SetActorAnim("Cover2", { anim = "menu/cover_fadein.anm" }) EnqueueExecuteScript("Cover2", [[SetActorAnim("Cover2", {anim = "menu/cover.anm", loop = false});EnqueueExecuteScript("Cover2", "DestroyActor('Cover2');enqueueSecondCoverAnim()")]]) else CreateActor("ActorGeom", { name = "Cover", model = "menu/cover.mesh", layer = LF_PANELS+2} ) --CreateActor("ActorGeom", { name = "Fade", model = "menu/fade_to_black.mesh", layer = LF_PANELS+4} ) --animacion de opaco a transparente, cuando acaba, espero lo que dura la animacion cover.anm a la portada y luego, fade out. --finalmente cargo el juego. --SetActorAnim("Fade", {anim = "menu/fade_black_from_1_to_0.anm", loop = false}) SetActorAnim("Cover", { anim = "menu/cover.anm" }) EnqueueExecuteScript("Cover", "loadGameAndStart()") end else g_backFromFadeBlack = true if(not ExistsActor("Fade")) then CreateActor("ActorGeom", { name = "Fade", model = "menu/fade_to_black.mesh", layer = LF_PANELS+4} ) end loadGameAndStart() end g_backFromFadeBlack = false g_backToGarage = false g_TextOverlap = -18 g_backMenu = false --pongo el flag a true solo cuando voy a empezar una carrera y lo quito cuando paso por la pantalla de buyScreen g_buyScreenNeedToShow = false end -- CreaciÛn de los actores principales function initGame() math.randomseed(getTime()) PreLoadResources() -- Cargamos las opciones loadPreferences() --execute("menu/mainStart.lua") execute("menu/menuScreens.lua") if(currentMenuScreen ~= nil) then currentMenuScreen:postFreeScreenResources() end currentMenuScreen = TMainMenuScreen:new() currentMenuScreen:resetScreen() end function loadPreferences() Sound.SetEffectsVolume(LoadPreference("EffectSlider", 1000) / 1000) Sound.SetMusicVolume(LoadPreference("MusicSlider", 1000) / 1000) end function PreLoadResources() Sound.Enable3DSound(false) g_ShinningButtonSound = Sound.LoadSound("sounds/menu/button07.ogg") -- Tournament, online,tutorial g_ActionButtonSound = Sound.LoadSound("sounds/menu/button01.ogg") -- Next y Back g_SelectionButtonSound = Sound.LoadSound("sounds/menu/SELECCION_1.ogg") -- dificultad y pintura g_ScrollSound = Sound.LoadSound("sounds/menu/SELECCION_1.ogg") -- Selección de scroll --g_ScrollDisableSound = Sound.LoadSound("sounds/FX_Boton.ogg") -- Selección de scroll con elemento bloqueado --g_JungleButtonSound = Sound.LoadSound("sounds/FX_Boton.ogg") -- Premios g_raceButtonSound = Sound.LoadSound("sounds/menu/RACE.ogg") -- Carrera g_SprayButtonSound = Sound.LoadSound("sounds/menu/SPRAY.ogg") -- Pintura g_ActivateCheckpointSound = Sound.LoadSound("sounds/ingame/checkpoint.ogg") -- Activacion de un checkpoint en el tutorial g_menuMusic = Sound.LoadMusic("sounds/music/FUNK_PREVIO.ogg") -- Música de menú --[[ g_cupMusic1 = Sound.LoadMusic("sounds/music/RC_MUSICA_PRU.ogg") -- Música de copa 1 g_cupMusic2 = Sound.LoadMusic("sounds/music/country_pista_arena.ogg") -- Música de copa 2 g_cupMusic3 = Sound.LoadMusic("sounds/music/TECNO_LARGO.ogg") -- Música de copa 3 --]] LoadTexture("fontTRN_bg.pvr") LoadTexture("fontTRN_fg.pvr") end