コード例 #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_RunAfter.cs プロジェクト: BXZR/Sword
 public override FSMBasic moveToNextState()
 {
     //为了确保能真的攻击到,留下多余空间
     //this.theThis.theAttackAreaLength*1.5f在没有遇到之前就开始会挥舞兵器了
     //至于移动就在于navMeshAgent了
     if (Vector3.Distance(this.theThis.transform.position, this.theEMY.transform.position) <= this.theThis.theAttackAreaLength * 1.5f)
     {
         //Debug.Log ("runafter to attack");
         FSM_Attack attack = new FSM_Attack();
         attack.makeState(this.theMoveController, this.theAttackLlinkController, this.theAnimator, this.theThis, this.theEMY);
         return(attack);
     }
     if (this.theThis.transform.position.y < this.theEMY.transform.position.y - 0.75)
     {
         //Debug.Log ("runafter to jump");
         FSM_Jump jump = new FSM_Jump();
         jump.makeState(this.theMoveController, this.theAttackLlinkController, this.theAnimator, this.theThis, this.theEMY);
         return(jump);
     }
     //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.theAttackLlinkController, this.theAnimator, this.theThis);
         return(search);
     }
     return(this);
 }
コード例 #3
0
 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.theAttackLlinkController, this.theAnimator, this.theThis, this.theMainEMY);
         return(attack);
     }
 }
コード例 #4
0
ファイル: FSMStage.cs プロジェクト: BXZR/Sword
    public FSMBasic getState(int ID)
    {
        for (int i = 0; i < theStatesSaved.Count; i++)
        {
            if (theStatesSaved [i].geID() == ID)
            {
                return(theStatesSaved [i]);
            }
        }

        FSMBasic theOne = new FSMBasic();

        switch (ID)
        {
        case 1:
        {
            theOne = new FSM_Attack();
            theStatesSaved.Add(theOne);
        }
        break;

        case 2:
        {
            theOne = new FSM_Jump();
            theStatesSaved.Add(theOne);
        }
        break;

        case 3:
        {
            theOne = new FSM_RunAfter();
            theStatesSaved.Add(theOne);
        }
        break;

        case 4:
        {
            theOne = new FSM_Search();
            theStatesSaved.Add(theOne);
        }
        break;
        }
        return(theOne);
    }