Example #1
0
        public void borders() //создание случайных границ
        {
            Random rand = new Random();

            for (int i = 1; i <= (Width * Height / 2); i++)
            {
                int ran = rand.Next(0, CellList.Count - Width - 3); //случайное число - номер ячейки
                if (CellList[ran].ycoord == Width)
                {
                    ran = ran - 1;
                }
                CellList[ran].tborder = true;
                if (CellList[ran].xcoord >= 1)
                {
                    CCell pXMinus1 = Get(CellList[ran].xcoord - 1, CellList[ran].ycoord); //соседняя ячейка сверху
                    pXMinus1.bborder = true;                                              //создание парной границы
                }
                ran = rand.Next(0, CellList.Count - Width - 3);                           //случайное число - номер ячейки
                if (CellList[ran].ycoord == Width)
                {
                    ran = ran - 1;
                }
                CellList[ran].lborder = true;
                if (CellList[ran].ycoord >= 1)
                {
                    CCell pYMinus1 = Get(CellList[ran].xcoord, CellList[ran].ycoord - 1); //соседняя ячейка слева
                    pYMinus1.rborder = true;                                              //создание парной границы
                }
            }
        }
Example #2
0
 public void newfield()
 {
     CellList.Clear();
     for (int i = 0; i <= Height; i++)
     {
         for (int j = 0; j <= Width; j++)
         {
             CCell Cell = new CCell()
             {
                 xcoord  = i,
                 ycoord  = j,
                 bborder = false,
                 lborder = false,
                 rborder = false,
                 tborder = false,
                 type    = EType.Ordinary
             };
             //создание внешних границ
             if ((i == 0) || (i == Height))
             {
                 Cell.tborder = true;
             }
             if ((j == 0) || (j == Width))
             {
                 Cell.lborder = true;
             }
             if (i == (Height - 1))
             {
                 Cell.bborder = true;
             }
             if (j == (Width - 1))
             {
                 Cell.rborder = true;
             }
             CellList.Add(Cell);
         }
     }
     CellList[0].type = EType.Entry;
     CellList[CellList.Count - Width - 3].type = EType.Exit;
     borders();           //создание случайных границ
     bholes();            //создание "черных дыр"
     DrawingField();      //рисование поля
     DrawingBlackHoles(); //рисование черных дыр
 }