Exemple #1
0
 public override FSMBasic moveToNextState()
 {
     if (theEMY == null || theEMY.isAlive == false)
     {
         //Debug.Log ("attack to search");
         FSM_Search search = new FSM_Search();
         search.makeState(this.theMoveController, this.theAttackLlinkController, this.theAnimator, this.theThis);
         return(search);
     }
     if (this.theThis.transform.position.y < this.theEMY.transform.position.y - 0.75)
     {
         //Debug.Log ("attack to jump");
         FSM_Jump jump = new FSM_Jump();
         jump.makeState(this.theMoveController, this.theAttackLlinkController, this.theAnimator, this.theThis, this.theEMY);
         return(jump);
     }
     if (Vector3.Distance(this.theThis.transform.position, this.theEMY.transform.position) > this.theThis.theAttackAreaLength * 0.8f)
     {
         //Debug.Log ("attack to runafter");
         FSM_RunAfter runafter = new FSM_RunAfter();
         runafter.makeState(this.theMoveController, this.theAttackLlinkController, this.theAnimator, this.theThis, this.theEMY);
         return(runafter);
     }
     return(this);
 }
Exemple #2
0
 public override FSMBasic moveToNextState()
 {
     if (this.theThis.transform.position.y >= this.theEMY.transform.position.y - 0.75 || timer < 0)
     {
         //Debug.Log ("jump to runafter");
         FSM_RunAfter runafter = new FSM_RunAfter();
         runafter.makeState(this.theMoveController, this.theAttackLlinkController, this.theAnimator, this.theThis, this.theEMY);
         return(runafter);
     }
     return(this);
 }
Exemple #3
0
    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);
    }
Exemple #4
0
 public override FSMBasic moveToNextState()
 {
     if (this.theAim == null || this.theAim.isAlive == false)
     {
         //Debug.Log ("attack to search");
         FSM_Search search = new FSM_Search();
         search.makeState(this.theMoveController, this.theAnimator, this.theThis, null);
         return(search);
     }
     if (Vector3.Distance(this.theMoveController.transform.position, this.theAim.transform.position) > this.theAttackLength * 0.8f)
     {
         //Debug.Log ("attack to runafter");
         FSM_RunAfter runafter = new FSM_RunAfter();
         runafter.makeState(this.theMoveController, this.theAnimator, this.theThis, this.theAim);
         runafter.OnChangeToThisState();
         return(runafter);
     }
     return(this);
 }
Exemple #5
0
    /// <summary>
    /// 强制显示生命条
    /// </summary>
    public void GotAim()
    {
        if (!thethis.theBloodSlider)
        {
            thethis.MakeHpSlider();
        }
        if (this.theStateNow is FSM_Search)
        {
            FSMBasic theStateNew = new FSM_RunAfter();
            theStateNew.makeState(this.theMoveController, this.theAnimator, theStateNow.theThis, theStateNow.theAim);
            theStateNew.setArea(attackarea, searchArea);

            if (theStateNew != theStateNow)
            {
                OnStateChange(theStateNow, theStateNew);
            }

            theStateNow = theStateNew;
        }
    }
Exemple #6
0
    //AI最简单的群体行为操作
    //一人追杀则群体追杀
    public override void OnChangeToThisState()
    {
        //Debug.Log("all move ");
        Collider [] AIs = Physics.OverlapSphere(this.theThis.transform.position, 1.3f);
        for (int i = 0; i < AIs.Length; i++)
        {
            FSMStage theStage = AIs [i].GetComponent <FSMStage> ();
            if (AIs [i].tag == "AI" && theStage)
            {
                if (theStage.theStateNow == null)
                {
                    return;
                }

                //ID = 4表示还在search,这个时候应该把自己的敌人通知给身边的单位
                if (theStage.theStateNow.geID() == 4 || theStage.theStateNow.geID() == 2)
                {
                    FSM_RunAfter runafter = new FSM_RunAfter();
                    theStage.moveTotheState(runafter, this.theEMY);
                }
            }
        }
    }