Exemplo n.º 1
0
        public virtual void Apply()
        {
            if (Start == null || End == null || AstarPath.active == null)
            {
                return;
            }

            GraphNode startNode = AstarPath.active.GetNearest(Start.position).node;
            GraphNode endNode   = AstarPath.active.GetNearest(End.position).node;

            if (startNode == null || endNode == null)
            {
                return;
            }

            if (deleteConnection)
            {
                startNode.RemoveConnection(endNode);
                if (!oneWay)
                {
                    endNode.RemoveConnection(startNode);
                }
            }
            else
            {
                uint cost = (uint)System.Math.Round((startNode.position - endNode.position).costMagnitude * costFactor);

                startNode.AddConnection(endNode, cost);
                if (!oneWay)
                {
                    endNode.AddConnection(startNode, cost);
                }
            }
        }
Exemplo n.º 2
0
        public virtual void Apply()
        {
            if (this.Start == null || this.End == null || AstarPath.active == null)
            {
                return;
            }
            GraphNode node  = AstarPath.active.GetNearest(this.Start.position).node;
            GraphNode node2 = AstarPath.active.GetNearest(this.End.position).node;

            if (node == null || node2 == null)
            {
                return;
            }
            if (this.deleteConnection)
            {
                node.RemoveConnection(node2);
                if (!this.oneWay)
                {
                    node2.RemoveConnection(node);
                }
            }
            else
            {
                uint cost = (uint)Math.Round((double)((float)(node.position - node2.position).costMagnitude * this.costFactor));
                node.AddConnection(node2, cost);
                if (!this.oneWay)
                {
                    node2.AddConnection(node, cost);
                }
            }
        }
Exemplo n.º 3
0
        protected override void OnDisable()
        {
            base.OnDisable();

            postScanCalled = false;

            if (startNode != null)
            {
                reference.Remove(startNode);
            }
            if (endNode != null)
            {
                reference.Remove(endNode);
            }

            if (startNode != null && endNode != null)
            {
                startNode.RemoveConnection(endNode);
                endNode.RemoveConnection(startNode);

                if (connectedNode1 != null && connectedNode2 != null)
                {
                    startNode.RemoveConnection(connectedNode1);
                    connectedNode1.RemoveConnection(startNode);

                    endNode.RemoveConnection(connectedNode2);
                    connectedNode2.RemoveConnection(endNode);
                }
            }
        }
Exemplo n.º 4
0
 public virtual void Apply()
 {
     if (((this.Start != null) && (this.End != null)) && (AstarPath.active != null))
     {
         GraphNode node  = AstarPath.active.GetNearest(this.Start.position).node;
         GraphNode node2 = AstarPath.active.GetNearest(this.End.position).node;
         if ((node != null) && (node2 != null))
         {
             if (this.deleteConnection)
             {
                 node.RemoveConnection(node2);
                 if (!this.oneWay)
                 {
                     node2.RemoveConnection(node);
                 }
             }
             else
             {
                 Int3 num2 = node.position - node2.position;
                 uint cost = (uint)Math.Round((double)(num2.costMagnitude * this.costFactor));
                 node.AddConnection(node2, cost);
                 if (!this.oneWay)
                 {
                     node2.AddConnection(node, cost);
                 }
             }
         }
     }
 }