示例#1
0
        private static List <PlayerMovementPath> createProposedMovementPaths(PlayerMovementPath currentMovementPath, CollisionMap Map)
        {
            List <PlayerMovementPath> paths = new List <PlayerMovementPath>();

            // Get the unblocked neighbours at the current coordinate
            List <CollisionMapElement> childElements = Map.getElement(currentMovementPath.getLastCoordinate()).getUnblockedNeighbours();

            foreach (CollisionMapElement element in childElements)
            {
                // Do not go back the direction you just came
                if (!element.ElementCoordinate.Equals(currentMovementPath.getSecondToLastCoordinate()))
                {
                    PlayerMovementPath newMovementPath = currentMovementPath.Clone();
                    // Add the other coordinates
                    newMovementPath.CoordinatePath.Add(element.ElementCoordinate);
                    newMovementPath.HeuristicValue = Map.getElement(element.ElementCoordinate).DistanceFromGoal + currentMovementPath.getDistanceTravelled();
                    paths.Add(newMovementPath);
                }
            }

            return(paths);
        }