예제 #1
0
	// ------
	void OnAcceptButton(bool inside)
	{
		if (!inside)
			return;

		WeaponSettings.Upgrade upgrade = m_ResearchItem.GetUpgrade(m_UpgradeIndex);
		if (upgrade.GoldCost > 0 && ResearchSupport.Instance.HasPlayerEnoughFunds(upgrade.GoldCost, true) == false)
		{
			//zobrazit not funds popup
			/*GuiShopNotFundsPopup.Instance.DesiredItem = new ShopItemId((int)upgrade.ParentID, GuiShop.E_ItemType.Weapon);
			GuiShopNotFundsPopup.Instance.UpgradeID   = m_UpgradeIndex;
			Owner.ShowPopup("NotFundsPopup", "", "");*/
			Owner.ShowPopup("ShopMessageBox", TextDatabase.instance[02030091], TextDatabase.instance[02030092], null);
		}
		else
		{
#if !TEMPORARY_UPGRADE_HACK
			int guid = upgrade.GetGUID();
			m_UpgradeCloudAction = new BuyAndFetchPPI(CloudUser.instance.authenticatedUserID, guid);
			GameCloudManager.AddAction(m_UpgradeCloudAction);
#else
				// TEMPORARY CODE
			ResearchSupport.Instance.GetPPI().InventoryList.TMP_CODE_AddWeaponUpgrade( (m_ResearchItem as ResearchItem).weaponID, m_ResearchItem.GetUpgrade(m_UpgradeIndex).ID );
#endif
			GuiPopupResearchWait popik =
							Owner.ShowPopup("ResearchWait", TextDatabase.instance[0113050], TextDatabase.instance[0113060], BuyWaitResultHandler) as
							GuiPopupResearchWait;
			popik.SetActionStatusDelegate(GetActionStatus);
		}
	}
예제 #2
0
    IEnumerator DoUpgradeCoroutine(int upgradeIndex)
    {
        WeaponSettings.Upgrade upgrade = m_ResearchItem.GetUpgrade(upgradeIndex);
        if (upgrade.GoldCost > 0 && ResearchSupport.Instance.HasPlayerEnoughFunds(upgrade.GoldCost, true) == false)
        {
            ShopItemId desired = new ShopItemId((int)upgrade.ParentID, GuiShop.E_ItemType.Weapon);
            ShopItemId reqIAP  = ShopDataBridge.Instance.GetIAPNeededForItem(desired, upgradeIndex);

            if (reqIAP.IsEmpty())
            {
                yield break;
            }

            bool buySucceed = true;
            GuiShopNotFundsPopup.Instance.AddFundsID = reqIAP;
            GuiPopup popup = Owner.ShowPopup("NotFundsPopup",
                                             "",
                                             "",
                                             (inPopup, inResult) =>
            {
                switch (inResult)
                {
                case E_PopupResultCode.Cancel:
                    buySucceed = false;
                    break;

                case E_PopupResultCode.Failed:
                    buySucceed = false;
                    break;
                }
            });

            //Debug.Log("Popup Visible:" + popup.IsVisible);
            while (popup.IsVisible == true)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (buySucceed == false)
            {
                yield break;
            }

            //Debug.Log("IAP success:" + buySucceed);
        }

        if (ResearchSupport.Instance.HasPlayerEnoughFunds(upgrade.GoldCost, true))
        {
            GuiPopupDoUpgrade popik = Owner.ShowPopup("DoUpgrade", "", "", DoUpgradeResultHandler) as GuiPopupDoUpgrade;
            popik.SetItem(m_ResearchItem, upgradeIndex);
        }
    }
예제 #3
0
	// ------
	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();
	}
예제 #4
0
    // -----
    public void SetItem(IResearchItem item)
    {
        m_ResearchItem = item;
        m_Name.SetNewText(m_ResearchItem.GetName());

        m_Description.SetNewText(m_ResearchItem.GetDescription());

        bool isGold;

        // TODO : PROBABLY NOT CORRECT, FUND TYPE IS NOT PROPERLY TESTED:
        m_Price.SetNewText(m_ResearchItem.GetPrice(out isGold).ToString());
        m_Image.Widget.CopyMaterialSettings(m_ResearchItem.GetImage());

        int maxParams = item.GetNumOfParams();

        for (int i = 0; i < maxParams; i++)
        {
            m_Params[i].Name.SetNewText(item.GetParamName(i));
            m_Params[i].Value.SetNewText(item.GetParamValue(i));
            m_Params[i].Value.Widget.Color = item.UpgradeIsAppliedOnParam(i) ? m_UpgradedValueColor : Color.white;
            ShowWidget(m_Params[i].Parent, true);
        }

        for (int i = maxParams; i < ResearchItem.MAX_PARAMS; i++)
        {
            ShowWidget(m_Params[i].Parent, false);
        }

        int maxUpgrades = item.GetNumOfUpgrades();

        if (m_ResearchItem.GetState() == ResearchState.Active)
        {
            ShowWidget(m_UpgradeArea, maxUpgrades > 0);
            ShowWidget(m_PriceArea, false);
        }
        else
        {
            ShowWidget(m_UpgradeArea, false);
            ShowWidget(m_PriceArea, true);
        }

        if (m_ResearchItem.GetState() == ResearchState.Active)
        {
            for (int i = 0; i < maxUpgrades; i++)
            {
                bool ownsUpgrade = item.OwnsUpgrade(i);
                WeaponSettings.Upgrade upgrade = item.GetUpgrade(i);
                m_Upgrades[i].m_UpgradeIcon.SetUpgradeType(upgrade.ID);
                m_Upgrades[i].m_UpgradeIcon.Show();

                isGold = upgrade.GoldCost > 0;
                bool hasEnoughMoney = ResearchSupport.Instance.HasPlayerEnoughFunds(isGold ? upgrade.GoldCost : upgrade.MoneyCost, isGold);
                if (!ownsUpgrade)
                {
                    m_Upgrades[i].m_Name.Widget.Color = Color.white;
                    m_Upgrades[i].m_CostVal.SetNewText(isGold ? upgrade.GoldCost.ToString() : upgrade.MoneyCost.ToString());

                    if (!hasEnoughMoney)
                    {
                        GuiBaseUtils.PendingHint             = E_Hint.Money;
                        m_Upgrades[i].m_Parent.Color         = m_ActiveUpgradeBtnColor;
                        m_Upgrades[i].m_CostVal.Widget.Color = Color.red;
                        m_Upgrades[i].m_UpgradeIcon.SetStatus(UpgradeIcon.Status.Inactive);
                    }
                    else
                    {
                        m_Upgrades[i].m_Parent.Color         = m_ActiveUpgradeBtnColor;
                        m_Upgrades[i].m_CostVal.Widget.Color = Color.white;
                        m_Upgrades[i].m_UpgradeIcon.SetStatus(UpgradeIcon.Status.Active);
                    }
                    ShowWidget(m_Upgrades[i].m_Researched, false);
                    ShowWidget(m_Upgrades[i].m_CostGold, isGold);
                    ShowWidget(m_Upgrades[i].m_CostMoney, !isGold);
                }
                else
                {
                    m_Upgrades[i].m_UpgradeIcon.SetStatus(UpgradeIcon.Status.Active);
                    m_Upgrades[i].m_CostVal.Widget.Color = m_UpgradedValueColor;
                    m_Upgrades[i].m_Name.Widget.Color    = Color.white;
                    m_Upgrades[i].m_Parent.Color         = m_InactiveUpgradeBtnColor;
                    m_Upgrades[i].m_CostVal.SetNewText(item.GetUpgradeValueText(i));
                    ShowWidget(m_Upgrades[i].m_Researched, true);
                    ShowWidget(m_Upgrades[i].m_CostGold, false);
                    ShowWidget(m_Upgrades[i].m_CostMoney, false);
                }
                m_Upgrades[i].m_Name.SetNewText(item.GetUpgradeName(i));
                ShowWidget(m_Upgrades[i].m_Name.Widget, true);
                ShowWidget(m_Upgrades[i].m_CostVal.Widget, true);
                m_Upgrades[i].m_Button.SetDisabled(ownsUpgrade);
                ShowWidget(m_Upgrades[i].m_Button.Widget, true);
            }
            for (int i = maxUpgrades; i < ResearchItem.MAX_UPGRADES; i++)
            {
                m_Upgrades[i].m_UpgradeIcon.Hide();
                ShowWidget(m_Upgrades[i].m_Name.Widget, false);
                ShowWidget(m_Upgrades[i].m_CostGold, false);
                ShowWidget(m_Upgrades[i].m_CostMoney, false);
                ShowWidget(m_Upgrades[i].m_CostVal.Widget, false);
                ShowWidget(m_Upgrades[i].m_Parent, false);
            }
        }
        else
        {
            for (int i = 0; i < ResearchItem.MAX_UPGRADES; i++)
            {
                m_Upgrades[i].m_UpgradeIcon.Hide();
                ShowWidget(m_Upgrades[i].m_Name.Widget, false);
                ShowWidget(m_Upgrades[i].m_CostVal.Widget, false);
                ShowWidget(m_Upgrades[i].m_CostGold, false);
                ShowWidget(m_Upgrades[i].m_CostMoney, false);
            }
        }

        bool unavailable    = m_ResearchItem.GetState() == ResearchState.Unavailable;
        int  cost           = m_ResearchItem.GetPrice(out isGold);
        bool notEnoughMoney = !ResearchSupport.Instance.HasPlayerEnoughFunds(cost, isGold);

        if (unavailable || notEnoughMoney && (m_ResearchItem.GetState() != ResearchState.Active))
        {
            string explanation = item.GetCantBuyExplanation();
            if ((explanation == "") && notEnoughMoney)
            {
                explanation = TextDatabase.instance[0113080];
            }
            m_Explanation.SetNewText(explanation);
            ShowWidget(m_Explanation.Widget, true);
            ShowWidget(m_ResearchButton.Widget, false);

            m_Price.Widget.Color = notEnoughMoney ? Color.red : Color.white;

            if (notEnoughMoney)
            {
                GuiBaseUtils.PendingHint = E_Hint.Money;
            }
        }
        else
        {
            ShowWidget(m_Explanation.Widget, false);
            if (m_ResearchItem.GetState() == ResearchState.Active)
            {
                ShowWidget(m_ResearchButton.Widget, false);
            }
            else
            {
                ShowWidget(m_ResearchButton.Widget, true);
            }
            m_Price.Widget.Color = Color.white;
        }
        m_ResearchButton.SetDisabled(unavailable || notEnoughMoney);
    }