protected IEnumerator Patrolling() { currentState = EnemyStateTest.patrolling; while (true) { enemyMovement.Patrol(); yield return(new WaitForEndOfFrame()); } }
protected virtual void AttackPlayer() { hasDetectedPlayer = true; if (!playerIsInAttackDistance) { currentState = EnemyStateTest.chasing; } else { enemyShoot.AttemptToShoot(); } }
protected IEnumerator ChasePlayer() { currentState = EnemyStateTest.chasing; hasDetectedPlayer = true; if (!playerIsInStoppingDistance) { enemyMovement.MoveTowards(player); } else { enemyMovement.StopMoving(player); } yield return(new WaitForEndOfFrame()); }
internal virtual void CheckAndUpdateEnemyState() { if (!hasDetectedPlayer && currentState != EnemyStateTest.patrolling) { StartCoroutine(Patrolling()); } if (playerIsInAttackDistance && currentState != EnemyStateTest.attacking) { StopAllCoroutines(); currentState = EnemyStateTest.attacking; AttackPlayer(); } if (hasDetectedPlayer) { StopAllCoroutines(); StartCoroutine(ChasePlayer()); } }
private IEnumerator ResetBeingPushed() { yield return(new WaitForSecondsRealtime(durationOfPush)); currentState = EnemyStateTest.patrolling; }
public void Pushed() { currentState = EnemyStateTest.beingPushed; StopAllCoroutines(); StartCoroutine(ResetBeingPushed()); }