public void ResetProgress()
    {
        Upgrade.reset = true;
        XPUI.ResetAll();

        Play();
    }
    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)";
        }
    }
Exemple #3
0
    void  Awake()
    {
        XP           = 0;
        ExperienceUI = FindObjectOfType(typeof(XPUI)) as XPUI;

        //Load player's level.
        if (SaveAndLoad == true)
        {
            XP    = PlayerPrefs.GetFloat("XP");
            Level = PlayerPrefs.GetInt("Level");
            if (Level == 0)
            {
                Level = 1;
            }
        }

        ExperienceUI.SetXPBarUI();
    }
    protected virtual void Oof()
    {
        if (!oofed)
        {
            oofed = true;
            // if( oofSound != null )
            // {
            //  // audSrc.PlayOneShot( oofSound );
            //  var audLeftover = Instantiate( ResLoader.Load( "Prefabs/AudioLeftover" ) );
            //  audLeftover.AddComponent<AudioSource>().PlayOneShot( oofSound );
            //  Destroy( audLeftover,oofSound.length );
            // }
            // else print( "Oof sound is null on " + gameObject.name );

            var enemies = FindObjectsOfType <NewEnemyBase>();
            if (enemies.Length <= 1)
            {
                XPUI.Win();
            }

            Destroy(gameObject);
        }
    }
    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" );
        }
    }