示例#1
0
    IEnumerator OpenPlayerDialogue()
    {
        buttonBad.GetComponent <Button>().interactable     = false;
        buttonNeutral.GetComponent <Button>().interactable = false;
        buttonGood.GetComponent <Button>().interactable    = false;
        choices.SetActive(false);

        // Make the buttons invisible for next memory encounter
        buttonBad.GetComponent <CanvasGroup>().alpha     = 0;
        buttonNeutral.GetComponent <CanvasGroup>().alpha = 0;
        buttonGood.GetComponent <CanvasGroup>().alpha    = 0;

        animatorP.SetBool("isOpenP", true);

        if (chooseBad)
        {
            // If the player chooses the an option, display appropriate text in their dialogue
            pDialogueText.GetComponent <Text>().text = choiceText[0];

            // Add specific stat to statIncrease based on choice
            statIncrease.GetComponent <Text>().text += "\n" + textStatBad.GetComponent <Text>().text;
        }

        if (chooseNeutral)
        {
            // If the player chooses the an option, display appropriate text in their dialogue
            pDialogueText.GetComponent <Text>().text = choiceText[1];

            // Add specific stat to statIncrease based on choice
            statIncrease.GetComponent <Text>().text += "\n" + textStatNeutral.GetComponent <Text>().text;
        }

        if (chooseGood)
        {
            // If the player chooses the an option, display appropriate text in their dialogue
            pDialogueText.GetComponent <Text>().text = choiceText[2];

            // Add specific stat to statIncrease based on choice
            statIncrease.GetComponent <Text>().text += "\n" + textStatGood.GetComponent <Text>().text;
        }

        yield return(new WaitForSeconds(waitTimeAlphaStart));

        // Enable stat increase text to transition in
        statIncrease.GetComponent <AlphaTransition>().canIncrease = true;

        // Increase player's statistics
        gm.IncreaseStatistics();

        yield return(new WaitForSeconds(5f));

        // Reset stat increase text to default
        statIncrease.GetComponent <Text>().text = "+ Projectile Speed\n+ Reload Speed";

        // Remove player dialogue box from screen
        animatorP.SetBool("isOpenP", false);
    }