void CountAttacks() { numberOfAttacks++; if (numberOfAttacks >= statePatternEnemy.numberOfAttacks) { statePatternEnemy.ChangeState(new RedManChaseState(statePatternEnemy)); } }
public void UpdateState() { Movement player = statePatternEnemy.GetPlayer(); if (player != null) { statePatternEnemy.movement.MoveTowardsObject(player); if (Vector2.Distance(statePatternEnemy.transform.position, statePatternEnemy.player.transform.position) < statePatternEnemy.maxAttackDistance && statePatternEnemy.CanSeePlayer() && (Time.time - statePatternEnemy.lastAttackTime > statePatternEnemy.timeBetweenAttacks)) { statePatternEnemy.ChangeState(new AttackState(statePatternEnemy)); } else if ((Time.time - statePatternEnemy.lastAttackTime > 2 * statePatternEnemy.timeBetweenAttacks)) { statePatternEnemy.ChangeState(new AttackState(statePatternEnemy)); } } }
void CountAttacks() { numberOfAttacks++; Debug.Log("Attacked"); if (numberOfAttacks >= statePatternEnemy.numberOfAttacks) { statePatternEnemy.ChangeState(new ChaseState(statePatternEnemy)); } }
public void UpdateState() { Movement player = statePatternEnemy.GetPlayer(); if (player != null) { if (Vector2.Distance(statePatternEnemy.transform.position, statePatternEnemy.player.transform.position) < statePatternEnemy.minObserveDistance) { statePatternEnemy.ChangeState(new ChaseState(statePatternEnemy)); } } }
IEnumerator WaitRandomTime() { yield return(new WaitForSeconds(UnityEngine.Random.Range(min, max))); spe.ChangeState(new ChaseState(spe)); }