Exemplo n.º 1
0
        EmptyCell CreateCell(int x, int y, int count)
        {
            EmptyCell newCell = Instantiate(cellObj, new Vector2(Width / 2f - .5f - y, -Height / 2f + .5f + x), Quaternion.identity, transform).GetComponent <EmptyCell>();

            newCell.InitCell(x, y, count);
            return(newCell);
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
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);
             }
         }
     }
 }