Esempio n. 1
0
 internal void SetMemento(GameMemento memento)
 {
     if (mementos.Count > 0)
     {
         if (mementos[mementos.Count - 1] != memento)
         {
             mementos.Add(memento);
         }
     }
     else
     {
         mementos.Add(memento);
     }
 }
Esempio n. 2
0
 internal void RestoreState(GameMemento memento)
 {
     this.gameField     = memento.gameField;
     this.currentPlayer = memento.currentPlayer;
     for (int i = 0; i < this.X.Count; i++)
     {
         if (i < memento.X.Count)
         {
             this.X[i] = memento.X[i];
             this.Y[i] = memento.Y[i];
         }
         else
         {
             this.X.RemoveAt(i);
             this.Y.RemoveAt(i);
         }
     }
     if (memento.Y.Count == 0)
     {
         this.X.Clear();
         this.Y.Clear();
     }
 }