예제 #1
0
        public override bool HandlerTrigger(FSMBase fsm)
        {
            if (fsm.targetTF == null)
            {
                return(false);
            }

            return(Vector3.Distance(fsm.transform.position, fsm.targetTF.position) <= fsm.chStates.attackDistance);
        }
예제 #2
0
 public override void ActionState(FSMBase fsm)
 {
     base.ActionState(fsm);
     if (atkTime <= Time.time)
     {
         fsm.skillSystem.UseRandomSkill();
         atkTime = Time.time + fsm.chStates.attacklnterval;
     }
 }
예제 #3
0
 /// <summary>
 /// 检测当前状态是否满足
 /// </summary>
 public void Reason(FSMBase fsm)
 {
     for (int i = 0; i < Triggers.Count; i++)
     {
         if (Triggers[i].HandlerTrigger(fsm))
         {
             //从映射表中获取输出状态
             FSMStateID StateID = map[Triggers[i].TriggerID];
             //切换状态
             fsm.ChangeActiveState(StateID);
             return;
         }
     }
 }
예제 #4
0
        //--循环 A=B=C=A.....
        private void LoopPatrolling(FSMBase fsm)
        {
            if (Vector3.Distance(fsm.transform.position, fsm.wayPoints[index].position) < 0.5f)
            {
//                 if (index == fsm.wayPoints.Length - 1)
//                 {
//
//                     index--;
//                 }
//                 index ++;
                index = (index + 1) % fsm.wayPoints.Length;
            }
            fsm.MoveToTarget(fsm.wayPoints[index].position, 0, fsm.walkSpeed);
        }
예제 #5
0
        //根据巡逻模式ABC都是数据,应在机里面找
        //--往返 A=B=C=B=A.....
        private void PingPongPatrolling(FSMBase fsm)
        {
            if (Vector3.Distance(fsm.transform.position, fsm.wayPoints[index].position) < 0.5f)
            {
                if (index == fsm.wayPoints.Length - 1)
                {
                    Array.Reverse(fsm.wayPoints);
                    index++;
                }

                index = (index + 1) % fsm.wayPoints.Length;
            }
            fsm.MoveToTarget(fsm.wayPoints[index].position, 0, fsm.walkSpeed);
        }
예제 #6
0
 //--单次 A-B-C
 private void OncePatrolling(FSMBase fsm)
 {
     if (Vector3.Distance(fsm.transform.position, fsm.wayPoints[index].position) < 0.5f)
     {
         if (index == fsm.wayPoints.Length - 1)
         {
             //完成巡逻
             fsm.IspatrolComplete = true;
             return;//退出
         }
         index++;
     }
     //fsm.wayPoints[2].position;
     fsm.MoveToTarget(fsm.wayPoints[index].position, 0, fsm.walkSpeed);
 }
예제 #7
0
        public override void ActionState(FSMBase fsm)
        {
            base.ActionState(fsm);
            switch (fsm.patrolMode)
            {
            case PatrolMode.Once:
                OncePatrolling(fsm);
                break;

            case PatrolMode.Loop:
                LoopPatrolling(fsm);
                break;

            case PatrolMode.PingPong:
                PingPongPatrolling(fsm);
                break;
            }
        }
예제 #8
0
 public virtual void ExitState(FSMBase fsm)
 {
 }
예제 #9
0
 public virtual void ActionState(FSMBase fsm)
 {
 }
예제 #10
0
 //为具体状态类提供可选事件
 public virtual void EnterState(FSMBase fsm)
 {
 }
예제 #11
0
 public override void ExitState(FSMBase fsm)
 {
     fsm.StopMove();
     base.ExitState(fsm);
     fsm.anim.SetBool(fsm.chStates.chParams.run, false);
 }
예제 #12
0
 public override void EnterState(FSMBase fsm)
 {
     base.EnterState(fsm);
     fsm.anim.SetBool(fsm.chStates.chParams.run, true);
 }
예제 #13
0
 public override void ExitState(FSMBase fsm)
 {
     base.ExitState(fsm);
     fsm.anim.SetBool(fsm.chStates.chParams.Idle, false);
 }
예제 #14
0
 public override bool HandlerTrigger(FSMBase fsm)
 {
     return(fsm.chStates.HP <= 0);
 }
예제 #15
0
 public override void EnterState(FSMBase fsm)
 {
     base.EnterState(fsm);
     //fsm.anim.SetBool(fsm.chStates.chParams.Death, true);
     fsm.enabled = false;
 }
예제 #16
0
 public override bool HandlerTrigger(FSMBase fsm)
 {
     return(fsm.targetTF.GetComponent <CharacterStatus>().HP <= 0);
 }
예제 #17
0
        //逻辑处理

        public abstract bool HandlerTrigger(FSMBase fsm);
예제 #18
0
 public override void ActionState(FSMBase fsm)
 {
     base.ActionState(fsm);
     //fsm.targetTF
     fsm.MoveToTarget(fsm.targetTF.position, fsm.chStates.attackDistance, fsm.runSpeed);
 }
예제 #19
0
 public override bool HandlerTrigger(FSMBase fsm)
 {
     return(fsm.targetTF != null);
 }
 public override bool HandlerTrigger(FSMBase fsm)
 {
     return(fsm.IspatrolComplete);
 }
예제 #21
0
 public override void EnterState(FSMBase fsm)
 {
     base.EnterState(fsm);
     fsm.IspatrolComplete = false;
     fsm.anim.SetBool(fsm.chStates.chParams.Walk, true);
 }