Ejemplo n.º 1
0
    /**
     * Initiates destruction of game object based on bullet
     **/
    void ActivateDestruction(Bullet bullet)
    {
        GameObject particles       = Instantiate(shatterParticles, gameObject.transform.position, Quaternion.identity);
        GameObject bulletParticles = Instantiate(shatterParticles, bullet.gameObject.transform.position, Quaternion.identity);

        if (bullet.animal == animal)
        {
            game.playSound(animal);
            ParticleSystem.MainModule mainModule = particles.GetComponent <ParticleSystem> ().main;
            mainModule.startColor = Color.green;
            ParticleSystem.MainModule bulletMainModule = bulletParticles.GetComponent <ParticleSystem> ().main;
            bulletMainModule.startColor = Color.green;
            Debug.Log(transform.position);
            Debug.Log(transform.localRotation);
            Destroy(bullet.gameObject);
            Destroy(gameObject);
            game.GoodHit(animal, id);
        }
        else
        {
            game.playSound(4);
            ParticleSystem.MainModule mainModule = particles.GetComponent <ParticleSystem> ().main;
            mainModule.startColor = Color.red;
            ParticleSystem.MainModule bulletMainModule = bulletParticles.GetComponent <ParticleSystem> ().main;
            bulletMainModule.startColor = Color.red;
            Destroy(bullet.gameObject);
            Destroy(gameObject);
            game.BadHit(animal);
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        Bullet bull = coll.gameObject.GetComponent <Bullet> () as Bullet;

        Debug.Log("COLLISION DETECTED");
        if (bull != null)
        {
            if (bull.animal == animal)
            {
                Destroy(bull.gameObject);
                Destroy(gameObject);
                game.GoodHit(animal, id);
            }
            else
            {
                Destroy(bull.gameObject);
                Destroy(gameObject);
                game.BadHit(animal);
            }
        }
        else
        {
        }
    }