Ejemplo n.º 1
0
    void OnCollisionEnter(Collision col)
    {
        playerHp health = col.collider.gameObject.GetComponent <playerHp>();

        if (col.collider.gameObject.GetComponent <bot>() != null)
        {
            Rigidbody rigid = col.collider.gameObject.GetComponent <Rigidbody>();
            if (rigid != null)
            {
                col.collider.gameObject.GetComponent <bot>().Eject();
                rigid.AddForce(transform.forward * 5);
            }
        }
        if (health != null)
        {
            health.TakeDamages(damages);

            GameObject b = ObjectPool.instance.GetObjectForType("bloodEmiter", true);
            if (b != null)
            {
                b.transform.position = transform.position;
                b.transform.forward  = col.contacts[0].normal;
                //b.transform.rotation = Quaternion.FromToRotation(Vector3.right, col.contacts[0].normal);
            }
            else
            {
                Debug.Log("plus de sang");
            }
        }
        ObjectPool.instance.PoolObject(gameObject);
    }
Ejemplo n.º 2
0
    void Explose()
    {
        if (audio != null)
        {
            Debug.Log("sons");
            audio.PlayOneShot(audio.clip);
        }
        Collider[] touchs = Physics.OverlapSphere(transform.position, radius);
        foreach (Collider t in touchs)
        {
            if (t.GetComponent <Collider>().gameObject.GetComponent <bot>() != null)
            {
                Rigidbody rigid = t.GetComponent <Collider>().gameObject.GetComponent <Rigidbody>();
                if (rigid != null)
                {
                    t.GetComponent <Collider>().gameObject.GetComponent <bot>().Eject();
                    rigid.AddExplosionForce(500f, new Vector3(transform.position.x, transform.position.y - 2, transform.position.z), 50f);
                }
            }

            Health health = t.gameObject.GetComponent <Health>();
            if (health != null)
            {
                health.TakeDamages(damages);
            }

            playerHp player = t.gameObject.GetComponent <playerHp>();
            if (player != null)
            {
                player.TakeDamages(damages);
            }

            ObjectPool.instance.PoolObject(gameObject);
        }
    }