Esempio n. 1
0
    /// <summary>
    /// The screen fades out, deletes the savegame and goes back to the main menu
    /// </summary>
    /// <returns></returns>
    public IEnumerator fadeGameOver()
    {
        Color tmp2 = new Color();

        for (float i = 0f; i < 1f; i = i + 0.02f)
        {
            tmp   = fader.GetComponent <RawImage>().color;
            tmp.a = i;
            fader.GetComponent <RawImage>().color = tmp; //Hay que hacerlo así porque no es una variable y no se puede cambiar directamente
            yield return(new WaitForSeconds(0.0001f));
        }

        gameOver.SetActive(true);

        audioManager.stopMusic();
        backgroundMusic = Resources.Load <AudioClip>("Music/Normal Dungeon Music");

        tmp2 = gameOver.transform.GetChild(0).GetComponent <Text>().color;

        for (float i = 0f; i < 1f; i = i + 0.02f)
        {
            tmp2.a = i;
            gameOver.transform.GetChild(0).GetComponent <Text>().color = tmp2; //Hay que hacerlo así porque no es una variable y no se puede cambiar directamente
            yield return(new WaitForSeconds(0.0001f));
        }

        gameDataManager.DeleteSave();

        yield return(new WaitForSeconds(2f));

        for (float i = 1f; i >= 0f; i = i - 0.02f)
        {
            tmp2.a = i;
            gameOver.transform.GetChild(0).GetComponent <Text>().color = tmp2; //Hay que hacerlo así porque no es una variable y no se puede cambiar directamente
            yield return(new WaitForSeconds(0.0001f));
        }

        yield return(new WaitForSeconds(1f));

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }