Ejemplo n.º 1
0
 private void FillLayoutWithElements(int amount)
 {
     for (var i = 0; i < amount; i++)
     {
         GameCells.Add(CreateCell());
     }
 }
Ejemplo n.º 2
0
        public GameCell RightClickCell(GameCell gc)
        {
            GameCell gameCell = GameCells.Find(cell => cell.X == gc.X && cell.Y == gc.Y);

            gameCell.FlagCell();
            return(gameCell);
        }
Ejemplo n.º 3
0
    void Awake()
    {
        instance = this;

        _gridSize[0] = COLS + 2;
        _gridSize[1] = ROWS + 2;

        _spawnGrid = new Cell[_gridSize[0], _gridSize[1]];
    }
Ejemplo n.º 4
0
 protected void CreateCells()
 {
     for (int x = 1; x <= BoardSize.Size; x++)
     {
         for (int y = 1; y <= BoardSize.Size; y++)
         {
             GameCells.Add(new GameCell(CellSize, x, y));
         }
     }
 }
Ejemplo n.º 5
0
 public void SetNeighbors()
 {
     foreach (GameCell currentCell in GameCells)
     {
         GameCell northNeighbor = GameCells.Find(cell => cell.X == currentCell.X - 1 && cell.Y == currentCell.Y);
         GameCell eastNeighbor  = GameCells.Find(cell => cell.X == currentCell.X && cell.Y == currentCell.Y - 1);
         GameCell southNeighbor = GameCells.Find(cell => cell.X == currentCell.X + 1 && cell.Y == currentCell.Y);
         GameCell westNeighbor  = GameCells.Find(cell => cell.X == currentCell.X && cell.Y == currentCell.Y + 1);
         currentCell.Neighbors = new Neighbors(northNeighbor, eastNeighbor, southNeighbor, westNeighbor);
     }
 }
Ejemplo n.º 6
0
        public void ActivateCells()
        {
            int    cellCount           = BoardSize.Size * BoardSize.Size;
            int    numberOfActiveCells = (int)(cellCount * Difficulty.Difficulty);
            Random rnd = new Random();

            for (int i = 0; i < numberOfActiveCells; i++)
            {
                int      x      = rnd.Next(1, BoardSize.Size + 1);
                int      y      = rnd.Next(1, BoardSize.Size + 1);
                GameCell result = GameCells.Find(cell => cell.X == x && cell.Y == y && !cell.Live);
                while (result == null)
                {
                    x      = rnd.Next(1, BoardSize.Size + 1);
                    y      = rnd.Next(1, BoardSize.Size + 1);
                    result = GameCells.Find(cell => cell.X == x && cell.Y == y && !cell.Live);
                }
                result.Live = true;
            }
        }
        private GameCell GetGameCell(Int32 x, Int32 y)
        {
            var coordinate = new Coordinate(x, y);

            return(GameCells.FirstOrDefault(gameCell => gameCell.Location.Equals(coordinate)));
        }