Ejemplo n.º 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <Rigidbody>() != null && other.gameObject != this && other.isTrigger)
        {
            Rigidbody targetRigidBody = other.GetComponent <Rigidbody>();
            if (targetRigidBody.GetComponent <CarHealth>() != null)
            {
                CarHealth targetCarHealth = targetRigidBody.GetComponent <CarHealth>();

                if (isShielded)
                {
                    if (!targetCarHealth.isShielded)
                    {
                        targetCarHealth.TakeCollisionDamage(2 * collisionDamage);
                    }
                    else
                    {
                        targetCarHealth.RemoveShield();
                    }
                }
                else
                {
                    if (!targetCarHealth.isShielded)
                    {
                        targetCarHealth.TakeCollisionDamage(collisionDamage);
                    }
                    else
                    {
                        targetCarHealth.RemoveShield();
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <CarMovement>() != null && other.isTrigger)
     {
         CarHealth targetCarHeath = other.GetComponent <CarHealth>();
         if (targetCarHeath.IsShielded())
         {
             targetCarHeath.RemoveShield();
             Destroy(gameObject);
         }
         else
         {
             CarMovement targetCarMovement = other.GetComponent <CarMovement>();
             targetCarMovement.SetCatOn();
         }
     }
 }
Ejemplo n.º 3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <Rigidbody>() != null && other.isTrigger)
     {
         CarHealth targetCarHeath = other.GetComponent <CarHealth>();
         if (targetCarHeath.IsShielded())
         {
             targetCarHeath.RemoveShield();
         }
         else
         {
             Rigidbody rigidbody     = other.GetComponent <Rigidbody>();
             Rigidbody thisRigidBody = GetComponent <Rigidbody>();
             rigidbody.AddForce(thisRigidBody.velocity * 10, ForceMode.Force);
             Destroy(gameObject);
         }
     }
 }