當前位置: 首頁>>代碼示例>>C#>>正文


C# Path.GetTotalLength方法代碼示例

本文整理匯總了C#中Pathfinding.Path.GetTotalLength方法的典型用法代碼示例。如果您正苦於以下問題:C# Path.GetTotalLength方法的具體用法?C# Path.GetTotalLength怎麽用?C# Path.GetTotalLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pathfinding.Path的用法示例。


在下文中一共展示了Path.GetTotalLength方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnPathComplete

 public void OnPathComplete(Path p)
 {
     if(p.error)
     {
         length = -1.0f;
     }
     else
     {
         length = p.GetTotalLength();
         startSearch();
     }
 }
開發者ID:kisank,項目名稱:AI-project,代碼行數:12,代碼來源:SCIENCE.cs

示例2: OnPathCompleted

 void OnPathCompleted(Path p)
 {
     if (p.error)
     {
         return;
     }
     pathToCursor = p.vectorPath;
     pathToCursorLength = Mathf.Lerp(Vector3.Distance(pathToCursor[0], pathToCursor[pathToCursor.Count - 1]), p.GetTotalLength(), 0.5f);
 }
開發者ID:Nachtrind,項目名稱:Fungus,代碼行數:9,代碼來源:GameInput.cs

示例3: WaitForPathCalculation

 private IEnumerator WaitForPathCalculation()
 {
     Debug.Log ("mAttackingObject.transform.position = " + mAttackingObject.transform.position);
     mAStarPath = mSeeker.StartPath(transform.position, mAttackingObject.transform.position, OnPathComplete);
     yield return StartCoroutine (mAStarPath.WaitForPath ());
     //float temppathlength = 0.0f;
     mNearestTargetPathLength = mAStarPath.GetTotalLength ();
     Debug.Log ("mNearestTargetPathLength = " + mNearestTargetPathLength);
     //mAStarPath.Claim (this);
 }
開發者ID:TonyTang1990,項目名稱:TonyTang1990_Unity_COC,代碼行數:10,代碼來源:Soldier.cs

示例4: OnPathChecked

    /**
     * Callback function that is triggered once the path has been computed for this alien
     **/
    public void OnPathChecked(Path p)
    {
        //Debug.Log ("Yey, we got a path back. Did it have an error? "+p.error);
        if (!p.error) {
            if(p != null) {
                //AstarAI aiMove = gameObject.GetComponent<AstarAI>();
                if(aiPath == null || p.GetTotalLength() < aiPath.GetTotalLength())
                    aiPath = p;
                    finalMarineTarget = currentMarineTarget;
                //unitStatus = UnitStatus.READY_TO_MOVE;
            }
        } else {
            // there was an error
            Debug.Log ("Yey, we got an alien path back but there was an error "+p.error);
        }

        // check the next marine to see if it has a shorter path
        GameObject marines = GameObject.Find("Marines");
        marineCheckCount ++;
        if(marineCheckCount < marines.transform.childCount) {
            ComputePath(gameObject.transform, marines);
        } else if (aiPath != null) {
            // no more marines, to check. lets go with the best one.
            unitStatus = UnitStatus.READY_TO_MOVE;
            Debug.Log("moving to marine= "+finalMarineTarget.name);
        } else {
            unitStatus = UnitStatus.MOVED;
        }
    }
開發者ID:mdeegler,項目名稱:xeno,代碼行數:32,代碼來源:AlienData.cs

示例5: __ReportPathNodes

        /// <summary>
        /// Prints info about the nodes of the AstarPath course.
        /// <remarks>The course the fleet follows is actually derived from path.VectorPath rather than path.path's collection
        /// of nodes that are printed here. The Seeker's StartEndModifier determines whether the closest node to the start 
        /// position is included or simply replaced by the exact start position.</remarks>
        /// </summary>
        /// <param name="path">The course.</param>
        private void __ReportPathNodes(Path path) {
            if (path.path.Any()) {
                float startToFirstNodeDistance = Vector3.Distance(Position, (Vector3)path.path[0].position);
                D.Log(ShowDebugLog, "{0}'s Destination is {1} at {2}. Start is {3} with Topography {4}. Distance to first AStar Node: {5:0.#}.",
                    DebugName, ApTarget.DebugName, ApTarget.Position, Position, _fleet.Topography.GetValueName(), startToFirstNodeDistance);
                float cumNodePenalties = 0F;
                string distanceFromPrevNodeMsg = string.Empty;
                GraphNode prevNode = null;
                path.path.ForAll(node => {
                    Vector3 nodePosition = (Vector3)node.position;
                    if (prevNode != null) {
                        distanceFromPrevNodeMsg = ", distanceFromPrevNode {0:0.#}".Inject(Vector3.Distance(nodePosition, (Vector3)prevNode.position));
                    }
                    if (ShowDebugLog) {
                        Topography topographyFromTag = __GetTopographyFromAStarTag(node.Tag);
                        D.Log("{0}'s Node at {1} has Topography {2}, penalty {3}{4}.",
                            DebugName, nodePosition, topographyFromTag.GetValueName(), (int)path.GetTraversalCost(node), distanceFromPrevNodeMsg);
                    }
                    cumNodePenalties += path.GetTraversalCost(node);
                    prevNode = node;
                });
                //float lastNodeToDestDistance = Vector3.Distance((Vector3)prevNode.position, ApTarget.Position);
                //D.Log(ShowDebugLog, "{0}'s distance from last AStar Node to Destination: {1:0.#}.", DebugName, lastNodeToDestDistance);

                if (ShowDebugLog) {
                    // calculate length of path in units scaled by same factor as used in the rest of the system
                    float unitLength = path.GetTotalLength();
                    float lengthCost = unitLength * Int3.Precision;
                    float totalCost = lengthCost + cumNodePenalties;
                    D.Log("{0}'s Path Costs: LengthInUnits = {1:0.#}, LengthCost = {2:0.}, CumNodePenalties = {3:0.}, TotalCost = {4:0.}.",
                        DebugName, unitLength, lengthCost, cumNodePenalties, totalCost);
                }
            }
            else {
                D.Warn("{0}'s course from {1} to {2} at {3} has no AStar Nodes.", DebugName, Position, ApTarget.DebugName, ApTarget.Position);
            }
        }
開發者ID:Maxii,項目名稱:CodeEnv.Master,代碼行數:44,代碼來源:FleetCmdItem.cs

示例6: OnPathingComplete

    private void OnPathingComplete(Path path)
    {
        if (path.error == false)
        {
            if (_path != null)
            {
                _path.Release(this);
            }

            _path = path;
            _path.Claim(this);

            _pathIndex = 0;
            //Update distanec to objective.
            this.DistanceToObjective = _path.GetTotalLength();
        }
    }
開發者ID:Axuim,項目名稱:Tower-Defense,代碼行數:17,代碼來源:Enemy.cs


注:本文中的Pathfinding.Path.GetTotalLength方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。