示例#1
0
    public void addNewQuestDialogue(QuestLineContainer questLine)
    {
        QuestLineContainer[] temp = new QuestLineContainer[(NPCsQuestsDialogue.Length + 1)];

        for (int i = 0; i < NPCsQuestsDialogue.Length; i++) {

            temp[i] = NPCsQuestsDialogue[i];

        }

        temp[temp.Length - 1] = questLine;

        NPCsQuestsDialogue = temp;
    }
示例#2
0
    public void interact()
    {
        if (activeQuest == null)
        {
            bool questAvaliable = false;
            gameObject.GetComponent <Animator>().SetTrigger("startTalking");

            while ((!questAvaliable) && (avaliableQuests.Count != 0))
            {
                if (player.GetComponent <QuestsManager>().checkIfQuestAlreadyCompleted(avaliableQuests[0].questName, avaliableQuests[0].questGiver))
                {
                    avaliableQuests.RemoveAt(0);
                }
                else
                {
                    questAvaliable = true;
                }
            }

            if ((avaliableQuests.Count > 0) || questAvaliable)
            {
                activeQuest   = avaliableQuests[0];
                questDialogue = DialogueSystem.Main.getQuestDialogueForSpecificNPC(NPCName).searchByQuestTitleAndNotCompleted(activeQuest.questName);

                for (int i = 0; i < questDialogue.getTotalSizeOfQuestIntroDialogue(); i++)
                {
                    DialogueSystem.Main.DisplayText(questDialogue.getQuestIntroDialogue(i).speaker, questDialogue.getQuestIntroDialogue(i).text);
                }

                DialogueSystem.Main.setActionAfterDialogueQueueFinished(endTalkingAnimation);

                //player acceptance of quest
                DialogueSystem.Main.playerConfirmQuest(NPCName, gameObject, questRejectMessage);
            }
            else
            {
                if (casualDialogue == null)
                {
                    casualDialogue = DialogueSystem.Main.getCasualDialogueForSpecificNPC(NPCName);
                }

                System.Random rnd = new System.Random();

                int casualPos = rnd.Next(0, casualDialogue.getTotalSizeOfDialogueLines());

                DialogueSystem.Main.DisplayText(casualDialogue.getDialogueLine(casualPos).speaker, casualDialogue.getDialogueLine(casualPos).text);
                DialogueSystem.Main.setActionAfterDialogueQueueFinished(endTalkingAnimation);
            }
        }
        else
        {
            if (player.GetComponent <QuestsManager>().checkQuestStatus(activeQuest.questGiver, activeQuest.questName))
            {
                Debug.Log("Quest Completed");

                for (int i = 0; i < questDialogue.getTotalSizeOfQuestCompletionDialogue(); i++)
                {
                    DialogueSystem.Main.DisplayText(questDialogue.getQuestCompletionDialogue(i).speaker, questDialogue.getQuestCompletionDialogue(i).text);
                }
                DialogueSystem.Main.setActionAfterDialogueQueueFinished(endTalkingAnimation);
                player.GetComponent <QuestsManager>().npcConfirmedAndFinishedQuest(activeQuest.questName, activeQuest.questGiver);
                activeQuest   = null;
                questDialogue = null;
            }
            else
            {
                Debug.Log("Quest Not Completed Yet");

                if (fillerPosition >= questDialogue.getTotalSizeOfQuestFillerDialogue())
                {
                    fillerPosition = 0;
                }

                DialogueSystem.Main.DisplayText(questDialogue.getQuestFillerDialogue(fillerPosition).speaker, questDialogue.getQuestFillerDialogue(fillerPosition).text);
                fillerPosition = fillerPosition + 1;
                DialogueSystem.Main.setActionAfterDialogueQueueFinished(endTalkingAnimation);
            }
        }

        if (!RequiresQuestToBeAccepted && PendingTalkToStoryAction != null)
        {
            PendingTalkToStoryAction.DynamicInvoke();
            PendingTalkToStoryAction = null;
        }
    }