private void SwitchState() { if (this.kGameStateType != kNextGameStateType) { kGameState.CleanUp(); GameStateBase nextGameState = null; switch (kNextGameStateType) { case GameStateType.MainMenu: { nextGameState = new MainMenuGameState(); break; } case GameStateType.Simulation: { nextGameState = new SimulationGameState(); break; } case GameStateType.Quit: { nextGameState = new QuitGameState(); break; } } this.kGameStateType = kNextGameStateType; this.kGameState = nextGameState; nextGameState.Startup(); } }
private void Awake() { if (instance == null) { instance = this; } playerLevel = PlayerPrefs.GetInt(PrefKeys.playerLevel, 1); playerExp = PlayerPrefs.GetInt(PrefKeys.playerExp, 0); playerID = PlayerPrefs.GetString(PrefKeys.playerID, System.Guid.NewGuid().ToString()); playerName = PlayerPrefs.GetString(PrefKeys.playerName, "Anonymous"); playerBestScore = PlayerPrefs.GetInt(PrefKeys.bestScore, 0); PlayerPrefs.SetInt(PrefKeys.playerLevel, playerLevel); PlayerPrefs.SetInt(PrefKeys.playerExp, playerExp); PlayerPrefs.SetString(PrefKeys.playerID, playerID); PlayerPrefs.SetString(PrefKeys.playerName, playerName); PlayerPrefs.SetInt(PrefKeys.bestScore, playerBestScore); }
// Use this for initialization void Start() { MainMenuGameState gameState = MainMenuGameState.instance; GetComponent <Text>().text = gameState.GetExp() + playerExpBaseText + StaticCalcs.experienceToLevel(gameState.GetPlayerLevel()); }