public override FSMBasic moveToNextState(FSMStage theContrtoller) { //找不到目标就继续找 if (theMainEMY == null) { return(this); } //找到了目标就转到下一个状态 else { //Debug.Log ("search to attack"); FSMBasic attack = theContrtoller.getState(1); attack.makeState(this.theMoveController, this.theAttackLlinkController, this.theAnimator, this.theThis, this.theMainEMY); return(attack); } }
//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); } } } }
public virtual FSMBasic moveToNextState(FSMStage theController) { return(this); }
void Start() { theStage = this.GetComponentInParent <FSMStage> (); }