public virtual void Die() { if (state != DamagableState.Alive) { return; } state = DamagableState.Dying; _deathCounter = 0; if (deathSound) { AudioSource.PlayClipAtPoint(deathSound, transform.position); } }
// Update is called once per frame protected virtual void Update() { switch (state) { case DamagableState.Dead: return; case DamagableState.Dying: _deathCounter += Time.deltaTime; if (_deathCounter > deathTime) { state = DamagableState.Dead; OnDeath(); } break; case DamagableState.Alive: UpdateAlive(); break; } }