Exemple #1
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (!hasTriggeredRecently)
        {
            hasTriggeredRecently = true;
            if (collision.gameObject.tag == "Orb")
            {
                Destroy(collision.gameObject);
                stateComponent.AddOrb();
            }
            if (collision.gameObject.tag == "Upper")
            {
                Destroy(collision.gameObject);
                FreezeWorldComponent.instance.UpgradeFreeze();
            }
            if (collision.gameObject.tag == "Downer")
            {
                Destroy(collision.gameObject);
                FreezeWorldComponent.instance.UpgradeCooldown();
            }
            if (collision.gameObject.tag == "Key")
            {
                Destroy(collision.gameObject);
                stateComponent.AddKey();
            }

            StartCoroutine("ResetHasTriggered");
        }

        if (collision.gameObject.tag == "Enemy")
        {
            TryToDamagePlayer(collision.gameObject);
        }

        if (collision.gameObject.tag == "FireBallUpgrade")
        {
            Destroy(collision.gameObject);
            physicsComponent.iceBallPrefab.GetComponent <IceBallFreezeComponent>().Unsubscribe();
            physicsComponent.iceBallPrefab = fireBallPrefab;
        }
    }