//-------------------------------------------------------------------------------------------------------- private void LoadGameStateOrStartNewGame() { // if this device has no saved game, just start a new game if (!File.Exists(Application.persistentDataPath + saveFileName)) { StartNewGame(); return; } // fetch the save state from the save file BinaryFormatter formatter = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + saveFileName, FileMode.Open); SaveState saveState = (SaveState)formatter.Deserialize(file); file.Close(); // if the loaded game is actually over, start a new one instead if (saveState.IsGameOver) { StartNewGame(); return; } // populate the board according to the saved state for (int i = 0; i < saveState.BlockLocations.Count; i++) { CreateBlock( location: hexes[saveState.BlockLocations[i]], kind: saveState.BlockKinds[i], level: saveState.BlockLevels[i], celebrate: false); } Score = saveState.Score; ScoreMultPanel.CurrentLevel = saveState.Multiplier; ScoreMultPanel.CreateComboPrefab(); turnCount = saveState.TurnCount; // update the level rewards bar CurrentWildChance = saveState.CurrentWildChance; CurrentDoubleChance = saveState.CurrentDoubleChance; CurrentTripleChance = saveState.CurrentTripleChance; CurrentHungryNekoInterval = saveState.CurrentHungryNekoInterval; MovesSinceLastHungryNeko = saveState.MovesSinceLastHungryNeko; ForceWildCardNextTurn = false; UnlockProgressBar.SnapToCurrentScoreWithoutRewards(); // initialize the current hungry neko, if we have one if (saveState.HungryNekoCount > 0) { HungryNekos[saveState.HungryNekoLocation].GetHungry(saveState.HungryNekoLevel); } // misc initialization tasks ScoreDisplayObj.Snap(); swipeDir = BoardDirection.Null; allowInput = true; HighScore = PlayerPrefs.GetInt(playerPrefHighScoreKey); Debug.Log("Game loaded. " + "Total games started: " + PlayerPrefs.GetInt(playerPrefsGameCountKey) + ", " + "Premium status: " + PremiumControllerObj.IsGamePremium); }