Exemplo n.º 1
0
 protected IEnumerator Patrolling()
 {
     currentState = EnemyStateTest.patrolling;
     while (true)
     {
         enemyMovement.Patrol();
         yield return(new WaitForEndOfFrame());
     }
 }
Exemplo n.º 2
0
 protected virtual void AttackPlayer()
 {
     hasDetectedPlayer = true;
     if (!playerIsInAttackDistance)
     {
         currentState = EnemyStateTest.chasing;
     }
     else
     {
         enemyShoot.AttemptToShoot();
     }
 }
Exemplo n.º 3
0
 protected IEnumerator ChasePlayer()
 {
     currentState      = EnemyStateTest.chasing;
     hasDetectedPlayer = true;
     if (!playerIsInStoppingDistance)
     {
         enemyMovement.MoveTowards(player);
     }
     else
     {
         enemyMovement.StopMoving(player);
     }
     yield return(new WaitForEndOfFrame());
 }
Exemplo n.º 4
0
 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());
     }
 }
Exemplo n.º 5
0
        private IEnumerator ResetBeingPushed()
        {
            yield return(new WaitForSecondsRealtime(durationOfPush));

            currentState = EnemyStateTest.patrolling;
        }
Exemplo n.º 6
0
 public void Pushed()
 {
     currentState = EnemyStateTest.beingPushed;
     StopAllCoroutines();
     StartCoroutine(ResetBeingPushed());
 }