예제 #1
0
        public void PlayerXPGetFillAmountTest()
        {
            PlayerXP xp = PlayerXP.LoadFromJson("PlayerXP");

            xp.points = 0;
            Assert.IsTrue(xp.GetFillAmount() == 0);

            xp.points = xp.maxPoints / 2;
            Assert.IsTrue(xp.GetFillAmount() == 0.5);

            xp.points = xp.maxPoints;
            xp.AddPoints(2);
            Assert.IsTrue(xp.GetFillAmount() <= 1);
        }
예제 #2
0
    /// <summary>
    /// Добавляет опыт
    /// </summary>
    /// <param name="xp"></param>
    public void AddXP(int xp)
    {
        var isLevelUp = playerXP.AddPoints(xp);

        if (isLevelUp)
        {
            xpText.text = playerXP.CurrentLevel.ToString();
        }
        xpBar.fillAmount = playerXP.GetFillAmount();
    }
예제 #3
0
    public bool isOpened = false; //Открыто ли внутриигровое меню

    void Start()
    {
        playerXP = PlayerXP.LoadFromJson("PX");
        //Commented for debug
        //playerXP = PlayerXP.LoadFromJson(PlayerPrefs.GetString("PlayerJson"));
        playerStats        = PlayerStats.LoadFromJson();
        xpBar              = xpBar.GetComponent <Image>();
        xpText             = xpBar.GetComponentInChildren <Text>();
        xpText.text        = playerXP.CurrentLevel.ToString();
        xpBar.fillAmount   = playerXP.GetFillAmount();
        attackAnim         = GetComponentInChildren <PlayerAttackAnimation>();
        healthText         = hpBar.GetComponentInChildren <Text>();
        hpBar              = hpBar.GetComponent <Image>();
        manaText           = manaBar.GetComponentInChildren <Text>();
        manaBar            = manaBar.GetComponent <Image>();
        nameText.text      = playerStats.name;
        money.text         = playerStats.money.ToString();
        inventory          = GetComponent <Inventory>();
        audio              = GetComponentInChildren <AttackAudio>();
        plusMoneyCoroutine = ShowAddedMoney();
    }