public override void JobTick(NPC npc) { if (!Init) { Init = true; ShopNode = new NPCDialogNode("What do you have for sale?", "Take a look"); ShopNode.SetOnSelectFunction(() => { //Debug.Log("test?"); GUIManager.Instance.StartShop(npc, WorkLocation.WorkBuilding.Inventory); }); if (npc.Dialog == null) { NPCDialog dialog = new NPCDialog(npc, "Hello, how can I help you today?"); dialog.AddNode(ShopNode); npc.SetDialog(dialog); NPCDialogNode exitNode = new NPCDialogNode("I'll be on my way", ""); exitNode.IsExitNode = true; dialog.AddNode(exitNode); } else { npc.Dialog.AddNode(ShopNode); } } float deltaTime = Time.time - CurrentPositionTime; if (deltaTime > CurrentPositionTimeOut) { ChooseNewPosition(); } }
private void DisplayNode(NPCDialogNode node) { GameObject nodeObj = Instantiate(PlayerReplyButtonPrefab); nodeObj.transform.SetParent(PlayerRepliesRegion.transform, false); DialogPlayerReplyButton but = nodeObj.GetComponent <DialogPlayerReplyButton>(); but.InitButton(this, node); }
public void NodeReplyClicked(NPCDialogNode node) { //If the node is null (shouldn't be), or its an exit node, we clear the dialog GUI if (node == null || node.IsExitNode) { Clear(); gameObject.SetActive(false); GameManager.PlayerManager.EndDialog(); } else { //If the node is not an exit node, we call its selection function node.OnSelectNode(); //And then Display the node NPC.Dialog.SetCurrentNode(node); DisplayCurrentNode(); } }
public void NodeReplyClicked(NPCDialogNode node) { //If the node is null (shouldn't be), or its an exit node, we clear the dialog GUI if (node == null || node.IsExitNode) { Debug.Log("HEREHREHERE"); Clear(); gameObject.SetActive(false); PlayerManager.Instance.EndDialog(); InConversation = false; Debug.Log("exit"); } else { //If the node is not an exit node, we call its selection function node.OnSelectNode(); //And then Display the node NPC.Dialog.SetCurrentNode(node); DisplayCurrentNode(); } }
public void SetCurrentNode(NPCDialogNode node) { CurrentNode = node; }
public void AddNode(NPCDialogNode node) { Nodes.Add(node); node.SetParent(this); }
public void RemoveNode(NPCDialogNode node) { Nodes.Remove(node); }
/// <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); }
public void AddNode(NPCDialogNode node) { ChildNodes.Add(node); node.SetParent(Parent); }
public void InitButton(DialogGUI parent, NPCDialogNode node) { Text.text = node.PlayerText; Parent = parent; Node = node; }