public void ShowGUI() { if (GameData.currentLevel == 0) { if (GameData.enemiesDestroyed == GameData.enemiesSpawned - 1) { gameDataRef.playerLives += 1; } GUI.Label(new Rect(Screen.width / 2 - 70, Screen.height / 2, 200, 30), "Level 1 completed"); if (GUI.Button(new Rect(Screen.width / 2 - 135, Screen.height / 2 + 40, 270, 30), "Click Here to proceed to level 2")) { manager.SwitchState(new PlayStateL2(manager)); } } else if (GameData.currentLevel == 1) { GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2, 300, 30), "Congratulations! You've beat the game"); GameData.playerName = GUI.TextField(new Rect(Screen.width / 2 - 75, Screen.height / 2 + 30, 150, 30), GameData.playerName); if (GUI.Button(new Rect(Screen.width / 2 - 135, Screen.height / 2 + 70, 270, 30), "Click Here to Restart Game")) { HighScores.AddHighScore(GameData.playerName, manager.gameDataRef.score); HighScores.SaveScores(); manager.Restart(); } } }
public void ShowGUI() { GameData.playerName = GUI.TextField(new Rect(Screen.width / 2 - 75, Screen.height / 2 - 30, 150, 30), GameData.playerName); if (GUI.Button(new Rect(Screen.width / 2 - 135, Screen.height / 2, 270, 30), "Back to menu")) { HighScores.AddHighScore(GameData.playerName, manager.gameDataRef.score); HighScores.SaveScores(); manager.Restart(); } }
public void TestHighScoreSaving() { HighScores hss = new HighScores(); hss.AddHighScore(new HighScore { points = 100, name = "TEST2" }); hss.SaveHighScores(); hss.LoadHighScores(); Assert.AreEqual(hss[0].points, 100); }
public bool ShowHighScores(string playerName = "") { if (currentState.GetStateType() == GameState.State.RESULT || currentState.GetStateType() == GameState.State.HIGH_SCORE_INPUT) { long newScore = enemyHandler.GetScore(); highScores.AddHighScore(newScore, playerName); SwitchState(GameState.State.HIGH_SCORE); return(true); } return(false); }
public void GameOver() { gameOver = true; HighScores highScores = new HighScores(); if (highScores.IsHighScore(score)) { gameOverText.text = "New high score!"; highScores.AddHighScore("You", score); highScores.SaveHighScores(); StartCoroutine(SwitchToLevelAfterPause("HighScores", 4.0f)); } else { gameOverText.text = "Game Over"; } }