Пример #1
0
        MineCell CreateMine(int x, int y)
        {
            MineCell newMine = Instantiate(mineObj, new Vector2(Width / 2f - .5f - y, -Height / 2f + .5f + x), Quaternion.identity, transform).GetComponent <MineCell>();

            newMine.InitCell(x, y);
            return(newMine);
        }
Пример #2
0
        public void Init(MapInfo info)
        {
            Height  = info.height;
            Width   = info.width;
            cellObj = info.cell;
            mineObj = info.mine;

            mapRand = new MapRandomizator(Height, Width, info.mineCount);
            if (info.useSeed)
            {
                Random.InitState(info.seed.GetHashCode());
            }

            DeleteOldCells();
            mines.Clear();
            cells.Clear();
        }
Пример #3
0
 private void SetMineCellsSizeAndLocation()
 {
     MineCells = new MineCell[Rows, Columns];
     Points    = new Point[Rows, Columns];
     for (int y = 0; y < Rows; y++)
     {
         for (int x = 0; x < Columns; x++)
         {
             MineCells[y, x]         = new MineCell();
             MineCells[y, x].Picture = ImageLibrary[-1];
             MineCells[y, x].Y       = y;
             MineCells[y, x].X       = x;
             Points[y, x]            = new Point();
             Points[y, x].Y          = y * elementLength;
             Points[y, x].X          = x * elementLength;
         }
     }
 }
Пример #4
0
 public void CreateMap()
 {
     int[,] map = mapRand.GetRandomMap();
     for (int i = 0; i < map.GetLength(0); i++)
     {
         for (int j = 0; j < map.GetLength(1); j++)
         {
             if (map[i, j] == 0)
             {
                 EmptyCell cell = CreateCell(i, j, CalculateMineAroundCell(map, i, j));
                 cells.Add(cell);
             }
             else
             {
                 MineCell mine = CreateMine(i, j);
                 cells.Add(mine);
                 mines.Add(mine);
             }
         }
     }
 }