Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IBonus bonus = collision.gameObject.GetComponent <IBonus>();

        if (bonus != null)
        {
            bonus.makeAction(this);
            Destroy(collision.gameObject);
        }
        IWeapon weapon = collision.gameObject.GetComponent <IWeapon>();

        if (weapon != null)
        {
            GameObject newWeapon = Instantiate(collision.gameObject, new Vector3(10000, 10000, -1000), Quaternion.identity);
            newWeapon.GetComponent <SpriteRenderer>().sprite = null;
            newWeapon.AddComponent <NoDestroy>();
            GetComponent <Shooting>().weapon = newWeapon;
        }
        Destroy(collision.gameObject);
    }