当前位置: 首页>>代码示例>>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;未经允许,请勿转载。