Exemple #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "head")

        {
            HeadController headObj = other.gameObject.GetComponent <HeadController> ();

            Instantiate(explosion).GetComponent <Transform> ().position =
                other.gameObject.GetComponent <Transform> ().position;


            Damage(damage);

            headObj.Reset();
            headColl = other.gameObject.GetComponent <AudioSource> ();
            headColl.Play();
        }

        if (other.gameObject.tag == "coin")
        {
            CoinController coinObj = other.gameObject.GetComponent <CoinController> ();
            coinObj.Reset();
            Player.Instance.Money = Player.Instance.Money + 10;
            coinColl = other.gameObject.GetComponent <AudioSource> ();
            coinColl.Play();
        }
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "head")

        {
            Instantiate(expl).GetComponent <Transform> ().position =
                other.gameObject.GetComponent <Transform> ().position;


            HeadController headObj = other.gameObject.GetComponent <HeadController> ();



            headObj.Reset();

            bulletColl = other.gameObject.GetComponent <AudioSource> ();
            bulletColl.Play();

            Destroy(gameObject);
        }
    }