public override void DoAction(BaseBrain brain) { brain.changeStatePossible = false; brain.ResetAnimatorState(); brain.animator.SetBool("AttackB", true); }
public override void Init(BaseBrain brain) { brain.SetNavMeshSpeed(brain.normalSpeed); brain.ResetAnimatorState(); brain.animator.SetBool("PatrolB", true); }
private IEnumerator AttackBehaviour(BaseBrain brain) { int actionId = 0; IEnumerator action = null; bool executeNextAction = true; while (brain.Target != null) { //Check distance if (Vector3.Distance(brain.transform.position, brain.Target.transform.position) > brain.navMeshAgent.stoppingDistance) { brain.ChangeState(typeof(BaseChaseState)); } if (executeNextAction) { action = action.ActWithDelay(() => actions[actionId].DoAction(brain), //execute next action state => executeNextAction = state, //Check if execution complete 0, //time delay before attackInterval[actionId]); //time delay after brain.StartCoroutine(action); actionId = (actionId + 1) % actions.Length; executeNextAction = false; } yield return(null); } brain.StopCoroutine(action); brain.changeStatePossible = true; yield return(null); brain.ChangeState(typeof(BaseTargetLostState)); }
// Start is called before the first frame update void Start() { thisTransform = GetComponent <Transform>(); brain = GetComponent <BaseBrain>(); thisRigid = GetComponent <Rigidbody>(); health = healthBar.GetComponent <HealthBar>(); health.parentTransform = thisTransform; health.maxHealth = 300; UpdateVisuals(); }
public override void DoAction(BaseBrain brain) { if (brain.Target == null) { brain.ChangeState(typeof(BaseWanderState)); return; } brain.navMeshAgent.SetDestination(brain.Target.transform.position); if (brain.navMeshAgent.remainingDistance <= brain.navMeshAgent.stoppingDistance) { brain.ChangeState(typeof(BaseAttackState)); return; } }
public override void Exit(BaseBrain brain) { brain.changeStatePossible = true; brain.StopCoroutine(attackBehaviour); }
public override void Execute(BaseBrain brain) { }
private float[] attackInterval; //time prepare attack, attack public override void Init(BaseBrain brain) { attackInterval = new float[] { prepareAttackTime, attackTime }; attackBehaviour = AttackBehaviour(brain); brain.StartCoroutine(attackBehaviour); }
public abstract void DoAction(BaseBrain brain);
public override void Init(BaseBrain brain) { brain.ResetAnimatorState(); brain.animator.SetBool("PatrolB", true); }
void TargetLostAnimation(BaseBrain brain) { brain.ResetAnimatorState(); brain.animator.SetBool("TargetLostB", true); }
public override void Exit(BaseBrain brain) { brain.StopCoroutine(searchTarget); brain?.StopCoroutine(targetLost); }
public override void Init(BaseBrain brain) { searchTarget = searchTarget.DoWhile(1.5f, null, () => brain.StartCoroutine(targetLost)); targetLost = targetLost.DoWhile(3, () => TargetLostAnimation(brain), () => brain.ChangeState(typeof(BaseWanderState))); brain.StartCoroutine(searchTarget); }
public override void DoAction(BaseBrain brain) { }