コード例 #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == Tags.coins)
     {
         main.CollectCoinsAudio();
         coinsCollected = coinsCollected + 1;
         uiManager.UpdateCoinsCollectedText(coinsCollected);
         if (coinsCollected == 10)
         {
             lives++;
             uiManager.UpdatePlayerLivesUIText(lives);
         }
     }
     else if (collision.tag == LevelTwoTags.Fireball)
     {
         PlayerDamaged();
         Destroy(collision.gameObject);
     }
     else if (collision.tag == Tags.castle)
     {
         main.StopLevelTwoSong();
         main.LevelClearSound();
         uiManager.DisplayLevelCompleteText();
         StartCoroutine(LoadLevelThreeDelay(5f));
     }
 }
コード例 #2
0
    //counts the number of coins collected by the player



    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == LevelTwoTags.PlayerTwo)
        {
            _main.CollectCoinsAudio();
            Destroy(this.gameObject);
        }
    }