Example #1
0
    // 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);
        }
    }
Example #2
0
    protected void Damage(Transform enemy)
    {
        EnemyStat e = enemy.GetComponent <EnemyStat>();

        if (e != null)
        {
            e.TakeDamage(damage);
        }
    }
Example #3
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Enemy"))
     {
         EnemyStat stat = collision.gameObject.GetComponent <EnemyStat>();
         if (stat)
         {
             stat.TakeDamage(1);
         }
     }
 }
Example #4
0
 void OnTriggerEnter(Collider collider)
 {
     if (collider.transform.CompareTag("Enemy"))
     {
         EnemyStat stat = collider.transform.gameObject.GetComponent <EnemyStat>();
         if (stat)
         {
             stat.TakeDamage(1);
         }
         Destroy(gameObject);
     }
 }
Example #5
0
 public void TakeDamage(int amount)
 {
     enemyStats.TakeDamage(amount);
     UpdateHealthSlider();
 }