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); }
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); }
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); } }