private void FixedUpdate() { switch (_currentState) { case AIStage.WAITING: _currentCountdown -= Time.deltaTime; _rb.velocity = Vector2.zero; if (_currentCountdown <= 0f) { _currentCountdown = Random.Range(waitTime / 4, waitTime); _currentState = AIStage.WALKING; _direction = (player.transform.position - transform.position).normalized; _direction = _scared ? -_direction : _direction; } break; case AIStage.WALKING: _currentCountdown -= Time.deltaTime; Move(_direction.x, _direction.y); if (_currentCountdown <= 0f) { _currentCountdown = Random.Range(waitTime / 4, waitTime); _currentState = AIStage.WAITING; } break; default: break; } }
internal override void Awake() { base.Awake(); _currentState = AIStage.WAITING; _scared = false; }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { _currentCountdown = Random.Range(waitTime / 4, waitTime); _currentState = AIStage.WAITING; if (collision.gameObject.GetComponent <Player_Script>()._raging) { GetComponent <Collider2D>().enabled = false; GetComponent <SpriteRenderer>().sprite = deadSprite; _rb.velocity = Vector2.zero; _currentState = AIStage.DEAD; } } }
void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Projectile") { Destroy(coll.gameObject); health -= 1; if (health < stage3Health && _AIStage == AIStage.Stage2) { _AIStage = AIStage.Stage3; fireRate = stage3FireRate; _AIPos = AIPos.TL; _stage3Target = _stage3TL; } else if (health < stage2Health && _AIStage == AIStage.Stage1) { _AIStage = AIStage.Stage2; _delay = 1.0f; } } }