GetPath() публичный Метод

Pathfinding function
public GetPath ( float currentX, float currentY, StarSystem currentDestination, StarSystem newDestination, bool hasExtended, Empire whichEmpire ) : List
currentX float Fleet's Galaxy X
currentY float Fleet's Galaxy Y
currentDestination StarSystem Fleet's current destination for when empire don't have hyperspace communications
newDestination StarSystem New destination
hasExtended bool
whichEmpire Empire For fuel range and other info
Результат List
Пример #1
0
        public void SetTentativePath(StarSystem destination, bool hasExtendedFuelTanks, Galaxy galaxy)
        {
            if (destination == null || destination == _adjacentSystem)
            {
                //if destination is same as origin, or nowhere, clear the tentative path
                TentativeNodes = null;
                return;
            }
            if (_travelNodes != null && _travelNodes[_travelNodes.Count - 1].StarSystem == destination)
            {
                //Same path as current path
                TentativeNodes = null;
                return;
            }
            if (TentativeNodes != null && TentativeNodes[_tentativeNodes.Count - 1].StarSystem == destination)
            {
                // Existing tentative path
                return;
            }

            StarSystem currentDestination = null;

            if (_adjacentSystem == null)             //Has left a system
            {
                currentDestination = _travelNodes[0].StarSystem;
            }
            List <TravelNode> path = galaxy.GetPath(_galaxyX, _galaxyY, currentDestination, destination, hasExtendedFuelTanks, _empire);

            if (path == null)
            {
                TentativeNodes = null;
                return;
            }

            TentativeNodes = path;
            if (TentativeNodes.Count == 0)
            {
                TentativeNodes = null;
            }
        }
Пример #2
0
        public void SetTentativePath(StarSystem destination, bool hasExtendedFuelTanks, Galaxy galaxy)
        {
            if (destination == null || destination == _adjacentSystem)
            {
                //if destination is same as origin, or nowhere, clear the tentative path
                TentativeNodes = null;
                return;
            }
            if (_travelNodes != null && _travelNodes[_travelNodes.Count - 1].StarSystem == destination)
            {
                //Same path as current path
                TentativeNodes = null;
                return;
            }
            if (TentativeNodes != null && TentativeNodes[_tentativeNodes.Count - 1].StarSystem == destination)
            {
                // Existing tentative path
                return;
            }

            StarSystem currentDestination = null;
            if (_adjacentSystem == null) //Has left a system
            {
                currentDestination = _travelNodes[0].StarSystem;
            }
            List<TravelNode> path = galaxy.GetPath(_galaxyX, _galaxyY, currentDestination, destination, hasExtendedFuelTanks, _empire);
            if (path == null)
            {
                TentativeNodes = null;
                return;
            }

            TentativeNodes = path;
            if (TentativeNodes.Count == 0)
            {
                TentativeNodes = null;
            }
        }