public override void Action(BaseFSM fsm)
 {
     //判断是否到达路点
     if (Vector3.Distance(fsm.transform.position,
                          fsm.PatrolWayPoints[currentWayPointIndex].position) < arrivalDistance)
     {
         if (currentWayPointIndex == fsm.PatrolWayPoints.Length - 1)
         {
             if (fsm.patrolMode == PatrolMode.Once)//单程
             {
                 patrolComplete       = true;
                 currentWayPointIndex = 0;
                 return;
             }
             //结束巡逻
             else if (fsm.patrolMode == PatrolMode.PingPong)
             {
                 Array.Reverse(fsm.PatrolWayPoints);
             }
         }
         //到 : 换下一个路点
         currentWayPointIndex += 1;
         currentWayPointIndex  = currentWayPointIndex % fsm.PatrolWayPoints.Length;
     }
     currentWayPoint = fsm.PatrolWayPoints[currentWayPointIndex];
     fsm.MoveToTarget(currentWayPoint.position, fsm.walkSpeed, fsm.RotationSpeed, arrivalDistance);
     //播动画
     fsm.PlayeAnimation(fsm.animParams.Walk);
 }
Exemple #2
0
    public override void Action(BaseFSM fsm)
    {
        if (fsm.targetObject == null)
        {
            return;
        }
        //位移

        //播放跑动画
        if (fsm.targetPlayer != null && fsm.targetPlayer.gameObject != null)
        {
            fsm.PlayeAnimation(fsm.animParams.Run);
            fsm.MoveToTarget(fsm.targetPlayer.position, fsm.MoveSpeed, fsm.RotationSpeed);
        }
    }
Exemple #3
0
 public override void Action(BaseFSM fsm)
 {
     fsm.MoveToTarget((Vector3)fsm.GotoPosition,
                      fsm.runSpeed, fsm.arrivalWPDistance);
 }