コード例 #1
0
 public Quest(string questName, QuestInitiator init, QuestTask[] tasks, QuestType questType)
 {
     QuestName = questName;
     Initiator = init;
     Tasks     = tasks;
     QuestType = questType;
     Completed = false;
 }
コード例 #2
0
    private void AddNPCInitDialoge(NPC npc, QuestInitiator init, Quest quest)
    {
        if (init.InitType != QuestInitiator.InitiationType.TALK_TO_NPC)
        {
            throw new System.Exception("NPC dialoge can only be added for quest initiations of type 'TALK_TO_NPC");
        }

        if (npc.Dialog == null)
        {
            //npc.SetDialog(new NPCDialog(npc));
        }


        switch (quest.QuestType)
        {
        case QuestType.clear_dungeon:

            break;
        }
    }
コード例 #3
0
    /// <summary>
    /// Places the dungeon key in a random structure.
    ///
    /// </summary>
    /// <param name="dungeonPos"></param>
    /// <param name="chunkStructure"></param>
    /// <param name="endTasks"></param>
    /// <returns></returns>
    private Quest GenerateDungeonKeyQuest_RandomStructure(Vec2i dungeonPos, Dungeon dungeon, List <QuestTask> endTasks)
    {
        //Find a random chunk structure
        ChunkStructure ranStruct = GetRandomFreeStructure(dungeonPos, 3);

        if (ranStruct == null)
        {
            throw new System.Exception("We need to fix this");
        }
        //We add the dungeon key to the loot chest of this structure
        ranStruct.FinalLootChest.GetInventory().AddItem(dungeon.GetKey());
        //Add the item finding task


        endTasks.Add(new QuestTask("Go to " + ranStruct.Name + " and collect the key", QuestTask.QuestTaskType.PICK_UP_ITEM,
                                   new object[] { dungeon.GetKey(), ranStruct.WorldMapLocation, (ranStruct.FinalLootChest as WorldObjectData).WorldPosition }));

        //Quest initiator will be a random entity
        //Therefore, we choose a random settlement
        Settlement set = GetRandomSettlement(dungeonPos, 5);
        //Then take a random npc from it.
        NPC            npc       = GameManager.EntityManager.GetEntityFromID(GenRan.RandomFromList(set.SettlementNPCIDs)) as NPC;
        QuestInitiator questInit = new QuestInitiator(QuestInitiator.InitiationType.TALK_TO_NPC, new object[] { npc, false });



        //We now reverse the tasks to get in correct order
        endTasks.Reverse();
        Quest quest = new Quest("Clear dungeon " + questCount, questInit, endTasks.ToArray(), QuestType.clear_dungeon);



        if (npc.Dialog == null)
        {
            NPCDialog dialog = new NPCDialog(npc, "Hello adventurer! How can I help you today?");

            NPCDialogNode exitNode = new NPCDialogNode("Don't worry, I'll be on my way", "");
            exitNode.IsExitNode = true;

            dialog.AddNode(exitNode);
            npc.SetDialog(dialog);
        }
        NPCDialogNode startQuestNode = new NPCDialogNode("Have you heard of any quests for an adventurer such as myself?", "I've heard of a dungeon that may be full of sweet shit." +
                                                         " It's probably locked though, last I heard the key was at " + ranStruct.Name);

        NPCDialogNode exitNode2 = new NPCDialogNode("Thanks! I'll be on my way", "");

        exitNode2.IsExitNode = true;
        startQuestNode.AddNode(exitNode2);
        npc.Dialog.AddNode(startQuestNode);

        startQuestNode.SetOnSelectFunction(() => {
            GameManager.QuestManager.StartQuest(quest);
        });
        startQuestNode.SetShouldDisplayFunction(() =>
        {
            if (GameManager.QuestManager.Unstarted.Contains(quest))
            {
                return(true);
            }
            return(false);
        });


        NPCDialogNode questRewardNode = new NPCDialogNode("I killed " + dungeon.Boss.Name, "I didn't think it was possible. Here, take this as a reward");

        questRewardNode.AddNode(exitNode2);
        questRewardNode.SetShouldDisplayFunction(() => {
            return(GameManager.QuestManager.Completed.Contains(quest));
        });
        questRewardNode.SetOnSelectFunction(() =>
        {
            Inventory playerInv = GameManager.PlayerManager.Player.Inventory;
            playerInv.AddItem(new SteelLongSword());
        });
        npc.Dialog.AddNode(questRewardNode);

        return(quest);
    }