private void OnTakeDamage(float arg1, float arg2) { if (_enemyStates == Enemystates.dead) { return; } if (_lifeSlider) { _lifeSlider.value = arg2; } if (arg2 <= 0) { //_isDead = true; _enemyStates = Enemystates.dead; if (_animationComponent) { _animationComponent.Die(); } if (UIController.Instance) { UIController.Instance.AddMessage("Enemy killed"); } _navMeshAgent.destination = transform.position; Invoke("Die", 1f); } else { if (_animationComponent) { _animationComponent.Hit(); } _navMeshAgent.destination = transform.position; //_isDead = true; _enemyStates = Enemystates.damaged; Invoke("HitEnd", .5f); } }
public void Initialize(Transform player, Vector3 pos, Quaternion rot) { //_isDead = false; _enemyStates = Enemystates.normal; if (_animationComponent) { _animationComponent.Run(); } gameObject.SetActive(true); transform.position = pos; transform.rotation = rot; Player = player; if (_lifeSlider) { _lifeSlider.maxValue = _lifeSlider.value = _health; _lifeSlider.minValue = 0; } if (_heathComponent) { _heathComponent.CurrentLifeValue = _health; } }
private void HitEnd() { //_isDead = false; _enemyStates = Enemystates.normal; }