Example #1
0
        private void DealAreaDamage(Core.GameObject toIgnore)
        {
            List <BaseAlien> aliens = SceneManager.Instance.currScene.GetObjectsByClass <Assets.Objects.BaseAlien>();

            foreach (BaseAlien alien in aliens)
            {
                if (toIgnore == alien)
                {
                    continue;
                }

                float distance = (alien.transform.position - transform.position).Length();
                if (distance > areaRange)
                {
                    continue;
                }

                Gameplay.Health health = alien.GetComponent <Gameplay.Health>();
                if (health == null)
                {
                    continue;
                }


                health.DealDamage(new Gameplay.DamageInfo()
                {
                    damageDealer = Damage.damageDealer, value = (int)(Damage.value * 0.5)
                });
            }

            RocketExplosion explosion = new RocketExplosion(new Transform(transform));

            GameManager.SpawnObject(explosion);
        }
Example #2
0
 protected virtual void OnHit(Collider thisCollider, Collider otherCollider)
 {
     Gameplay.Health enemyHealth = otherCollider.Parent.GetComponent <Gameplay.Health>();
     if (enemyHealth != null)
     {
         enemyHealth.DealDamage(Damage);
     }
     else
     {
         return;
     }
     Destroy();
 }