//================================================================================================== void Update() { if (flagRestartLevel) { #if UNITY_ANDROID #else if (Input.GetKeyDown(KeyCode.R)) { StoreRuntimeLevel(); Statistics.GetInst().ActualizeTotalScore(); Statistics.GetInst().ActualizeBestScoreList(); GamePlaySave.GetInst().ClearSavedScoreProgress(); if (GamePlaySave.GetInst().LoadNewGame(RuntimeContext.GetInst().nesActLevel.levelName)) { Application.LoadLevel(RuntimeContext.GetInst().nesActLevel.levelName); } } #endif } #if UNITY_ANDROID if (Input.GetKey(KeyCode.Escape)) #else if (Input.GetKeyDown(KeyCode.Escape)) #endif { if (!flagGameOver) { StoreRuntimeLevel(); StoreRuntimePlayer(); GamePlaySave.GetInst().SaveProgress(); } else { // player ship was destroyed, the game is over // actualize total statistics // write new best score // --> do not save level progress StoreRuntimeLevel(); Statistics.GetInst().ActualizeTotalScore(); Statistics.GetInst().ActualizeBestScoreList(); // and because the game is over, just clear score stats in last saved game, BUT do not delete the save // this is because of this situation: // * player has score of 25000 (not important) // * player saved the game // * player loaded the game and was destroyed (game over happened) // * total stats was updated from this game over --> this is important // * top 20 stats was updated from this game over --> this is important // * --->>> if the saved game score is not cleaded, player can load the game // (yes the same game he just lost = game over), with the previous score // of 25000... // * therefore saved score is cleaned --> this is important // * player loaded last saved game - ship is the same, level is the same, // wave is the same, BUT score is ZERO // * player loose the game again (game over) --> JUST THE SCORE OBTAINED FROM // LAST LOAD IS ADDED TO TOTAL SCORE and TOP 20 ;) GamePlaySave.GetInst().ClearSavedScoreProgress(); } Application.LoadLevel(eGameLevels.Screen_MainMenu.ToString()); } UpdateTextLifes(RuntimeContext.GetInst().nesActPlayer.actLifes); UpdateTextHealth(RuntimeContext.GetInst().nesActPlayer.actHealth); UpdateTextShield(RuntimeContext.GetInst().nesActPlayer.actShield); UpdateTextEnergy(RuntimeContext.GetInst().nesActPlayer.actEnergy); UpdateTextScore(RuntimeContext.GetInst().nesActLevel.levelScore); }
void OnGUI() { if ((Screen.width != screenWidth) || (Screen.height != screenHeight)) { CalcButtonRects(); CalcBestScoreRect(); textPageTextStyle = new GUIStyle("box"); textPageTextStyle.richText = true; textPageTextStyle.alignment = TextAnchor.UpperLeft; textPageTextStyle.font = new Font("Times New Roman"); } if (bestScoreShowed) { if (bestScoreTextTable.Length <= 0) { InitTextBestScore(); } GUILayout.BeginArea(textPageScrollRect); { textPageScrollVec = GUILayout.BeginScrollView(textPageScrollVec, GUILayout.Width(textPageScrollRect.width), GUILayout.Height(textPageScrollRect.height)); { GUILayout.Label(bestScoreTextTable); } GUILayout.EndScrollView(); } GUILayout.EndArea(); } else if (creditsShowed) { if (creditsText.Length <= 0) { InitTextCredits(); } GUILayout.BeginArea(textPageScrollRect); { textPageScrollVec = GUILayout.BeginScrollView(textPageScrollVec, GUILayout.Width(textPageScrollRect.width), GUILayout.Height(textPageScrollRect.height)); { GUILayout.Label(creditsText); } GUILayout.EndScrollView(); } GUILayout.EndArea(); } else if (helpShowed) { if (helpText.Length <= 0) { InitTextHelp(); } GUILayout.BeginArea(textPageScrollRect); { textPageScrollVec = GUILayout.BeginScrollView(textPageScrollVec, GUILayout.Width(textPageScrollRect.width), GUILayout.Height(textPageScrollRect.height)); { GUILayout.Label(helpText); } GUILayout.EndScrollView(); } GUILayout.EndArea(); } else { GUILayout.BeginArea(mainButtonsRect); { GUILayout.BeginVertical(); { //GUILayout.FlexibleSpace(); if (GUILayout.Button("New Game", GUILayout.ExpandHeight(true))) // GUILayout.Height(mainButtonsHeight.x))) { if (GamePlaySave.GetInst().LoadNewGame()) { Application.LoadLevel(RuntimeContext.GetInst().nesActLevel.levelName); } } GUILayout.Space(mainButtonsHeight.y); if (GUILayout.Button("Load Game", GUILayout.ExpandHeight(true))) // GUILayout.Height(mainButtonsHeight.x))) { if (GamePlaySave.GetInst().LoadProgress()) { Application.LoadLevel(RuntimeContext.GetInst().nesActLevel.levelName); } } GUILayout.Space(mainButtonsHeight.y); if (GUILayout.Button("Best Scores", GUILayout.ExpandHeight(true))) // GUILayout.Height(mainButtonsHeight.x))) { bestScoreShowed = true; } GUILayout.Space(mainButtonsHeight.y); if (GUILayout.Button("Ships", GUILayout.ExpandHeight(true))) // GUILayout.Height(mainButtonsHeight.x))) { Application.LoadLevel(eGameLevels.Screen_ShipSelect.ToString()); } GUILayout.Space(mainButtonsHeight.y); if (GUILayout.Button("Credits", GUILayout.ExpandHeight(true))) // GUILayout.Height(mainButtonsHeight.x))) { creditsShowed = true; } GUILayout.Space(mainButtonsHeight.y); if (GUILayout.Button("Help", GUILayout.ExpandHeight(true))) // GUILayout.Height(mainButtonsHeight.x))) { helpShowed = true; } //GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); } GUILayout.EndArea(); } }