예제 #1
0
 //找下一个点及对应的表现
 private void FindNextNode()
 {
     if (Vector3.Distance(transform.position, _targetVec) < 0.1f)
     {
         index++;
         if (index >= points.Length - 1)
         {
             index = points.Length - 1;
         }
         _targetVec = points[index];
         _Action    = MyAction[index - 1];
     }
 }
예제 #2
0
 //表现
 void ChangeAction()
 {
     //如果当前目标点有变化
     if (_Action.type != _last.type)
     {
         _last = _Action;
         //如果是移动
         if (_Action.type == ZActionType.move)
         {
             OnActionMove();
         }
         else if (_Action.type == ZActionType.stop)
         {
             isStop = true;
             OnActionStop();
         }
     }
 }
예제 #3
0
        private bool isStop;        //是否停止

        void Init()
        {
            index  = 0;
            points = path.nodes.ToArray();
            for (int i = 0; i < points.Length; i++)
            {
                points[i] += new Vector3(UnityEngine.Random.Range(-path.radius, path.radius), UnityEngine.Random.Range(-path.radius, path.radius), UnityEngine.Random.Range(-path.radius, path.radius));
            }
            _targetVec    = points[index];
            findNextPoint = true;
            arrive        = false;
            _Action       = MyAction[0];
            _last         = _Action;
            isStop        = false;
            if (MyAction.Length < points.Length)
            {
                Debug.LogWarning("设置的动作数少于路径的点数");
            }
            OnPathStart();
        }