local guiGoalSizeX = 7.5 local guiGoalSizeY = 7.5 local guiGoalY = 128 local guiGoalXOffset = 17.1 local guiGoalXBase = 201 local guiGoalXSudden = 183 --=============================================================================== function getGuiMenuMessage(index) if (index == 0) then return { scale = 0.25, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, vertical = E_VALIGN_CENTER, text = txtPaused } elseif (index == 1) then return { scale = 0.3, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, vertical = E_VALIGN_CENTER, text = txtResume } elseif (index == 2) then return { scale = 0.3, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, vertical = E_VALIGN_CENTER, text = txtStats } elseif (index == 3) then return { scale = 0.3, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, vertical = E_VALIGN_CENTER, text = txtExit } end end --=============================================================================== function touch_gamepause() -- print("pause touched") PauseState() Sound.PlaySound(MenuSounds.Fx.buttonOk, false) SetActorAnimPenalty("PauseButton", { anim = "gui_pause_touch.anm", loop = false }) EnqueueExecuteScript("PauseButton", "showInGameMenu()") NotifyInGameModalMsgStatus(true) end --=============================================================================== function showInGameMenu() SetActorAnimPenalty("PauseButton", { anim = "gui_pause_out.anm", loop = false }) CreateActor("ActorGeom", {name = "InGameMenu", model = "gui_menu.mesh", camera = "guiCamera", layer = LF_PANELS+1, touchable = true}) RegisterTouchableActor("InGameMenu") SetActorAnimPenalty("InGameMenu", { anim = "gui_menu_intro.anm", loop = false }) end --=============================================================================== function touch_button1() -- print("in game menu button resume") Sound.PlaySound(MenuSounds.Fx.buttonBack, false) SetActorAnimPenalty("InGameMenu", { anim = "gui_menu_but1.anm", loop = false }) UnregisterTouchableActor("InGameMenu") EnqueueExecuteScript("InGameMenu", "ResumeState()") EnqueueExecuteScript("InGameMenu", "destroyInGameMenu(\"showPauseButton()\")") end --=============================================================================== function showPauseButton() SetActorAnimPenalty("PauseButton", { anim = "gui_pause_in.anm", loop = false }) NotifyInGameModalMsgStatus(false) end --=============================================================================== function destroyInGameMenu(functionName) SetActorAnimPenalty("InGameMenu", { anim = "gui_menu_outro.anm", loop = false }) EnqueueExecuteScript("InGameMenu", functionName) EnqueueExecuteScript("InGameMenu", "DestroyActor(\"InGameMenu\")") end --=============================================================================== function touch_button2() -- print("in game menu button stats") Sound.PlaySound(MenuSounds.Fx.buttonOk, false) SetActorAnimPenalty("InGameMenu", { anim = "gui_menu_but2.anm", loop = false }) UnregisterTouchableActor("InGameMenu") EnqueueExecuteScript("InGameMenu", "destroyInGameMenu(\"showInGameStats()\")") end local userStats --=============================================================================== function getStatisticsText(index) if (index == 1) then return { scale = 0.095, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS+1, vertical = E_VALIGN_CENTER, text = txtStatistics } elseif (index == 2) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, vertical = E_VALIGN_CENTER, text = txtPlayerPoints .. ": " .. userStats[1] } elseif (index == 3) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, align = E_ALIGN_RIGHT, vertical = E_VALIGN_CENTER, text = txtTournamentsWon } elseif (index == 4) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, align = E_ALIGN_RIGHT, vertical = E_VALIGN_CENTER, text = txtRoundsWon } elseif (index == 5) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, align = E_ALIGN_RIGHT, vertical = E_VALIGN_CENTER, text = txtGoalsScored } elseif (index == 6) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, align = E_ALIGN_RIGHT, vertical = E_VALIGN_CENTER, text = txtGoalsInRow } elseif (index == 7) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, align = E_ALIGN_RIGHT, vertical = E_VALIGN_CENTER, text = txtSaves } elseif (index == 8) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, align = E_ALIGN_RIGHT, vertical = E_VALIGN_CENTER, text = txtSavesInRow } elseif (index < 15) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, vertical = E_VALIGN_CENTER, text = "" .. userStats[index - 7] } elseif (index < 18) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, vertical = E_VALIGN_CENTER, text = "" .. userStats[index - 7] .. "%%" } elseif (index == 19) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS+1, vertical = E_VALIGN_CENTER, text = "" .. (userStats[index - 8]) .. "%%" } end end --=============================================================================== function showInGameStats() Sound.PlaySound(MenuSounds.Fx.panelIn, false) userStats = GetUserStats() if (LITE_VERSION == true) then CreateActor("ActorGeom", { name = "UserStats", model = "Screen_statistics_lite.mesh", touchable = true, camera = "backgroundCamera", layer = LF_PANELS+1}) SetActorAnimPenalty("UserStats", { anim = "Screen_statistics_in_lite.anm", loop = false }) else CreateActor("ActorGeom", { name = "UserStats", model = "Screen_statistics.mesh", touchable = true, camera = "backgroundCamera", layer = LF_PANELS+1}) SetActorAnimPenalty("UserStats", { anim = "Screen_statistics_in.anm", loop = false }) end RegisterTouchableActor("UserStats") end --=============================================================================== function touch_button3() -- print("in game menu button exit") Sound.PlaySound(MenuSounds.Fx.buttonOk, false) SetActorAnimPenalty("InGameMenu", { anim = "gui_menu_but3.anm", loop = false }) UnregisterTouchableActor("InGameMenu") EnqueueExecuteScript("InGameMenu", "onExitMatchActions()") if (LITE_VERSION == true) then SetAdsChangeTimeInterval(0.0) ShowAdsBanner(false) end end --=============================================================================== function touch_statistics() -- print("in game stats") Sound.PlaySound(MenuSounds.Fx.buttonBack, false) Sound.PlaySound(MenuSounds.Fx.panelOut, false) if (LITE_VERSION == true) then SetActorAnimPenalty("UserStats", { anim = "Screen_statistics_out_lite.anm", loop = false }) else SetActorAnimPenalty("UserStats", { anim = "Screen_statistics_out.anm", loop = false }) end UnregisterTouchableActor("UserStats") EnqueueExecuteScript("UserStats", "showInGameMenu()") EnqueueExecuteScript("UserStats", "DestroyActor(\"UserStats\")") end --=============================================================================== function showGui() SetActorAnimPenalty("TeamsNamesGui", { anim = "gui_teambar_intro.anm", loop = false }) SetActorAnimPenalty("PauseButton", { anim = "gui_pause_in.anm", loop = false }) -- SetActorAnimPenalty("TeamsFlagsGui", { anim = "gui_flags_in.anm", loop = false }) local shotsPositions if (currentMatch.suddenDeath == true) then shotsPositions = 1 else shotsPositions = currentMatch.nbOfShots end SetActorPosition("ScoreAGui", { 110.0, 0.0, 0.0 }) SetActorPosition("ScoreBGui", { -110.0, 0.0, 0.0 }) EnqueueExecuteScript("TeamsNamesGui", "SetTranslateAction(\"ScoreAGui\", 110.0, 0.0, 0.0, 86.5 - " .. shotsPositions .. " * 5.3, 0.0, 0.0, 0.05 * " .. shotsPositions .. ")") EnqueueExecuteScript("TeamsNamesGui", "SetTranslateAction(\"ScoreBGui\", -110.0, 0.0, 0.0, -86.5 + " .. shotsPositions .. " * 5.3, 0.0, 0.0, 0.05 * " .. shotsPositions .. ")") end --=============================================================================== function initGuiPositions() if (IPAD_VERSION == true) then guiGoalSizeX = 15 guiGoalSizeY = 15 guiGoalY = 314 guiGoalXOffset = 36.5 guiGoalXBase = 429 guiGoalXSudden = 392 elseif (ANDROID_VERSION == true) then -- convert coordinates from iPhone ones taking into account the viewport size local width, height = GetViewportSize() local xRatio = width/480 local yRatio = height/320 guiGoalSizeX = 7.5 * xRatio guiGoalSizeY = 7.5 * yRatio guiGoalY = 128 * yRatio guiGoalXOffset = 17.1 * xRatio guiGoalXBase = 201 * xRatio guiGoalXSudden = 183 * xRatio else guiGoalSizeX = 7.5 guiGoalSizeY = 7.5 guiGoalY = 128 guiGoalXOffset = 17.1 guiGoalXBase = 201 guiGoalXSudden = 183 end end --=============================================================================== function restoreGuiGoals() -- print("restoring Gui goals") initGuiPositions() local nameIndex if (currentMatch.suddenDeath == true) then posX = -guiGoalXSudden nameIndex = (currentMatch.currentTurn - 1) * 2 + 1 if (currentMatch.suddenDeathA == 1) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks1.pvr", 255, 255, 255, 255, "") elseif (currentMatch.suddenDeathA == 0) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks2.pvr", 255, 255, 255, 255, "") end SetLayerFlags("GuiGoal" .. nameIndex, LF_PANELS) posX = guiGoalXSudden nameIndex = currentMatch.currentTurn * 2 if (currentMatch.suddenDeathB == 1) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks1.pvr", 255, 255, 255, 255, "") elseif (currentMatch.suddenDeathB == 0) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks2.pvr", 255, 255, 255, 255, "") end SetLayerFlags("GuiGoal" .. nameIndex, LF_PANELS) else for index = 1, 10 do posX = -guiGoalXBase + index * guiGoalXOffset nameIndex = (index - 1) * 2 + 1 -- print("shotsA[" .. index .. "] = " .. currentMatch.shotsA[index]) if (currentMatch.shotsA[index] == 1) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks1.pvr", 255, 255, 255, 255, "") elseif (currentMatch.shotsA[index] == 0) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks2.pvr", 255, 255, 255, 255, "") else break end SetLayerFlags("GuiGoal" .. nameIndex, LF_PANELS) posX = guiGoalXBase - index * guiGoalXOffset nameIndex = index * 2 if (currentMatch.shotsB[index] == 1) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks1.pvr", 255, 255, 255, 255, "") elseif (currentMatch.shotsB[index] == 0) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks2.pvr", 255, 255, 255, 255, "") else break end SetLayerFlags("GuiGoal" .. nameIndex, LF_PANELS) end end end --=============================================================================== function updateGui(goal) -- goal can be 0 or 1 local posX local nameIndex = (currentMatch.currentTurn - 1) * 2 + currentMatch.currentTeam initGuiPositions() isGoal = goal if (currentMatch.currentTeam == 1) then currentMatch.scoreA = currentMatch.scoreA + goal if (currentMatch.suddenDeath == true) then posX = -guiGoalXSudden currentMatch.suddenDeathA = goal else posX = -guiGoalXBase + currentMatch.currentTurn * guiGoalXOffset currentMatch.shotsA[currentMatch.currentTurn] = goal end currentMatch.currentTeam = 2 if (isMatchOver((currentMatch.nbOfShots - currentMatch.currentTurn), (currentMatch.nbOfShots - currentMatch.currentTurn + 1)) == true) then matchOver = true end else currentMatch.scoreB = currentMatch.scoreB + goal if (currentMatch.suddenDeath == true) then posX = guiGoalXSudden currentMatch.suddenDeathB = goal else posX = guiGoalXBase - currentMatch.currentTurn * guiGoalXOffset currentMatch.shotsB[currentMatch.currentTurn] = goal end currentMatch.currentTeam = 1 currentMatch.currentTurn = currentMatch.currentTurn + 1 if (isMatchOver((currentMatch.nbOfShots - currentMatch.currentTurn + 1), (currentMatch.nbOfShots - currentMatch.currentTurn + 1)) == true) then matchOver = true elseif (currentMatch.currentTurn > currentMatch.nbOfShots) then if (currentMatch.scoreA == currentMatch.scoreB) then -- sudden death phase currentMatch.suddenDeath = true currentMatch.suddenDeathA = -1 currentMatch.suddenDeathB = -1 goToSuddenDeath = true else -- match is over matchOver = true end end end if (goal == 1) then CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks1.pvr", 255, 255, 255, 255, "") else CreateActorImage("GuiGoal" .. nameIndex, posX, guiGoalY, guiGoalSizeX, guiGoalSizeY, "gui_marks2.pvr", 255, 255, 255, 255, "") end SetLayerFlags("GuiGoal" .. nameIndex, LF_PANELS) if (matchOver == true) then if (gameModeSelected == GAME_MODE_WORLDCUP) then -- if (hasUserWon() == false) then --TEST -- SaveUserMatchResult(currentMatch.scoreB, currentMatch.scoreA) -- else SaveUserMatchResult(currentMatch.scoreA, currentMatch.scoreB) --KEEP THIS!!! if (isWorldCupFinal() == true) then SimulateCPUMatches() -- this forces to set the cup winner now and award any extra points end -- end continueSimulation = true end updateStats() end end --=============================================================================== function animateGuiToSuddenDeath() local startIndex local translateTime = 0.0 if (currentMatch.currentTurn == currentMatch.nbOfShots + 1) then startIndex = 1 else startIndex = (currentMatch.currentTurn - 1) * 2 - 1 end initGuiPositions() for index = startIndex, (currentMatch.currentTurn - 1) * 2 do if (ExistsActor("GuiGoal" .. index)) then if (index % 2 == 1) then translateTime = translateTime + 0.15 SetTranslateToAction("GuiGoal" .. index, -guiGoalXBase, guiGoalY, 0.5, translateTime) else SetTranslateToAction("GuiGoal" .. index, guiGoalXBase, guiGoalY, 0.5, translateTime) end EnqueueTimeExecuteScript("DestroyActor(\"GuiGoal" .. index .. "\")", translateTime + 0.01) end end DeactivateActor("TeamsNamesGui") ActivateActor("TeamsNamesGui") -- this should make the flags draw over the gui goal images translateTime = translateTime + 0.15 SetTranslateToAction("ScoreAGui", 91.8, 0.0, 0.0, translateTime) SetTranslateToAction("ScoreBGui", -91.8, 0.0, 0.0, translateTime) EnqueueTimeExecuteScript("SetTranslateToAction(\"ScoreAGui\", 81.2, 0.0, 0.0, 0.15)", translateTime + 0.15) EnqueueTimeExecuteScript("SetTranslateToAction(\"ScoreBGui\", -81.2, 0.0, 0.0, 0.15)", translateTime + 0.15) end