Exemple #1
0
 public void UpdateMap()
 {
     int[,] temp = new int[field, field];
     label1.Text = "Red Death: " + RedCell.redDies;
     label2.Text = "Black Death: " + BlackCell.blackDies;
     foreach (var i in Map)
     {
         i.Check(Map, ref temp);
     }
     for (int i = 0; i < Map.GetLength(0); i++)
     {
         for (int j = 0; j < Map.GetLength(1); j++)
         {
             if (temp[i, j] == 0)
             {
                 Map[i, j] = new WhiteCell(Map[i, j]);
             }
             if (temp[i, j] == 2)
             {
                 Map[i, j] = new RedCell(Map[i, j]);
             }
             if (temp[i, j] == 1)
             {
                 Map[i, j]  = new BlackCell(Map[i, j]);
                 temp[i, j] = 0;
             }
         }
     }
 }
Exemple #2
0
        public void FirstUpdate()
        {
            int[,] temp = new int[field, field];
            Random rand = new Random();

            for (int i = 0; i < temp.GetLength(0); i++)
            {
                for (int j = 0; j < temp.GetLength(1); j++)
                {
                    temp[i, j] = rand.Next(0, 3);
                }
            }
            for (int i = 0; i < Map.GetLength(0); i++)
            {
                for (int j = 0; j < Map.GetLength(1); j++)
                {
                    if (temp[i, j] == 0)
                    {
                        Map[i, j] = new WhiteCell(Map[i, j]);
                    }
                    if (temp[i, j] == 2)
                    {
                        Map[i, j] = new RedCell(Map[i, j]);
                    }
                    if (temp[i, j] == 1)
                    {
                        Map[i, j]  = new BlackCell(Map[i, j]);
                        temp[i, j] = 0;
                    }
                }
            }
        }