示例#1
0
    /// <summary>
    /// Sets next node, assuming that the current node is a normal node, and one of the available
    /// dialogue options has been chosen as an answer to what has been said in the current node.
    /// </summary>
    /// <param name="chosenAnswer"></param>
    public bool Next(DialogueOption chosenAnswer)
    {
        if (CurrentNode.ImmediateNode)
        {
            throw new System.ArgumentException("Node is an immediate node - operation illegal!");
        }

        chosenAnswer.Visit();

        int      targetID   = chosenAnswer.NextID;
        NodeType targetType = chosenAnswer.NextType;

        if (targetType == NodeType.Exit)
        {
            // Wywołaj event ładujący nowy dialog
            FireOnDialogueEnded(chosenAnswer.NextDialogue);
            return(false);
        }

        if (targetType == NodeType.Condition && !CycleThroughConditions(targetID, out targetID, out targetType))
        {
            return(false);
        }

        if (targetType == NodeType.Node)
        {
            currentNodeID = targetID;
            CurrentNode.Visit();
        }

        return(true);
    }