コード例 #1
0
 public override FSMBasic moveToNextState()
 {
     //为了确保能真的攻击到,留下多余空间
     //this.theThis.theAttackAreaLength*1.5f在没有遇到之前就开始会挥舞兵器了
     //至于移动就在于navMeshAgent了
     if (this.theAim && Vector3.Distance(this.theMoveController.transform.position, this.theAim.transform.position) <= this.theAttackLength * 1.5f)
     {
         //Debug.Log ("runafter to attack");
         FSM_Attack attack = new FSM_Attack();
         attack.makeState(this.theMoveController, this.theAnimator, this.theThis, this.theAim);
         attack.OnChangeToThisState();
         return(attack);
     }
     //没找到目标。这个状态损失得更快
     if (!theAim)
     {
         timer -= Time.deltaTime;
     }
     //Debug.Log ("theEMY name is "+ theEMY.name);
     if (timer < 0)
     {
         //Debug.Log ("runafter to search");
         FSM_Search search = new FSM_Search();
         search.makeState(this.theMoveController, this.theAnimator, this.theThis, this.theAim);
         search.OnChangeToThisState();
         return(search);
     }
     return(this);
 }
コード例 #2
0
ファイル: FSM_Search.cs プロジェクト: BXZR/StudentFinal
 public override FSMBasic moveToNextState()
 {
     //找不到目标就继续找
     if (theMainEMY == null)
     {
         return(this);
     }
     //找到了目标就转到下一个状态
     else
     {
         //Debug.Log ("search to attack");
         FSM_Attack attack = new FSM_Attack();
         attack.makeState(this.theMoveController, this.theAnimator, this.theThis, theMainEMY);
         attack.OnChangeToThisState();
         return(attack);
     }
 }