void Update()
    {
        RaycastHit hit;

        if (timer > 0)
        {
            timer -= Time.deltaTime;
            Collider[] cols = Physics.OverlapSphere(transform.position, 15f, myMask);
            for (int i = 0; i < cols.Length; i++)
            {
                Rigidbody targetRigidBody = cols [i].GetComponent <Rigidbody> ();

                if (!targetRigidBody)
                {
                    AllyDroneScript allyDrone = cols[i].GetComponentInParent <AllyDroneScript>();
                    if (allyDrone != null)
                    {
                        allyDrone.currentPower -= damage;
                    }
                    continue;
                }
                targetRigidBody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius, 3f, ForceMode.Impulse);

                if (targetRigidBody != null)
                {
                    PlayerHealth1 playerHealth = targetRigidBody.GetComponent <PlayerHealth1> ();
                    if (playerHealth != null)
                    {
//						Debug.Log ("Reached It");
                        playerHealth.TakeDamage(damage);
                        playerHealth = null;
                        return;
                    }
                }
            }
        }
    }
Example #2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Head")
     {
         BlockCharacterLife blockCharLife = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
         if (blockCharLife != null)
         {
             blockCharLife.shots += 10000;
         }
         EnemyHealth1 enemyHealth = other.gameObject.GetComponentInParent <EnemyHealth1> ();
         if (enemyHealth != null)
         {
             enemyHealth.TakeDamage(10000, transform.position);
         }
     }
     if (other.gameObject.tag == "TC Spawner")
     {
         Destroy(other.gameObject);
     }
     if (other.gameObject.tag == "Player")
     {
         PlayerHealth1 playerHealth = other.gameObject.GetComponent <PlayerHealth1> ();
         if (playerHealth != null)
         {
             playerHealth.Restore();
         }
     }
     if (other.gameObject.tag == "Ally")
     {
         AllyDroneScript allyScript = other.gameObject.GetComponent <AllyDroneScript> ();
         if (allyScript != null)
         {
             allyScript.currentPower = allyScript.startingPower;
         }
     }
 }
Example #3
0
 void Start()
 {
     allyDrone = GetComponentInParent <AllyDroneScript>();
 }