/* Creator: Yan * find the npc in the scene and save the quest status and dialog status before change to another scene */ public void FindNPCSaveBool() { if (Content.instance == null) { return; } questList = Content.instance.contentStrings; foreach (var item in questList) { Debug.Log("q " + item); } List <string> npcList = AllNPCList.returnList(sceneNum); if (npcList == null) { return; } foreach (var item in npcList) { //Debug.Log (sceneNum + item); QuestStatus qs = new QuestStatus(item, new List <QuestStatus.QuestBool>(), new List <bool>()); GameObject ve = GameObject.FindGameObjectWithTag(item); if (ve == null) { return; } NPC veNPC = ve.GetComponent <NPC> (); if (veNPC != null) { foreach (var conCollection in veNPC.conditionCollections) { qs.questBool.Add(new QuestStatus.QuestBool(conCollection.description, conCollection.obtained, conCollection.available, conCollection.complete)); } } DialogArray veDialogArray = ve.GetComponent <DialogArray> (); if (veDialogArray != null) { foreach (var dialog in veDialogArray.conversations) { qs.dialogBool.Add(dialog.active); } } // foreach (var it in qs.questBool) { // Debug.Log (it.description + it.available + it.obtained + it.complete); // } if (saveQuest.ContainsKey(sceneNum)) { saveQuest [sceneNum].Add(qs); } else { saveQuest.Add(sceneNum, new List <QuestStatus>()); saveQuest [sceneNum].Add(qs); } } }
// Use this for initialization void Start() { dialogArray = GetComponent <DialogArray> (); dialogManager = FindObjectOfType <DialogueManagerTwo> (); if (!AllEventList.returnStatus("villageInitial", 0)) { dialogManager.StartDialogue(dialogArray.conversations[0]); } }
public override void Interact() { base.Interact(); if (check) { return; } base.Interact(); check = true; StartCoroutine("reset"); if (this.GetComponent <NPCItem>() != null) { this.GetComponent <NPCItem>().setNPCItem(this.GetComponent <NPCItem>().ntype); Debug.Log("set item"); } Debug.Log("interact"); if (dialogPanel != null) { dialogPanel.SetActive(true); DialogArray da = GetComponent <DialogArray> (); DialogPanel dp = dialogPanel.GetComponentInChildren <DialogPanel> (); if (dp != null) { dp.UpdateDialog(da.conversations); } } for (int i = 0; i < conditionCollections.Length; i++) { if (conditionCollections[i].CheckAndReact()) { Debug.Log("not default"); //return; conditionCollections[i].complete = true; QuestListUpdate(); return; } //conditionCollections[i].CheckAndReact (); } QuestListUpdate(); Debug.Log("default"); if (defaultReactionCollection != null) { defaultReactionCollection.React(); } //manager.content = questList.Change(); }
/*creator: Yan Zhang * find the npc in the scene and set the bool status from the global control to the npc */ public void FindNPCSetBool(int snum) { //find the quest list object in the scene if (GameObject.FindWithTag("QuestContent") == null) { return; } Content content = GameObject.FindWithTag("QuestContent").GetComponent <Content>(); content.contentStrings.Clear(); //add each quest the player current have to the quest list on gui foreach (var item in questList) { content.contentStrings.Add(item); //Debug.Log ("q " + item); } //get the list of npc that the current loading scene have List <string> npcList = AllNPCList.returnList(snum); if (npcList == null) { return; } //go throught the npc list in the cuurent scene and set the quest state and dialog state foreach (var item in npcList) { //Debug.Log (snum + item); //find the npc with teh tag GameObject ve = GameObject.FindGameObjectWithTag(item); if (ve == null) { //Debug.Log (item + " null when set"); return; } QuestStatus qs = null; if (!saveQuest.ContainsKey(snum)) { return; } foreach (var qstatus in saveQuest[snum]) { if (qstatus.npcName == item) { qs = qstatus; } } //get npc and set bool NPC veNPC = ve.GetComponent <NPC> (); foreach (var b in qs.questBool) { foreach (var conditionCollection in veNPC.conditionCollections) { if (b.description == conditionCollection.description) { conditionCollection.available = b.available; conditionCollection.obtained = b.obtained; conditionCollection.complete = b.complete; } } } //get the dialog and set the dialog array DialogArray veDialogArray = ve.GetComponent <DialogArray> (); if (veDialogArray != null) { for (int i = 0; i < veDialogArray.conversations.Length; i++) { veDialogArray.conversations [i].active = qs.dialogBool [i]; } } } }