예제 #1
0
파일: Edible.cs 프로젝트: Juutis/LD46
 void OnDestroy()
 {
     EdibleManager.GetInstance().Remove(this);
     if (LevelEndTrigger != null)
     {
         LevelEndTrigger.Trigger();
     }
 }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag(DEATHBOX_TAG))
        {
            levelManager.RespawnPlayer();
        }

        Coin coin = other.GetComponent <Coin>();

        if (coin != null)
        {
            levelManager.AddCoins(coin.coinAmount);
            coin.gameObject.SetActive(false);
        }

        Heart heart = other.GetComponent <Heart>();

        if (heart != null)
        {
            levelManager.AddHealth(heart.healthAmount);
            heart.gameObject.SetActive(false);
        }

        HurtPlayer hurt = other.GetComponent <HurtPlayer>();

        if (hurt != null && hurt.IsActive)
        {
            levelManager.DamagePlayer(hurt.damageAmount);
        }

        LevelEnd end = other.GetComponent <LevelEnd>();

        if (end != null)
        {
            end.Trigger();
        }

        Checkpoint check = other.GetComponent <Checkpoint>();

        if (check != null)
        {
            check.Trigger();
            respawnPoint = check.transform;
            checkpointAudio.Play();
        }
    }