public void PopulateShop() { shopActive = true; Debug.Log("PopulateShop"); Glossary glossy = PauseManager.instance.glossaryObj.GetComponent <Glossary>(); List <string> defeated = GameUtilities.getInteractedWith(glossy, false, true); if (defeated.Contains("Gaia Temple Leader Audrey") && !shopOwnersStock.ContainsKey("Stim")) { shopOwnersStock.Add("Stim", 150); } if (shopitemSubPnls == null) { shopitemSubPnls = new GameObject[] { GameObject.Find("ShopItemPnl01"), GameObject.Find("ShopItemPnl02"), GameObject.Find("ShopItemPnl03"), GameObject.Find("ShopItemPnl04"), GameObject.Find("ShopItemPnl05"), GameObject.Find("ShopItemPnl06"), GameObject.Find("ShopItemPnl07"), GameObject.Find("ShopItemPnl08"), GameObject.Find("ShopItemPnl09") }; } AdventureMeta meta = BaseSaver.getAdventure(); Dictionary <string, int> treasure = meta.GetTreasureList(); List <string> inventoryKeys = new List <string>(treasure.Keys); List <string> shopKeys = new List <string>(shopOwnersStock.Keys); GameObject.Find("MoneyTxt").GetComponent <Text>().text = "¥" + meta.getYen(); for (int i = 1; i < 10; i++) { if (shopKeys.Count >= i) { shopitemSubPnls[i - 1].SetActive(true); string img = "SI0" + i.ToString() + "Img"; string nme = "SI0" + i.ToString() + "Name"; string description = "SI0" + i.ToString() + "Desc"; string qty = "SI0" + i.ToString() + "Qty"; string cost = "SI0" + i.ToString() + "Cost"; GameObject.Find(img).GetComponent <Image>().sprite = glossy.GetItem(shopKeys[i - 1]).GetComponent <SpriteRenderer>().sprite; GameObject.Find(nme).GetComponent <Text>().text = shopKeys[i - 1]; GameObject.Find(description).GetComponent <Text>().text = glossy.GetItem(shopKeys[i - 1]).monTreas.description; GameObject.Find(qty).GetComponent <Text>().text = treasure.ContainsKey(shopKeys[i - 1]) ? treasure[shopKeys[i - 1]].ToString() : "0"; GameObject.Find(cost).GetComponent <Text>().text = "¥" + shopOwnersStock[shopKeys[i - 1]].ToString(); } else { shopitemSubPnls[i - 1].SetActive(false); } } }
IEnumerator checkQuestSatisfied() { bool qsts = meta.questsToAppear.Length > 0 || meta.questsToFight.Length > 0 || meta.questsToDisappear.Length > 0; if (qsts && glossy != null) { Debug.Log("This character has some f*****g quests!"); List <string> talkedTo = GameUtilities.getInteractedWith(glossy, true, false); List <string> defeated = GameUtilities.getInteractedWith(glossy, false, true); if (meta.questsToAppear.Length > 0) { /* * Hide character until this happens */ bool hideCharacter = true; foreach (QuestMeta npc in meta.questsToAppear) { if (npc.goal == QuestMeta.QuestType.TalkTo && !talkedTo.Contains(npc.questTarget)) { hideCharacter = false; } if (npc.goal == QuestMeta.QuestType.Defeated && !defeated.Contains(npc.questTarget)) { hideCharacter = false; } } if (hideCharacter) { meta.visible = true; } else { meta.visible = false; } } if (meta.questsToFight.Length > 0) { /* * Disable fight until this happens */ bool disableFight = false; foreach (QuestMeta npc in meta.questsToFight) { if (npc.goal == QuestMeta.QuestType.TalkTo && !talkedTo.Contains(npc.questTarget)) { disableFight = true; } if (npc.goal == QuestMeta.QuestType.Defeated && !defeated.Contains(npc.questTarget)) { disableFight = true; } } if (disableFight) { meta.canFight = false; } else { meta.canFight = true; } } if (meta.questsToDisappear.Length > 0) { /* * Show character until this happens */ bool showCharacter = false; foreach (QuestMeta npc in meta.questsToDisappear) { if (npc.goal == QuestMeta.QuestType.TalkTo && !talkedTo.Contains(npc.questTarget)) { showCharacter = true; } if (npc.goal == QuestMeta.QuestType.Defeated && !defeated.Contains(npc.questTarget)) { showCharacter = true; } } if (showCharacter) { meta.visible = true; } else { meta.visible = false; } } if (meta.visible) { GetComponent <BoxCollider2D>().enabled = true; GetComponent <SpriteRenderer>().enabled = true; Debug.Log("Enabled: " + meta.name); } else { GetComponent <BoxCollider2D>().enabled = false; GetComponent <SpriteRenderer>().enabled = false; Debug.Log("Disabled: " + meta.name); } if (!meta.canFight) { Debug.Log("Cant fight: " + meta.name); } } if (glossy == null) { glossy = GameObject.Find("PauseCanvas").GetComponent <PauseManager>().glossaryObj.GetComponent <Glossary>(); } yield return(null); }
IEnumerator checkQuestSatisfied() { bool qsts = meta.questsToAppear.Length > 0 || meta.questsToDisappear.Length > 0; if (qsts && glossy != null) { //Debug.Log("This interactable has some f*****g quests!"); List <string> talkedTo = GameUtilities.getInteractedWith(glossy, true, false); List <string> defeated = GameUtilities.getInteractedWith(glossy, false, true); //foreach(string talked in talkedTo){ // Debug.Log("Talked To: " + talked); //} if (meta.questsToAppear.Length > 0) { /* * Hide character until this happens */ bool hideCharacter = true; foreach (QuestMeta npc in meta.questsToAppear) { if (npc.goal == QuestMeta.QuestType.TalkTo && !talkedTo.Contains(npc.questTarget)) { hideCharacter = false; } if (npc.goal == QuestMeta.QuestType.Defeated && !defeated.Contains(npc.questTarget)) { hideCharacter = false; } } if (hideCharacter) { meta.visible = true; } else { meta.visible = false; } } if (meta.questsToDisappear.Length > 0) { /* * Show character until this happens */ bool showCharacter = false; foreach (QuestMeta npc in meta.questsToDisappear) { //Debug.Log(npc.ToString()); if (npc.goal == QuestMeta.QuestType.TalkTo) { if (!talkedTo.Contains(npc.questTarget)) { //Debug.Log("Haven't talked to: " + npc.questTarget); //Debug.Log("Talked to"); foreach (string talked in talkedTo) { Debug.Log(talked); } showCharacter = true; } } if (npc.goal == QuestMeta.QuestType.Defeated) { if (!defeated.Contains(npc.questTarget)) { showCharacter = true; } } } if (showCharacter) { meta.visible = true; } else { meta.visible = false; } } //Debug.Log("Interactable Visible: " + meta.visible.ToString()); if (meta.visible) { GetComponent <BoxCollider2D>().enabled = true; GetComponent <SpriteRenderer>().enabled = true; } else { GetComponent <BoxCollider2D>().enabled = false; GetComponent <SpriteRenderer>().enabled = false; } } if (glossy == null) { glossy = GameObject.Find("PauseCanvas").GetComponent <PauseManager>().glossaryObj.GetComponent <Glossary>(); } yield return(null); }