Ejemplo n.º 1
0
        public BattlefieldMemento CreateMemento()
        {
            BattlefieldMemento Memento = new BattlefieldMemento();

            foreach (List <Field> Row in this.BattleGrid)
            {
                Memento.BattleGrid.Add(Row.Select(x => x.CreateMemento()).ToList());
            }
            foreach (HeroInterface Hero in this.Heroes)
            {
                Memento.Heroes.Add(Hero.CreateMemento());
            }
            return(Memento);
        }
Ejemplo n.º 2
0
 public void Restore(BattlefieldMemento Memento)
 {
     for (int i = 0; i < BattleGrid.Count; i++)
     {
         for (int j = 0; j < BattleGrid[i].Count; j++)
         {
             BattleGrid[i][j].Restore(Memento.BattleGrid[i][j]);
         }
     }
     for (int i = 0; i < this.Heroes.Count; i++)
     {
         this.Heroes[i].Restore(Memento.Heroes[i]);
         Field Temp = GetField(this.Heroes[i].GetCoordinates()[0], this.Heroes[i].GetCoordinates()[1]);
         if (Temp != null && !this.Heroes[i].IsDead())
         {
             Temp.SetHero(this.Heroes[i]);
         }
     }
 }