Exemplo n.º 1
0
    public void madeChoice(Button button)
    {
        if (startPhraseID != 0)
        {
            // Get the buttons ID: 1, 2 or 3
            int buttonID;
            if (!Int32.TryParse(button.name.Substring(6), out buttonID))
            {
                Debug.Log("Couldn't parse the end of the button name, "
                          + button.name.Substring(6) + " as a number");
            }

            // Get the line number of the phrase you chose
            int choiceLineNum = startPhraseID + buttonID - 1;

            appendChoiceToSentence(choiceLineNum);
            scorePhrase(choiceLineNum);

            // Get the ID of the start of the next phrases
            int nextID = conversation.getIDOfNextPhrase(choiceLineNum);

            // Update the text of the three buttons
            if (nextID != 0)
            {
                setPhrasesFromLine(nextID);
                startPhraseID = nextID;
            }
            else
            {
                startPhraseID = 0;
                GameObject.Find("option1").GetComponentInChildren <Text> ().text = "End";
                GameObject.Find("option2").GetComponentInChildren <Text> ().text = "of the";
                GameObject.Find("option3").GetComponentInChildren <Text> ().text = "game!";
            }
        }
    }