コード例 #1
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;
                    }
                }
            }
        }
コード例 #2
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;
             }
         }
     }
 }
コード例 #3
0
        public void CreateMap()
        {
            Map = new Cell[field, field];
            for (int i = 0; i < field; i++)
            {
                for (int j = 0; j < field; j++)
                {
                    Point loc = new Point(20 + (size + 10) * j, 90 + (size + 10) * i);
                    Map[i, j] = new WhiteCell(size, loc, i, j);
                    Controls.Add(Map[i, j].square);
                }
            }
            int[,] temp = new int[field, field];
            int rnd;

            for (int i = 0; i < temp.GetLength(0); i++)
            {
                for (int j = 0; j < temp.GetLength(1); j++)
                {
                    rnd        = new Random().Next(0, 2);
                    temp[i, j] = rnd;
                }
            }
        }