void RecordCurrentGameToPref() { var gameState = new GameState(); gameState.side = CurrentSide; gameState.round = Round; gameState.boardSize = mBoardSize; gameState.checks = new CheckState[mBoardSize * mBoardSize]; for (int x = 0; x < mBoardSize; x++) { for (int y = 0; y < mBoardSize; y++) { var check = mCheckArray[x, y]; var checkState = new CheckState() { x = check.XPos, y = check.YPos, haveChess = check.HaveChess, }; var index = GetIndexFromXY(mBoardSize, x, y); gameState.checks[index] = checkState; } } GameStateRecorder.RecordGameState(gameState); }
// Check if the game ends and handle recording accordingly public static bool CheckIfGameEnds() { GameStateRecorder gsr = GameObjectFinder.FindGameStateRecorder(); GameObject[] players = GameObjectFinder.FindAllCharacters(); int numAlive = 0; foreach (GameObject player in players) { if (!player.GetComponent <Character>().IsDead) { numAlive++; } } if (numAlive == 1) { gsr.FinishRecording(); return(true); } else { return(false); } }
void ClearRecord() { GameStateRecorder.ClearGameRecord(); }