コード例 #1
0
    public List <string> Play(string answer)
    {
        List <string> response = new List <string>();

        if (Finished)
        {
            throw new InvalidOperationException("Adventure has been fininshed. Reset it to continue.");
        }

        // If right answer, continue.
        if (currentNode.IsRightAnswer(answer))
        {
            // Add right answer dialog to response.
            response.Add(currentNode.GetResponseString(answer));

            int lastIndex = index;
            index = currentNode.GetJumpIndex(answer);

            if (index < 0)
            {
                // No jump. Just get next node.
                index = lastIndex;
                index++;
            }

            // If andventure is fininshed, add finished dialog and return response.
            if (Finished)
            {
                response.Add(finishedDialog);

                return(response);
            }

            currentNode = nodes[index];

            Debug.Log(currentNode.GetResponseString("tissit"));
        }
        else
        {
            response.Add(wrongAnswerDialogs[random.Next(0, wrongAnswerDialogs.Length - 1)]);
        }

        return(response);
    }