Esempio n. 1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (gameObject.name == "Crown(Clone)" && collision.CompareTag("PlayerCollider"))
     {
         collision.GetComponentInParent <PlayerController>().ActivateCrownMode();
         audioManager.Play("sound_player_wow");
         Destroy(gameObject);
     }
     if (gameObject.name == "StrawHat" && collision.CompareTag("PlayerCollider"))
     {
         collision.GetComponentInParent <PlayerController>().ActivateStrawHatMode();
         if (achievmentDisplay != null)
         {
             achievmentDisplay.FoundSecretLevel();
         }
         audioManager.Play("sound_player_wow");
         Destroy(gameObject, 0.4f);
     }
     if (gameObject.name == "SunGlases(Clone)" && collision.CompareTag("PlayerCollider"))
     {
         collision.GetComponentInParent <PlayerController>().ActivateSunglases();
         audioManager.Play("sound_player_wow");
         Destroy(gameObject);
     }
 }
    IEnumerator LoadScene()
    {
        player.GetComponent <PlayerController>().levelCounter++;
        // transitionAnim.SetTrigger("end");


        // Zeit die der SPieler braucht um das Level zu schaffen

        saveTime = currentTime + "level:" + (levelToLoad - 1).ToString();

        PlayerPrefs.SetString("Time", saveTime);

        if (speedRunDisplay != null && currentTime <= 60)
        {
            speedRunDisplay.UnderAMinute();
        }
        else
        {
            Debug.Log("Speedrunisnulll");
        }

        if (levelToLoad == 1)
        {
            player.GetComponent <PlayerController>().levelCounter = 1;
            DataToSaveScript.TimeToFinishGame_SaveValue           = DataToSaveScript.TotalPlayTime_SaveValue;
            DataToSaveScript.FinishedTheGame_SaveValue            = true;
        }
        else
        {
            DontDestroyOnLoad(player);
        }
        DontDestroyOnLoad(achievements);
        DontDestroyOnLoad(audioManager);

        if (levelToLoad == 99)
        {
            DataToSaveScript.FoundSecretlevel_SaveValue = true;

            if (achievmentDisplay != null)
            {
                achievmentDisplay.FoundSecretLevel();
            }
        }

        SceneManager.LoadScene("Level" + levelToLoad);



        yield return(new WaitForSeconds(1.5f));
    }