コード例 #1
0
ファイル: PlayerXPUI.cs プロジェクト: cris204/Quemados
    private void AnimateChanges()
    {
        Sequence             xpSequence = DOTween.Sequence();
        ChangeValuesAnimated values     = this.animatedChanges.Dequeue();

        int currentValue   = (int)values.currentValue;
        int finalValue     = (int)values.finalValue;
        int nextLevelValue = (int)values.nextLevelValue;
        int levelValue     = values.levelValue;

        //Text
        Tween textTween = DOTween.To(() => currentValue, x => currentValue = x, finalValue, 0.5f).
                          OnUpdate(delegate()
        {
            this.SetXPText(currentValue);
        });

        //Image
        float xSize = 0;

        xSize = (((float)finalValue - 0) / ((float)this.nextLevelXP - 0));
        Vector2 newSize = this.fillerImageRT.sizeDelta;

        newSize.x = xSize * IMAGE_MAX_SIZE;
        Tween imageTween = this.fillerImageRT.DOSizeDelta(newSize, 0.5f);

        xpSequence.OnStart(() => this.SetLevelText(levelValue));

        xpSequence.OnComplete(delegate()
        {
            this.SetLevelText(levelValue);

            if (finalValue >= nextLevelValue)
            {
                this.SetXPText(0);
                newSize.x = 0;
                this.fillerImageRT.sizeDelta = newSize;
            }

            if (this.animatedChanges != null)
            {
                if (this.animatedChanges.Count > 0)
                {
                    this.AnimateChanges();
                }
                else
                {
                    this.isAnimating = false;
                }
            }
        });

        xpSequence.Append(textTween);
        xpSequence.Join(imageTween);
    }
コード例 #2
0
ファイル: PlayerXPUI.cs プロジェクト: cris204/Quemados
    public void UpdateXP(int newValue)
    {
        ChangeValuesAnimated newChange = new ChangeValuesAnimated(this.currentXp, newValue, this.nextLevelXP, this.currentLevel);

        this.currentXp = newValue;
        this.animatedChanges.Enqueue(newChange);

        if (!this.isAnimating)
        {
            this.isAnimating = true;
            this.AnimateChanges();
        }
    }