当前位置: 首页>>代码示例>>C#>>正文


C# NavMeshPath.GetCornersNonAlloc方法代码示例

本文整理汇总了C#中UnityEngine.NavMeshPath.GetCornersNonAlloc方法的典型用法代码示例。如果您正苦于以下问题:C# NavMeshPath.GetCornersNonAlloc方法的具体用法?C# NavMeshPath.GetCornersNonAlloc怎么用?C# NavMeshPath.GetCornersNonAlloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.NavMeshPath的用法示例。


在下文中一共展示了NavMeshPath.GetCornersNonAlloc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateDestination

    public override void CalculateDestination(Transform playerDestination)
    {
        Flowchart flow = GameObject.FindGameObjectWithTag ("Player").GetComponent<capsule>().flow;
        if (b1 && flow.GetIntegerVariable ("Blops1") < 0) {
            destination = GameObject.Find ("Blop1").transform.position;
            b1 = false;
            timeBeforeUpdate = 500;
        }
        else if (b2 && flow.GetIntegerVariable ("Blops2") < 0) {
            destination = GameObject.Find ("Blop2").transform.position;
            b2 = false;
            timeBeforeUpdate = 500;
        }
        else if (b3 && flow.GetIntegerVariable ("Blop3") < 0) {
            destination = GameObject.Find ("Blop3").transform.position;
            b3 = false;
            timeBeforeUpdate = 500;
        }
        else{
            timeBeforeUpdate = 50;
            Vector3 PDest = iapos;
            if(playerDestination != null)
                PDest = playerDestination.position;
            destination = iapos;
            NavMeshPath path = new NavMeshPath ();
            Transform player = GameObject.FindGameObjectWithTag ("Player").transform;
            NavMesh.CalculatePath (player.position, PDest , NavMesh.AllAreas, path);
            Vector3[] corners = new Vector3[100];
            int nbCorners = path.GetCornersNonAlloc (corners);
            GameObject[] obstacleSwitchs = GameObject.FindGameObjectsWithTag ("ObstacleSwitch");
            float initialDist = 0.0f;
            for (int i = 1; i < nbCorners; i++) {
                Vector3 diff = corners [i] - corners [i - 1];
                initialDist += diff.magnitude;
            }
            Debug.Log (initialDist);
            float nextDist = 0.0f;
            foreach (GameObject go in obstacleSwitchs) {
                nextDist = 0.0f;
                GameObject obstacle = go.GetComponent<Obstacle> ().obstacle;
                obstacle.SetActive (!obstacle.activeSelf);
                NavMesh.CalculatePath (player.position, iapos, 1, path);
                Vector3[] corners2 = new Vector3[1000];
                nbCorners = path.GetCornersNonAlloc (corners2);
                for (int i = 1; i < nbCorners; i++) {
                    Vector3 diff = corners2 [i] - corners2 [i - 1];
                    nextDist += diff.magnitude;
                }
                obstacle.SetActive (!obstacle.activeSelf);
                if ((nextDist > initialDist && flow.GetIntegerVariable("SferBleus")<0) ||
                    (nextDist < initialDist && flow.GetIntegerVariable("SferBleus")>0)	){

                    destination = go.transform.position;
                    initialDist = nextDist;
                }

            }
            //Debug.Log (nbCorners);

        }
    }
开发者ID:rstruk,项目名称:ProjetLaby,代码行数:61,代码来源:AllyComportement.cs


注:本文中的UnityEngine.NavMeshPath.GetCornersNonAlloc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。