Exemplo n.º 1
0
        public void InflictDamage(Globals.EnemyCollision coll, Vector2 bulletForce, int damage)
        {
            _health -= damage;
            //HealthBar.fillAmount = _health / 100;
            coll.lastHit = Time.time;

            if (_health <= 0)
            {
                _isDead = true;

                Shooting.enabled  = false;
                _movement.enabled = false;
                _rb.AddForce(bulletForce * 100);

                _deathTime = Time.time;
                _anim.SetTrigger("death");

                if (GameEndDialog != null)
                {
                    GameEndDialog.SetActive(true);
                }

                Destroy(Shooting.gameObject);
            }
        }
Exemplo n.º 2
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.gameObject.layer == 8)
     {
         Globals.EnemyCollision coll = enemyCollisions.FirstOrDefault(colission => colission.obj.GetInstanceID() == other.gameObject.GetInstanceID());
         if (coll != null)
         {
             enemyCollisions.Remove(coll);
         }
     }
 }
Exemplo n.º 3
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (other.gameObject.layer == 8)
            {
                Globals.EnemyCollision coll = new Globals.EnemyCollision();
                coll.obj = other.gameObject;
                enemyCollisions.Add(coll);

                _health.InflictDamage(coll, Vector2.zero, Globals.Constants.ZOMBIE_DAMAGE);
            }
        }