// Update is called once per frame void Update() { /* * if (Input.GetKey(KeyCode.Alpha1)) * { * enemyIsIdle(); * } * * if (Input.GetKey(KeyCode.Alpha2)) * { * enemyIsChasing(); * } * * if (Input.GetKey(KeyCode.Alpha3)) * { * enemyIsAttacking(); * } * * if (Input.GetKey(KeyCode.Alpha4)) * { * enemyIsDead(); * } */ if (Input.GetKeyDown(KeyCode.Space)) { eStat.TakeDamage(5, 1); Debug.Log(eStat.currentHealth); } }
protected void Damage(Transform enemy) { EnemyStat e = enemy.GetComponent <EnemyStat>(); if (e != null) { e.TakeDamage(damage); } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Enemy")) { EnemyStat stat = collision.gameObject.GetComponent <EnemyStat>(); if (stat) { stat.TakeDamage(1); } } }
void OnTriggerEnter(Collider collider) { if (collider.transform.CompareTag("Enemy")) { EnemyStat stat = collider.transform.gameObject.GetComponent <EnemyStat>(); if (stat) { stat.TakeDamage(1); } Destroy(gameObject); } }
public void TakeDamage(int amount) { enemyStats.TakeDamage(amount); UpdateHealthSlider(); }