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

            gameCell.FlagCell();
            return(gameCell);
        }
コード例 #3
0
ファイル: GameCells.cs プロジェクト: justonelemon/PairingGame
    void Awake()
    {
        instance = this;

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

        _spawnGrid = new Cell[_gridSize[0], _gridSize[1]];
    }
コード例 #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));
         }
     }
 }
コード例 #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);
     }
 }
コード例 #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;
            }
        }
コード例 #7
0
        private GameCell GetGameCell(Int32 x, Int32 y)
        {
            var coordinate = new Coordinate(x, y);

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