public void LoadGame() { using (var fs = new FileStream("test.bin", FileMode.Open)) { var bin = new BinaryFormatter(); _state = (GameState) bin.Deserialize(fs); Game.Instance().LoadGame(_state); } }
public void SaveGame(Game game) { _state = new GameState(game.Map, game.Players, game.Players.IndexOf(game.CurrentPlayer)); try { using (Stream stream = File.Open("test.bin", FileMode.Create)) { var bin = new BinaryFormatter(); bin.Serialize(stream, _state); } } catch (IOException) { MessageBox.Show("Error while saving to file!"); } }
public void LoadGame(GameState state) { Players = state.Players; CurrentPlayer = Players[state.CurrentPlayer]; Map.LoadFrom(state.Map); }
public void LoadGame(GameState state) { Players = state.Players; //TODO: добавить в файл сохранения информацию о том, который из игроков ходит. _currentPlayer = Players[0]; Map.LoadFrom(state.Map); }