コード例 #1
0
    void EaseMoney()
    {
        timeElapsedMoney += Time.deltaTime;

        //Ease
        /// variation = change in value
        /// elapsed = current time
        /// delay = duration
        /// offset = startValue

        float variation = targetMoney - orginalMoney;
        float elapsed   = timeElapsedMoney;
        float delay     = 0.7f;
        float offset    = orginalMoney;

        float finalMoney = Ease.CubicOut(variation, elapsed, delay, offset);

        moneyQuantityText.GetComponent <UnityEngine.UI.Text>().text = ((int)finalMoney).ToString();
    }
コード例 #2
0
    void EaseLife()
    {
        int maxLife = GameManager.instance.player.GetComponent <Mortality>().initialHealth;

        timeElapsedLife += Time.deltaTime;

        //Ease
        /// variation = change in value
        /// elapsed = current time
        /// delay = duration
        /// offset = startValue

        float variation = targetLife - orginalLife;
        float elapsed   = timeElapsedLife;
        float delay     = 0.7f;
        float offset    = orginalLife;

        float finalLife = Ease.CubicOut(variation, elapsed, delay, offset);

        lifeText.GetComponent <UnityEngine.UI.Text>().text       = maxLife + " / " + (int)finalLife;
        lifeBar.GetComponent <UnityEngine.UI.Image>().fillAmount = Mathf.Clamp01(finalLife / maxLife);
    }
コード例 #3
0
    void EaseXp()
    {
        int level = GameManager.instance.player.GetComponent <PlayerStatsController>().GetLevelForXP(targetXp);
        int maxXp = GameManager.instance.player.GetComponent <PlayerStatsController>().GetSumXpForLevel(level);

        timeElapsedXp += Time.deltaTime;

        //Ease
        /// variation = change in value
        /// elapsed = current time
        /// delay = duration
        /// offset = startValue

        float variation = targetXp - orginalXp;
        float elapsed   = timeElapsedXp;
        float delay     = 0.7f;
        float offset    = orginalXp;

        float finalXp = Ease.CubicOut(variation, elapsed, delay, offset);

        xpText.GetComponent <UnityEngine.UI.Text>().text       = maxXp + " / " + (int)finalXp;
        xpBar.GetComponent <UnityEngine.UI.Image>().fillAmount = Mathf.Clamp01(finalXp / maxXp);
    }