Ejemplo n.º 1
0
    IEnumerator CoWinScreen()
    {
        fadeScreen.FadeToWhite();
        ClearScreen();
        yield return(yieldInstruction1);

        cameraman.backgroundColor = ColorSelector.darkColor;
        TurnOn(congratulations.gameObject);
        fadeScreen.DeFade(congratulations, null);
        yield return(yieldInstruction03);

        TurnOn(resultStars.gameObject);

        switch (score)
        {       //All stars.
        case 0:
            resultStars.GetChild(0).GetComponent <Image>().sprite = winstar;
            resultStars.GetChild(1).GetComponent <Image>().sprite = winstar;
            resultStars.GetChild(2).GetComponent <Image>().sprite = winstar;
            break;

        //Lose one star.
        case -1:
        case -2:
            resultStars.GetChild(0).GetComponent <Image>().sprite = winstar;
            resultStars.GetChild(1).GetComponent <Image>().sprite = winstar;
            resultStars.GetChild(2).GetComponent <Image>().sprite = failstar;
            break;

        //Lose two stars.
        case -3:
        case -4:
            resultStars.GetChild(0).GetComponent <Image>().sprite = winstar;
            resultStars.GetChild(1).GetComponent <Image>().sprite = failstar;
            resultStars.GetChild(2).GetComponent <Image>().sprite = failstar;
            break;

        //Above zero and under -5. Attention to the if clause. It should be impossible to finish with a score above zero.
        default:
            resultStars.GetChild(0).GetComponent <Image>().sprite = failstar;
            resultStars.GetChild(1).GetComponent <Image>().sprite = failstar;
            resultStars.GetChild(2).GetComponent <Image>().sprite = failstar;
            break;
        }

        resultStars.GetChild(0).GetComponent <Image>().color = Color.clear;
        resultStars.GetChild(1).GetComponent <Image>().color = Color.clear;
        resultStars.GetChild(2).GetComponent <Image>().color = Color.clear;

        for (int i = 0; i < 3; i++)
        {
            fadeScreen.DeFade(null, resultStars.GetChild(i).GetComponent <Image>());
            yield return(yieldInstruction03);
        }

        nextgame.GetComponent <Button>().interactable  = false;
        selScreen.GetComponent <Button>().interactable = false;
        playagain.GetComponent <Button>().interactable = false;

        TurnOn(nextgame.gameObject);
        fadeScreen.DeFade(null, nextgame);
        yield return(yieldInstruction03);

        TurnOn(selScreen.gameObject);
        fadeScreen.DeFade(null, selScreen);
        yield return(yieldInstruction03);

        TurnOn(playagain.gameObject);
        fadeScreen.DeFade(null, playagain);
        yield return(yieldInstruction03);

        nextgame.GetComponent <Button>().interactable  = true;
        selScreen.GetComponent <Button>().interactable = true;
        playagain.GetComponent <Button>().interactable = true;
    }