Пример #1
0
    public void OnBulletCollision(Collider collider)
    {
        // Check bullet source
        BulletSystem bullet = collider.GetComponent<BulletSystem>();
        if (bullet.shooter != this.gameObject)
        {
            // Take damage
            healthSystem.TakeDamage(bullet.damage);

            bool destroyBullet = true;

            // Check for bullet type
            switch (bullet.type)
            {
                case BaseWeapon.BulletType.Piercing:
                    destroyBullet = false;
                    break;
                case BaseWeapon.BulletType.Fire:
                    break;
                case BaseWeapon.BulletType.Ice:
                    break;
                default:
                    break;
            }

            if (destroyBullet)
                bullet.Destroy();
        }
    }
Пример #2
0
 private void OnCollision(Collider collider)
 {
     if (collider.tag == "Bullet")
     {
         // Collision between 2 bullet destroys them
         BulletSystem bullet = collider.GetComponent <BulletSystem>();
         if (bullet.shooter == shooter)
         {
             bullet.Destroy();
             this.Destroy();
         }
     }
 }