示例#1
0
 public void LoadGame(GameMemento memento)
 {
     _state = memento.GetState();
 }
示例#2
0
 public GameMemento(GameState state)
 {
     _state = state;
 }
示例#3
0
        private GameState _state = new GameState(100, 0);//Health & Killed Monsters

        public void Play()
        {
            //During this Play method game's state is continuously changed
            Console.WriteLine(_state.ToString());
            _state = new GameState((int)(_state.Health * 0.9), _state.KilledMonsters + 2);
        }