Esempio n. 1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.layer != 8 || other.gameObject.CompareTag("Player"))
     {
         return;
     }
     GetComponent <Collider>().gameObject.GetComponent <Collider> ().enabled = false;
     foreach (Collider colider in Physics.OverlapSphere(transform.position, 10))
     {
         if (!colider.gameObject.CompareTag("Player"))
         {
             ZdrowiePrzeciwnika przeciwnik = colider.transform.parent.GetComponent <ZdrowiePrzeciwnika> ();
             if (przeciwnik == null)
             {
                 przeciwnik = colider.GetComponent <ZdrowiePrzeciwnika> ();
             }
             if (przeciwnik != null)
             {
                 przeciwnik.TakeDamage(damage);
             }
             if (colider.attachedRigidbody != null)
             {
                 colider.attachedRigidbody.AddExplosionForce(1000, transform.position, 2);
             }
         }
     }
     particles.Play();
     boom.Play();
     isParticles = true;
 }
Esempio n. 2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer != 8)
        {
            return;
        }
        ZdrowiePrzeciwnika enemyHealth = other.GetComponentInParent <ZdrowiePrzeciwnika> ();

        if (enemyHealth != null)
        {
            return;
        }
        GraczFPS gracz = other.GetComponent <GraczFPS> ();

        if (gracz != null)
        {
            gracz.TakeDamage(damage);
            transform.SetParent(other.gameObject.transform);
        }
        GetComponent <Collider>().gameObject.GetComponent <Collider> ().enabled = false;
        koniec = true;
    }