Пример #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (!other.isTrigger)
     {
         IHealthController target = other.gameObject.GetInterface <IHealthController>();
         if (target != null)
         {
             target.Damage(damage);
             hitBox.enabled = false;
         }
     }
 }
Пример #2
0
    private void OnCollisionEnter(Collision collision)
    {
        Boat waterObject = collision.gameObject.GetComponentInParent <Boat>();

        if (waterObject != null /* && firedBy != waterobject*/)
        {
            waterObject.Velocity.v += (shotPosition - collision.transform.position).normalized * cannonBallForce / 10;
            waterObject.Mass       += 100;
            Destroy(this);
        }
        else
        {
            IHealthController h = collision.gameObject.GetInterface <IHealthController>();
            if (h != null)
            {
                h.Damage(15);
                Destroy(this);
            }
        }
    }