public override void Action(BaseFSM basefsm)
        {
            basefsm.PlayAnimation(basefsm.animParams.Walk);
            basefsm.MoveToTarget(basefsm.wayPoints[currentWayPoint].position, basefsm.walkSpeed, basefsm.patrolArrivalDistance);
            //1.是否到达当前路点
            if (Vector3.Distance(basefsm.transform.position, basefsm.wayPoints[currentWayPoint].position) < basefsm.patrolArrivalDistance)
            {
                //2.是否是最后一个路点
                if (currentWayPoint == basefsm.wayPoints.Length - 1)
                {
                    //根据巡逻的方式决定结束或开始
                    switch (basefsm.patrolMode)
                    {
                    case PatrolMode.Once:
                        basefsm.isPatrolComplete = true;
                        return;

                    case PatrolMode.PingPong:
                        break;

                    case PatrolMode.Loop:
                        currentWayPoint = 0;
                        break;
                    }
                }
                currentWayPoint += 1;
            }
        }
Beispiel #2
0
 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.PlayAnimation(fsm.animParams.Walk);
 }
Beispiel #3
0
        public override void Action(BaseFSM basefsm)
        {
            basefsm.PlayAnimation(basefsm.animParams.Dead);
            basefsm.StopMove();

            basefsm.enabled = false; //死亡动画播放完毕后不再进入别的状态
        }
Beispiel #4
0
 public override void EnterState(BaseFSM fsm)
 {
     if (attackTime == 0)
     {
         attackTime = fsm.chStatus.attackSpeed;
     }
     fsm.PlayAnimation(fsm.animParams.FightIdle);
 }
Beispiel #5
0
 public override void Action(BaseFSM fsm)
 {
     //播放跑动画
     if (fsm.targetPlayer != null && fsm.targetPlayer.gameObject != null)
     {
         fsm.PlayAnimation(fsm.animParams.Run);
         fsm.MoveToTarget(fsm.targetPlayer.position, fsm.MoveSpeed, fsm.RotationSpeed);
     }
 }
Beispiel #6
0
 public override void Action(BaseFSM fsm)
 {
     if (fsm.targetObject != null)
     {
         fsm.MoveToTarget(
             fsm.targetObject.transform.position,
             fsm.moveSpeed,
             fsm.chStatus.chBase.attackDistance);
         // 播放响应的动画
         fsm.PlayAnimation(fsm.animParams.Run);
     }
 }
Beispiel #7
0
        public override void Action(BaseFSM fsm)
        {
            //盯住玩家
            TransformHelper.LookAtTarget(fsm.targetPlayer.position - fsm.transform.position, fsm.transform, fsm.RotationSpeed);

            if (attackTime <= 0)
            {
                attackTime = fsm.chStatus.attackSpeed;
                fsm.PlayAnimation(fsm.animParams.Attack);
                fsm.RandomAttack();
            }
            attackTime -= Time.deltaTime;
        }
Beispiel #8
0
        public override void Action(BaseFSM basefsm)
        {
            //1.条件需要有追逐的目标
            if (basefsm.targetObj != null)
            {
                //2.播放追逐动画
                basefsm.PlayAnimation(basefsm.animParams.Run);
                basefsm.MoveToTarget(basefsm.targetObj.position, basefsm.moveSpeed, basefsm.chState.attackDistance);

                //3.主要控制追的速度,靠近的距离==攻击距离
            }
            else
            {
                return;
            }
        }
Beispiel #9
0
 public override void OnStateExit(BaseFSM fsm)
 {
     fsm.PlayAnimation(AnimationName.idle);
 }
 public override void OnStateEnter(BaseFSM fsm)
 {
     fsm.PlayAnimation(AnimationName.death);
 }
Beispiel #11
0
 public override void OnStateEnter(BaseFSM fsm)
 {
     fsm.PlayAnimation(AnimationName.beAttack);
 }
Beispiel #12
0
 public override void OnStateEnter(BaseFSM fsm)
 {
     fsm.PlayAnimation(AnimationName.runForward);
     fsm.audioSource.Play();
 }
Beispiel #13
0
 public override void OnStateExit(BaseFSM fsm)
 {
     fsm.audioSource.Stop();
     fsm.PlayAnimation(AnimationName.idle);
 }
 public override void Action(BaseFSM fsm)
 {
     //播放动画
     fsm.PlayAnimation(AnimationName.idle);
     Debug.Log("进入Idle状态");
 }
Beispiel #15
0
 public override void Action(BaseFSM basefsm)
 {
     //播放待机动画
     basefsm.PlayAnimation(basefsm.animParams.Idle);
 }
Beispiel #16
0
 public override void EnterState(BaseFSM basefsm)
 {
     basefsm.StopMove();
     basefsm.PlayAnimation(basefsm.animParams.Idle);
 }
Beispiel #17
0
 public override void EnterState(BaseFSM fsm)
 {
     fsm.PlayAnimation(fsm.animParams.Dead);
 }
Beispiel #18
0
 public override void Action(BaseFSM fsm)
 {
     //播待机动画
     fsm.PlayAnimation(fsm.animParams.Idle);
 }