Ejemplo n.º 1
0
        /// <summary>
        /// Are these points connected, considering only terrain (not monsters)
        /// </summary>
        /// <param name="level"></param>
        /// <param name="firstPoint"></param>
        /// <param name="secondPoint"></param>
        /// <returns></returns>
        public bool ArePointsConnected(int level, Point firstPoint, Point secondPoint, PathingPermission permission)
        {
            if (firstPoint == secondPoint)
            {
                return(true);
            }

            return(pathFinding.arePointsConnected(level, firstPoint, secondPoint, permission));
        }
Ejemplo n.º 2
0
        public bool SetSquareUnwalkableIfDoorPathingIsPreserved(Point p)
        {
            if (p.x < 0 || p.y < 0 || p.x >= template.Width || p.y >= template.Height)
            {
                return(false);
            }

            //Set square unwalkable to test
            var originalTerrain = pathingMap.getCell(p.x, p.y);

            pathFinding.updateMap(0, p, PathingTerrain.Unwalkable);

            //Check all doors are pathable to each other
            bool pathable = true;

            var doors = template.PotentialDoors;

            for (int i = 0; i < doors.Count; i++)
            {
                for (int j = 0; j < doors.Count; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    if (!pathFinding.arePointsConnected(0, doors[i].Location, doors[j].Location, Pathing.PathingPermission.Normal))
                    {
                        pathable = false;
                        break;
                    }
                }
            }

            if (!pathable)
            {
                pathFinding.updateMap(0, p, originalTerrain);
                return(false);
            }
            return(true);
        }