Beispiel #1
0
 public virtual void OnObjectiveCompleted(OCQuests.Quest quest, int i)
 {
 }
Beispiel #2
0
    public void DisplayNode()
    {
        OCNode node     = tree.rootNodes[tree.currentRoot].GetNode(currentNode);
        bool   wait     = false;
        bool   exit     = false;
        int    nextNode = 0;

        switch (node.type)
        {
        case OCNodeType.Jump:
            tree.currentRoot = node.jump.rootNode;
            nextNode         = tree.rootNodes[tree.currentRoot].firstNode;
            break;

        case OCNodeType.Speak:
            speaker = speakers [node.speak.speaker];
            wait    = true;
            break;

        case OCNodeType.Event:
            // Send the event message to the target object
            if (node.evt.obj != null && node.evt.eventToTarget)
            {
                if (!string.IsNullOrEmpty(node.evt.argument))
                {
                    node.evt.obj.SendMessage(node.evt.message, node.evt.argument, SendMessageOptions.DontRequireReceiver);
                }
                else
                {
                    node.evt.obj.SendMessage(node.evt.message, tree, SendMessageOptions.DontRequireReceiver);
                }

                // Send the message to the event handler
            }
            else if (eventHandler)
            {
                if (!string.IsNullOrEmpty(node.evt.argument))
                {
                    eventHandler.Event(node.evt.message, node.evt.argument);
                }
                else if (node.evt.obj != null)
                {
                    eventHandler.Event(node.evt.message, node.evt.obj);
                }
                else
                {
                    eventHandler.Event(node.evt.message, tree);
                }
            }

            nextNode = node.connectedTo[0];
            break;

        case OCNodeType.SetFlag:
            flags.Set(node.setFlag.flag, node.setFlag.b);

            nextNode = node.connectedTo[0];
            break;

        case OCNodeType.GetFlag:
            if (flags.Get(node.getFlag.flag))
            {
                nextNode = node.connectedTo[1];
            }
            else
            {
                nextNode = node.connectedTo[0];
            }
            break;

        case OCNodeType.SetQuest:
            OCQuests.Quest quest = quests.GetUserQuest(node.setQuest.quest);

            if (quest == null)
            {
                quest = quests.GetPotentialQuest(node.setQuest.quest);

                if (quest != null)
                {
                    quests.AddUserQuest(quest);
                }
            }

            if (quest != null)
            {
                OCQuests.Objective objective = quest.objectives [node.setQuest.objective];
                objective.completed = node.setQuest.completed;
            }
            else
            {
                Debug.LogWarning("OCManager | Quest is null!");
            }

            nextNode = node.connectedTo[0];
            break;

        case OCNodeType.GetQuest:
            quest = quests.GetUserQuest(node.getQuest.quest);

            if ((!node.getQuest.completed && quest != null) || (quest != null && node.getQuest.objective < quest.objectives.Length && quest.objectives[node.getQuest.objective].completed))
            {
                nextNode = node.connectedTo[1];
            }
            else
            {
                nextNode = node.connectedTo[0];
            }
            break;

        case OCNodeType.End:
            tree.currentRoot = node.end.rootNode;
            exit             = true;
            break;
        }

        // Meta nodes
        if (exit)
        {
            EndConversation();
        }
        else if (!wait)
        {
            currentNode = nextNode;
            DisplayNode();

            // OCSpeak nodes
        }
        else if (node != null && node.speak != null)
        {
            eventHandler.OnSetSpeaker(speaker, node.speak);

            if (!node.speak.choice)
            {
                StartCoroutine(PlayLineAudio(node));

                if (node.speak.smalltalk)
                {
                    if (node.speak.index < node.speak.lines.Length - 1)
                    {
                        node.speak.index++;
                    }
                }
            }
        }
    }