Ejemplo n.º 1
0
    void RefreshUI()
    {
        nameText.text    = gameObject.name;
        xpBonusText.text = "xp bonus: " + xpBonusPercent.ToString() + "%";

        var fill = ( float )costLevel / ( float )costTiers.Count;

        if (fill < 0.0f)
        {
            fill = 0.0f;
        }
        if (fill > 1.0f)
        {
            fill = 1.0f;
        }
        fillImage.fillAmount = fill;

        if (costLevel >= costTiers.Count)
        {
            upgradeButton.interactable = false;
            buttonText.text            = "";
        }
        else
        {
            upgradeButton.interactable = XPUI.GetXP() >= costTiers[costLevel];
            buttonText.text            = "Upgrade (" + costTiers[costLevel].ToString() + " XP)";
        }
    }
Ejemplo n.º 2
0
    public void TryPurchase()
    {
        int xp = XPUI.GetXP();

        if (xp >= costTiers[costLevel])
        {
            // print( "yay upgrade" );
            XPUI.AddXP(-costTiers[costLevel]);
            XPUI.AddXPBonus(xpBonusPercent);

            ++costLevel;
            SetLevel();
            RefreshUI();
            var otherUpgrades = FindObjectsOfType <Upgrade>();
            foreach (var other in otherUpgrades)
            {
                other.RefreshUI();
            }
        }
        else
        {
            // print( "no go" );
        }
    }