//============================================================================= public void ShowPanel(bool bActive, int FairyLevel = 1, eFairy Fairy = eFairy.BLOOM) { if (bActive) { m_bButtonPressed = false; m_MainPanel.SetActive(true); FairyItemData CurFairyInfo = FairyItemsManager.GetFairyItem(Fairy); m_RequirementsPanel.Setup(CurFairyInfo, FairyLevel); m_txtFairyLevel.text = FairyLevel.ToString(); string txtHeader = TextManager.GetText("BOUTIQUE_UPGRADEFAIRY_TITLE"); txtHeader = txtHeader.Replace("(FairyName)", Fairy.ToString().ToUpper()); m_txtHeader.text = txtHeader; string txtLevelUp = TextManager.GetText("BOUTIQUE_UPGRADEFAIRY_LEVELUP"); txtLevelUp = txtLevelUp.Replace("(Cost)", String.Format("{0:n0}", CurFairyInfo.GemsRequired[FairyLevel])); m_txtLevelUp.text = txtLevelUp; } else { m_MainPanel.SetActive(false); } }
//===================================================== public void OnBuyOutfitFairy() { int PlayerGems = GameDataManager.Instance.PlayerGems; int PlayerDiamonds = GameDataManager.Instance.PlayerDiamonds; if (m_bBuyOutfitActive) { // Only show popup if player has enough diamonds to buy if (PlayerDiamonds >= m_BuyOutfit.cost) { ConfirmPurchaseManager.instance.ShowPanel(true, true, eFairy.BLOOM, m_BuyOutfit.cost); SetRoomMode(eRoomMode.BuyingOutfitFairy); } else { // Not enough money, show shop popup Instantiate(m_pfbShopPopup); ShopManager.instance.OnButtonPressed_ChangeType(1); } } else { FairyItemData CurFairyInfo = FairyItemsManager.GetFairyItem((eFairy)m_CurrentFairyIndex); // Only show popup if player has enough gems to buy if (PlayerGems >= CurFairyInfo.GemsRequired[0]) { ConfirmPurchaseManager.instance.ShowPanel(true, false, (eFairy)m_CurrentFairyIndex, CurFairyInfo.GemsRequired[0]); SetRoomMode(eRoomMode.BuyingOutfitFairy); } else { // Not enough money, show shop popup Instantiate(m_pfbShopPopup); ShopManager.instance.OnButtonPressed_ChangeType(0); } } }
//===================================================== void UpdateFairyRequirements() { int PlayerGems = GameDataManager.Instance.PlayerGems; if (UpgradeFairyManager.instance.WasButtonPressed()) { switch (UpgradeFairyManager.instance.GetButtonPressed()) { case 0: // Upgrade fairy level if we have enough diamonds bool bCanUpgradeFairy = true; bool bRequirementsWereMet = true; int UpgradeGemCost = 0; FairyItemData CurFairyInfo = FairyItemsManager.GetFairyItem((eFairy)m_CurrentFairyIndex); FairyData CurFairy = GameDataManager.Instance.GetFairyData((eFairy)m_CurrentFairyIndex); if (CurFairy != null) { UpgradeGemCost = CurFairyInfo.GemsRequired[CurFairy.Level + 1]; if (UpgradeGemCost > PlayerGems) { bCanUpgradeFairy = false; } if (GameDataManager.Instance.PlayerPopulation < CurFairyInfo.PopulationRequired[CurFairy.Level + 1]) { bRequirementsWereMet = false; bCanUpgradeFairy = false; } if (GameDataManager.Instance.GetNumKeysCollected() < CurFairyInfo.KeysRequired[CurFairy.Level + 1]) { bRequirementsWereMet = false; bCanUpgradeFairy = false; } } else { bCanUpgradeFairy = false; } if (bCanUpgradeFairy) { CurFairy.Level++; GameDataManager.Instance.SaveGameData(); GameDataManager.Instance.AddPlayerGems(-UpgradeGemCost); GameDataManager.Instance.BroadcastGuiData(); UpgradeFairyManager.instance.ShowPanel(false); SetRoomMode(eRoomMode.ViewingOutfits); // Analytics event Dictionary <string, object> EventDictionary = new Dictionary <string, object>(); EventDictionary["fairyID"] = ((eFairy)m_CurrentFairyIndex).ToString(); EventDictionary["fairyLevel"] = CurFairy.Level; Analytics.CustomEvent("UpgradeFairy", EventDictionary); } else { UpgradeFairyManager.instance.Reset(); // Not enough money, show shop popup (if requirements are met) if (bRequirementsWereMet) { Instantiate(m_pfbShopPopup); ShopManager.instance.OnButtonPressed_ChangeType(0); } } break; case 1: // Cancel UpgradeFairyManager.instance.ShowPanel(false); SetRoomMode(eRoomMode.ViewingOutfits); break; } } }
//===================================================== void UpdateBuyingOutfitFairy() { // Twirl anim bool bDoTwirl = false; if (ConfirmPurchaseManager.instance.WasButtonPressed()) { switch (ConfirmPurchaseManager.instance.GetButtonPressed()) { case 0: // Buy outfit/fairy if (m_bBuyOutfitActive) { // Outfit FairyData CurFairy = GameDataManager.Instance.GetFairyData((eFairy)m_CurrentFairyIndex); if (CurFairy != null) { CurFairy.BuyOutfit(m_BuyOutfit.id); CurFairy.Outfit = m_BuyOutfit.id; GameDataManager.Instance.SaveGameData(); // Use diamonds GameDataManager.Instance.AddPlayerDiamonds(-m_BuyOutfit.cost); GameDataManager.Instance.BroadcastGuiData(); // Analytics event Dictionary <string, object> EventDictionary = new Dictionary <string, object>(); EventDictionary["outfitID"] = m_BuyOutfit.id; Analytics.CustomEvent("BuyOutfit", EventDictionary); bDoTwirl = true; } } else { // Fairy GameDataManager.Instance.BuyFairy((eFairy)m_CurrentFairyIndex, true); // Use gems FairyItemData CurFairyInfo = FairyItemsManager.GetFairyItem((eFairy)m_CurrentFairyIndex); GameDataManager.Instance.AddPlayerGems(-CurFairyInfo.GemsRequired[0]); GameDataManager.Instance.BroadcastGuiData(); // Analytics event Dictionary <string, object> EventDictionary = new Dictionary <string, object>(); EventDictionary["fairyID"] = ((eFairy)m_CurrentFairyIndex).ToString(); Analytics.CustomEvent("BuyFairy", EventDictionary); bDoTwirl = true; } UpdateSelectedFairy(); ConfirmPurchaseManager.instance.ShowPanel(false); SetRoomMode(eRoomMode.ViewingOutfits); m_bBuyOutfitActive = false; if (bDoTwirl) { m_InspectOufitTimer = UnityEngine.Random.Range(3.0f, 6.0f); m_CurrentFairyObj.GetComponent <Animator>().SetTrigger("IsChangingOutfit"); } break; case 1: // Cancel ConfirmPurchaseManager.instance.ShowPanel(false); SetRoomMode(eRoomMode.ViewingOutfits); m_bBuyOutfitActive = false; break; } } }
//===================================================== void UpdateViewingOutfits() { // Show selected fairy name and fairy level information/buttons { if (m_CurrentFairyIndex <= 0) { m_btnPrevFairy.SetActive(false); } else { m_btnPrevFairy.SetActive(true); } if (m_CurrentFairyIndex >= 5) { m_btnNextFairy.SetActive(false); } else { m_btnNextFairy.SetActive(true); } m_txtCurrentFairyName.text = TextManager.GetText("FAIRYNAME_" + ((eFairy)m_CurrentFairyIndex).ToString()); // Fairy owned? FairyData CurFairy = GameDataManager.Instance.GetFairyData((eFairy)m_CurrentFairyIndex); if (CurFairy == null) { // Not owned, do we meet the requirements to buy this fairy? FairyItemData CurFairyInfo = FairyItemsManager.GetFairyItem((eFairy)m_CurrentFairyIndex); bool bRequirementsMet = AreRequirementsMet(CurFairyInfo); string txtPurchaseCost = TextManager.GetText("BOUTIQUE_PURCHASE"); txtPurchaseCost = txtPurchaseCost.Replace("(Cost)", CurFairyInfo.GemsRequired[0].ToString()); m_txtPurchaseCostGems.text = txtPurchaseCost; m_txtPurchaseCostDiamonds.text = txtPurchaseCost; if (bRequirementsMet) { // Requirements met, show purchase button m_sprPurchaseOverlayGems.SetActive(true); m_sprPurchaseOverlayDiamonds.SetActive(false); FairyLockedManager.instance.ShowPanel(false, CurFairyInfo); } else { // Requirements not met, show requirements panel m_sprPurchaseOverlayGems.SetActive(false); m_sprPurchaseOverlayDiamonds.SetActive(false); FairyLockedManager.instance.ShowPanel(true, CurFairyInfo); } // Hide all fairy levels foreach (GameObject Obj in m_sprFairyLevels) { Obj.SetActive(false); } foreach (GameObject Obj in m_sprFairyLevelsLocked) { Obj.SetActive(false); } } else { // Owned, show current fairy level m_sprPurchaseOverlayGems.SetActive(false); m_sprPurchaseOverlayDiamonds.SetActive(false); FairyLockedManager.instance.ShowPanel(false); int FairyLevel = CurFairy.Level; int Idx = 1; foreach (GameObject Obj in m_sprFairyLevels) { Obj.SetActive(Idx <= FairyLevel ? true : false); Idx++; } Idx = 1; foreach (GameObject Obj in m_sprFairyLevelsLocked) { Obj.SetActive(Idx == (FairyLevel + 1) ? true : false); Idx++; } // Buying outfit button active? if (m_bBuyOutfitActive) { m_sprPurchaseOverlayGems.SetActive(false); m_sprPurchaseOverlayDiamonds.SetActive(true); string txtPurchaseCost = TextManager.GetText("BOUTIQUE_PURCHASE"); txtPurchaseCost = txtPurchaseCost.Replace("(Cost)", m_BuyOutfit.cost.ToString()); m_txtPurchaseCostGems.text = txtPurchaseCost; m_txtPurchaseCostDiamonds.text = txtPurchaseCost; } } } // Random outfit inspection anim m_InspectOufitTimer -= Time.deltaTime; if (m_InspectOufitTimer < 0.0f) { m_InspectOufitTimer = UnityEngine.Random.Range(3.0f, 6.0f); m_CurrentFairyObj.GetComponent <Animator>().SetTrigger("IsInspectingOutfit"); } }