示例#1
0
        private bool CheckCondition(TileMap map, Vector2 cell)
        {
            foreach (var side in Conditions.Keys)
            {
                int i           = 0;
                var cellChoices = Conditions[side].CellIndexChoices;

                while (i++ < Consecutive)
                {
                    var adjacentCell = map.Tiles.Cells.GetFromPoint(cell.GetAdjacent(side));
                    if (cellChoices.Any())
                    {
                        if (!cellChoices.Contains(adjacentCell))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (adjacentCell != map.EmptyCell)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
示例#2
0
        public IEnumerable <ArrayGridPoint <T> > GetPointsInLine(Vector2 start, Direction dir)
        {
            Vector2 point = start;

            while (PointToIndex(point, -1) != -1)
            {
                yield return(new ArrayGridPoint <T>(point, this));

                point = point.GetAdjacent(dir);
            }

            yield return(new ArrayGridPoint <T>(point, this));
        }
示例#3
0
        public static Vector2[] GetAdjacentPoints(this Vector2 vector, bool includeDiagonal)
        {
            var sides = new List <BorderSide> {
                BorderSide.Left, BorderSide.Top, BorderSide.Right, BorderSide.Bottom
            };

            if (includeDiagonal)
            {
                sides.Add(BorderSide.TopLeftCorner);
                sides.Add(BorderSide.TopRightCorner);
                sides.Add(BorderSide.BottomLeftCorner);
                sides.Add(BorderSide.BottomRightCorner);
            }

            return(sides.Select(side => vector.GetAdjacent(side)).ToArray());
        }
示例#4
0
        public ArrayGridPoint <T> GetAdjacent(Direction side)
        {
            var adj = Position.GetAdjacent(side);

            return(new ArrayGridPoint <T>(adj, Grid));
        }