Exemplo n.º 1
0
        private static void TryQueueNewNode(IPathNode pNewNode, PathLink pLink, AStarStack pNodesToVisit, IPathNode pGoal)
        {
            IPathNode previousNode = pLink.GetOtherNode(pNewNode);
            float     linkDistance = pLink.Distance;
            float     newPathCost  = previousNode.PathCostHere + pNewNode.CostMultiplier * linkDistance;

            if (pNewNode.LinkLeadingHere == null || (pNewNode.PathCostHere > newPathCost))
            {
                pNewNode.DistanceToGoal  = pNewNode.DistanceTo(pGoal) * 2f;
                pNewNode.PathCostHere    = newPathCost;
                pNewNode.LinkLeadingHere = pLink;
                pNodesToVisit.Push(pNewNode);
            }
        }
Exemplo n.º 2
0
        public PathLink AddPathLink(IntPointNode nodeA, IntPointNode nodeB)
        {
            if (nodeA == nodeB || nodeB.Position == nodeA.Position)
            {
                throw new ArgumentException();
            }
            PathLink link = nodeB.GetLinkTo(nodeA);

            if (link == null)
            {
                link          = new PathLink(nodeA, nodeB);
                link.Distance = (nodeA.Position - nodeB.Position).Length();
                nodeA.Links.Add(link);
                nodeB.Links.Add(link);
            }

            return(link);
        }
Exemplo n.º 3
0
        public PathLink AddPathLink(IntPointNode nodeA, IntPointNode nodeB)
        {
            if (nodeA == nodeB || nodeB.Position == nodeA.Position)
            {
                Debug.Assert(false, "nodeA and node B should not be the same position");
                return(null);
            }
            PathLink link = nodeB.GetLinkTo(nodeA);

            if (link == null)
            {
                link          = new PathLink(nodeA, nodeB);
                link.Distance = (nodeA.Position - nodeB.Position).Length();
                nodeA.Links.Add(link);
                nodeB.Links.Add(link);
            }

            return(link);
        }
Exemplo n.º 4
0
 public void AddLink(PathLink pLink)
 {
     Links.Add(pLink);
 }
Exemplo n.º 5
0
 public void RemoveLink(PathLink pLink)
 {
     Links.Remove(pLink);
 }