Esempio n. 1
0
    // ------
    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);
        }
    }
Esempio n. 2
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);
    }