Пример #1
0
        protected void OnCollisionEnter(Collision collision)
        {
            // Collision, Projectile hit something

            IHealth damageReceiver =
                collision.gameObject.GetComponentInChildren <IHealth> ();

            if (damageReceiver != null)
            {
                // Colliding object can take damage
                damageReceiver.TakeDamage(_damage);

                // TODO: Instantiate effect
                // TODO: Add sound effect

                _shooter.ProjectileHit(this);
            }
        }
Пример #2
0
        // This is used to clean projectiles up after they
        // have exitted camera's viewport.
        protected void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.layer == LayerMask.NameToLayer("Destroyer"))
            {
                _shooter.ProjectileHit(this);
                return;
            }

            // Collision, Projectile hit something

            IHealth damageReceiver =
                other.gameObject.GetComponentInChildren <IHealth>();

            if (damageReceiver != null)
            {
                // Colliding object can take damage
                damageReceiver.TakeDamage(_damage);

                // TODO: Instantiate effect
                // TODO: Add sound effect

                _shooter.ProjectileHit(this);
            }
        }
Пример #3
0
 private void Explode()
 {
     ApplyDamage();
     InstantiateEffect();
     _shooter.ProjectileHit(this);
 }