Beispiel #1
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.CompareTag("Inimigo"))
     {
         Vida vidaInimigo = col.gameObject.GetComponent <Vida>();
         vidaInimigo.DiminuirVida(dano);
     }
 }
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == "Inimigo")
        {
            Vida vida = col.gameObject.GetComponent <Vida>();
            vida.DiminuirVida(200);
        }

        if (destruirAoEncostar)
        {
            GameObject explosaoGbj = Instantiate <GameObject>(efeitoExplosao, transform.position, Quaternion.identity);
            trilha.SetParent(explosaoGbj.transform);
            Destroy(gameObject);
        }
    }
    void Start()
    {
        RaycastHit[] hits;

        hits = Physics.SphereCastAll(transform.position, 5, Vector3.up, 10);

        for (int i = 0; i < hits.Length; i++)
        {
            RaycastHit hit = hits[i];
            if (hit.rigidbody)
            {
                hit.rigidbody.AddExplosionForce(forcaExplosao, transform.position, 10);
            }

            if (hit.transform.gameObject.tag == "Inimigo")
            {
                Vida vidaInimigo = hit.transform.gameObject.GetComponent <Vida>();
                vidaInimigo.DiminuirVida(150);
            }
        }

        Destroy(gameObject, 1.5f);
    }
Beispiel #4
0
 public void Atacar()
 {
     vidaJogador.DiminuirVida(dano);
     sistemaDeSom.Emitir(SistemaSom.EfeitoSonoro.Golpe);
 }