예제 #1
0
        public List <T> GetNeighboursInLine(int neighbourIndex, int rows)
        {
            List <T> currentNeighbours = new List <T>();

            for (int i = 1; i < rows + 1; i++)
            {
                Vector2 tilePosition = new Vector2(_tilePosition.x + _neighboursPositions[neighbourIndex].x * i, _tilePosition.y + _neighboursPositions[neighbourIndex].y * i);

                if (GridExt.IsInRange(_grid, tilePosition))
                {
                    currentNeighbours.Add(_grid[(int)tilePosition.x, (int)tilePosition.y]);
                }
                else
                {
                    currentNeighbours.Add(default(T));
                }
            }

            return(currentNeighbours);
        }
예제 #2
0
        public List <T> GetNeighbours8(int row)
        {
            List <T> currentNeighbours = new List <T>();

            for (int i = 0; i < 8; i++)
            {
                Vector2 tilePosition = new Vector2(_tilePosition.x + _neighboursPositions[i].x * row, _tilePosition.y + _neighboursPositions[i].y * row);

                if (GridExt.IsInRange(_grid, tilePosition))
                {
                    currentNeighbours.Add(_grid[(int)tilePosition.x, (int)tilePosition.y]);
                }
                else
                {
                    currentNeighbours.Add(default(T));
                }
            }

            return(currentNeighbours);
        }