protected override void OnViewShow() { base.OnViewShow(); if (m_BuyItemId == ShopItemId.EmptyId) { Debug.LogError("Call SetBuyItem with valid item id first!"); return; } ShopItemInfo inf = ShopDataBridge.Instance.GetItemInfo(m_BuyItemId); //different caption for differen confirmantion (buy, upgrade, add gold, convert gold) int idBuy = 02030020; int idAddFunds = 02030036; //format caption, different for adding funds string str1 = (m_BuyItemId.ItemType == GuiShop.E_ItemType.Fund) ? TextDatabase.instance[idAddFunds] : TextDatabase.instance[idBuy]; string caption = str1 + " " + inf.NameText; m_Caption_Label.SetNewText(caption); m_Thumbnail = GuiBaseUtils.PrepareSprite(m_ScreenLayout, ThumbName(m_BuyItemId.ItemType)); m_Thumbnail.Widget.Show(true, false); //stejne sprity jako ve scrollbaru if (inf.ScrollerWidget != null) { m_Thumbnail.Widget.CopyMaterialSettings(inf.ScrollerWidget); } else { m_Thumbnail.Widget.CopyMaterialSettings(inf.SpriteWidget); } m_SaleRoot.Show(inf.PriceSale, true); if (inf.PriceSale) { m_Sale_Label.SetNewText(inf.DiscountTag); } if (m_Cost != null) { m_Cost.Show(true); if (m_BuyItemId.ItemType == GuiShop.E_ItemType.Fund) { bool isGold = inf.AddGold > 0; m_Cost.SetValue(isGold ? inf.AddGold : inf.AddMoney, isGold, true); } else { m_Cost.SetValue(inf.Cost, inf.GoldCurrency); } } }
// ------ public void SetItem(IResearchItem item) { m_ResearchItem = item; //different caption for differen confirmantion (buy, upgrade, add gold, convert gold) string caption = TextDatabase.instance[m_ResearchItem.GetName()]; m_Caption_Label.SetNewText(caption); m_BigThumbnail.Widget.CopyMaterialSettings(m_ResearchItem.GetImage()); /*if(inf.PriceSale) * { * m_Sale_Label.SetNewText(inf.DiscountTag); * } * /**/ //m_Sale_Label.Widget.Show( false, true); if (m_Cost != null) { m_Cost.Show(true); bool isGold; int cost = m_ResearchItem.GetPrice(out isGold); m_Cost.SetValue(cost, isGold); } }
// ------ public void SetItem(IResearchItem item, int upgradeIndex) { m_ResearchItem = item; m_UpgradeIndex = upgradeIndex; m_Caption_Label.SetNewText(TextDatabase.instance[item.GetUpgradeName(upgradeIndex)]); m_Value_Label.SetNewText(item.GetUpgradeValueText(upgradeIndex)); if (m_Cost != null) { m_Cost.Show(true); WeaponSettings.Upgrade upgrade = m_ResearchItem.GetUpgrade(upgradeIndex); int cost; bool hasEnoughFunds; if (upgrade.MoneyCost > 0) { cost = upgrade.MoneyCost; hasEnoughFunds = ResearchSupport.Instance.HasPlayerEnoughFunds(cost, false); m_Cost.SetValue(cost, false); } else { cost = upgrade.GoldCost; hasEnoughFunds = ResearchSupport.Instance.HasPlayerEnoughFunds(cost, true); m_Cost.SetValue(cost, true); } if (!hasEnoughFunds) { m_AcceptButton.SetDisabled(upgrade.GoldCost > 0 ? false : true); m_Cost.SetMissingFunds(true); } else { m_AcceptButton.SetDisabled(false); m_Cost.SetMissingFunds(false); } } m_UpgradeIcon.SetUpgradeType(item.GetUpgrade(upgradeIndex).ID); m_UpgradeIcon.SetStatus(UpgradeIcon.Status.Active); m_UpgradeIcon.Show(); }
// ------ public void SetItems(int[] items) { m_ResearchGUIDs = items; m_Cost = 0; m_RefundedMoney = 0; m_Cost += m_ResearchGUIDs.Length * GameCloudSettings.REFUND_COST_PER_RESEARCH_ITEM; foreach (int i in m_ResearchGUIDs) { m_RefundedMoney += ResearchSupport.Instance.GetPriceBasedOnGuid(i); } //Debug.Log("Refunded: " + m_RefundedMoney); if (m_CostWidgets != null) { m_CostWidgets.Show(true); m_CostWidgets.SetValue(m_Cost, true); } bool disabled = (m_Cost <= 0) || !(ResearchSupport.Instance.HasPlayerEnoughFunds(m_Cost, true)); m_AcceptButton.SetDisabled(disabled); m_CostWidgets.SetDisabled(disabled); }
public void Show(ShopItemId itemId) { m_PictureSprite = GuiBaseUtils.PrepareSprite(m_Layout, ThumbName(itemId.ItemType)); if (itemId != ShopItemId.EmptyId) { ShopItemInfo inf = ShopDataBridge.Instance.GetItemInfo(itemId); m_NameLabel.Widget.Show(true, false); m_NameLabel.SetNewText(inf.NameText); m_PictureSprite.Widget.Show(true, false); m_PictureSprite.Widget.CopyMaterialSettings(inf.SpriteWidget); //string strDesc = TextDatabase.instance[ inf.Description ]; if (itemId.ItemType == GuiShop.E_ItemType.Hat) { m_SpecInfoLabel.SetNewText(TextDatabase.instance[0208048]); m_SpecInfoLabel.Widget.Show(true, false); } else { m_SpecInfoLabel.Widget.Show(false, false); } m_DescArea.SetNewText(inf.Description); m_DescArea.Widget.SetModify(true); m_DescArea.Widget.Show(true, false); m_OwnedSprite.Widget.Show(inf.Owned, true); //show cost only for what costs money bool showCost = (inf.Cost > 0) && (!inf.Owned || inf.Consumable); m_Cost.SetValue(inf.Cost, inf.GoldCurrency, false); m_Cost.Show(showCost); m_Sale.Show(inf.PriceSale, true); bool showCostBeforeSale = false; if (inf.PriceSale) { m_SaleLabel.SetNewText(inf.DiscountTag); showCostBeforeSale = (inf.CostBeforeSale > 0); m_CostBeforeSale.SetNewText(inf.CostBeforeSale.ToString()); } m_CostBeforeSale.Widget.Show(showCostBeforeSale, true); bool showIAP = ShopDataBridge.Instance.IsIAPFund(itemId) && inf.IAPCost != null; if (showIAP) { m_IAP_Widget.Show(true, true); m_IAP_Cost_Label.SetNewText(inf.IAPCost); } else { m_IAP_Widget.Show(false, true); } #if IAP_USE_MFLIVE //when using MFLive, amount of gold is chosen at the paywall page, so we display just "Gold" without any sales if (inf.AddGold > 0) { m_NameLabel.SetNewText(TextDatabase.instance[2030004]); m_Sale.Show(false, true); } #endif } else { //Debug.Log("Empty id"); m_NameLabel.Widget.Show(false, false); m_PictureSprite.Widget.Show(false, false); m_Cost.Show(false); m_DescArea.Widget.Show(false, false); m_OwnedSprite.Widget.Show(false, false); m_SaleLabel.Widget.Show(false, true); } }
public void UpdateItemButtons() { if (!IsShown) { return; } ShopItemId selId = m_ItemScroller.GetSelectedItem(); if (m_ItemScroller.IsScrolling == false && selId != ShopItemId.EmptyId) { //equip ShopItemInfo inf = ShopDataBridge.Instance.GetItemInfo(selId); bool shopEnabled = GuiFrontendMain.IsVisible; bool isDepleatedItem = (inf.Consumable && inf.OwnedCount <= 0); if (shopEnabled && isDepleatedItem) { m_Buy_Button.Widget.Show(true, true); m_Equip_Button.Widget.Show(false, true); m_Cost.SetValue(inf.Cost, inf.GoldCurrency, false); m_Cost.Show(true); } else { m_Buy_Button.Widget.Show(false, true); m_Equip_Button.Widget.Show(true, true); m_Cost.Show(false); //bool canEquip = (inf != null && !inf.Locked); //TODO_tady muzeme zakazat equip pro locknute itemy bool isSlotWaiting = GuiEquipMenu.Instance.IsSlotWaiting(selId.ItemType, GuiEquipMenu.Instance.SelectedSlotIndex); bool isItemWaiting = GuiEquipMenu.Instance.IsSlotItemWaiting(selId); bool canEquip = (inf != null) && !isSlotWaiting && !isItemWaiting; //nepovol equip skinu pokud uz je uquipnuty if (selId.ItemType == GuiShop.E_ItemType.Skin && m_EquipedItem.Equals(selId)) { canEquip = false; } //nepovol equip boostu pokud uz je vypotrebovany (povol pouze unequip) if (isDepleatedItem && (m_EquipedItem.IsEmpty() || !m_EquipedItem.Equals(selId))) { canEquip = false; } m_Equip_Button.SetDisabled(!canEquip); int strEquip = 02050001; int strUnequip = 02050002; int strSelect = 02050038; int strSwitch = 02050040; int strReplace = 02050042; int txtId = strEquip; if (selId.ItemType == GuiShop.E_ItemType.Skin) { txtId = strSelect; } else if (m_EquipedItem.Equals(selId)) { txtId = strUnequip; } else if (m_EquipedItem.IsEmpty()) { txtId = strEquip; } else if (ShopDataBridge.Instance.IsEquiped(selId)) { //predpokladame ze co je equipnuje je soucasne ve slotu (presnejsi by bylo prohledat sloty). txtId = strSwitch; } else { txtId = strReplace; } m_Equip_Label.SetNewText(txtId); } } else { //m_Equip_Button.Widget.Show(false, true); m_Equip_Button.SetDisabled(true); } }