Ejemplo n.º 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);
		}
	}
Ejemplo n.º 2
0
    // ------
    public bool OwnsUpgrade(int index)
    {
        WeaponSettings.Upgrade upgrade = GetUpgrade(index);

        if (upgrade != null)
        {
            return(ResearchSupport.Instance.GetPPI().InventoryList.OwnsWeaponUpgrade(weaponID, upgrade.ID));
        }

        return(false);
    }
Ejemplo n.º 3
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);
        }
    }
Ejemplo n.º 4
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();
	}
Ejemplo n.º 5
0
    // ------
    float GetModificator(E_WeaponUpgradeID upgradeID, bool checkOwnership)
    {
        float modif = 1.0f;

        if (weaponID == E_WeaponID.None)
        {
            return(0);
        }

        int upgradeNum = GetNumOfUpgrades();

        for (int i = 0; i < upgradeNum; i++)
        {
            WeaponSettings.Upgrade upgrade = GetUpgrade(i);
            if ((upgrade.ID == upgradeID) && (!checkOwnership || OwnsUpgrade(i)))
            {
                modif += upgrade.Modifier;
            }
        }
        return(modif);
    }
Ejemplo n.º 6
0
    // ------
    public int GetUpgradeName(int index)
    {
        WeaponSettings.Upgrade upgrade = GetUpgrade(index);

        if (upgrade != null)
        {
            switch (upgrade.ID)
            {
            case E_WeaponUpgradeID.Dispersion:
                return(0112040);

            case E_WeaponUpgradeID.AimingFov:
                return(0112070);

            case E_WeaponUpgradeID.BulletSpeed:
                return(0112050);

            case E_WeaponUpgradeID.ClipSize:
                return(0112030);

            case E_WeaponUpgradeID.Damage:
                return(0112020);

            case E_WeaponUpgradeID.AmmoSize:
                return(0112060);

            case E_WeaponUpgradeID.Silencer:
                return(0112080);

            case E_WeaponUpgradeID.FireTime:
                return(0112090);

            default:
                Error("unknown index!");
                break;
            }
        }
        return(0);
    }
Ejemplo n.º 7
0
    List <WeaponSettings.Upgrade> CollectUpgrades(ResearchItem item, int money)
    {
        List <WeaponSettings.Upgrade> result = new List <WeaponSettings.Upgrade>();

        int count = item.GetNumOfUpgrades();

        for (int idx = 0; idx < count; ++idx)
        {
            if (item.OwnsUpgrade(idx) == true)
            {
                continue;
            }

            WeaponSettings.Upgrade upgrade = item.GetUpgrade(idx);
            if (upgrade.MoneyCost > money)
            {
                continue;
            }

            result.Add(upgrade);
        }

        return(result);
    }
Ejemplo n.º 8
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);
    }
Ejemplo n.º 9
0
    // ------
    public string GetUpgradeValueText(int index)
    {
        string text = "";         //TextDatabase.instance[GetUpgradeName(index)];

        WeaponSettings settings = WeaponSettingsManager.Instance.Get(weaponID);

        WeaponSettings.Upgrade upgrade = GetUpgrade(index);
        if (upgrade != null)
        {
            switch (upgrade.ID)
            {
            case E_WeaponUpgradeID.Dispersion:
                if (upgrade.Modifier <= 0)
                {
                    float upgradeVal = 100 * ((ResearchItem.MAX_DISPERSION - settings.BaseData.Dispersion * (1 + upgrade.Modifier)) /
                                              (ResearchItem.MAX_DISPERSION - settings.BaseData.Dispersion) - 1);
                    text += "+ " + (upgradeVal >= 10 ? upgradeVal.ToString("0") : upgradeVal.ToString("0.0")) + "%";
                }
                else
                {
                    text += (upgrade.Modifier * 100) + "%";
                }
                break;

            case E_WeaponUpgradeID.BulletSpeed:
            case E_WeaponUpgradeID.ClipSize:
            case E_WeaponUpgradeID.Damage:
                if (upgrade.Modifier >= 0)
                {
                    text += "+ " + (upgrade.Modifier * 100) + "%";
                }
                else
                {
                    text += (upgrade.Modifier * 100) + "%";
                }
                break;

            case E_WeaponUpgradeID.AimingFov:
            case E_WeaponUpgradeID.FireTime:

                if (upgrade.Modifier >= 0)
                {
                    text += (-upgrade.Modifier * 100) + "%";
                }
                else
                {
                    text += "+ " + (-upgrade.Modifier * 100) + "%";
                }
                break;

            case E_WeaponUpgradeID.AmmoSize:
                text += "+ " + upgrade.Modifier;
                break;

            case E_WeaponUpgradeID.Silencer:
                break;

            default:
                Error("unknown index!");
                break;
            }
        }

        return(text);
    }