// PRIVATE METHODS: -----------------------------------------------------------------------

        private void OnChangeStat(Stats.EventArgs args)
        {
            float current = this.component.GetStat(this.stat.stat.uniqueName);

            switch (this.detect)
            {
            case Detection.OnChange:
                if (!Mathf.Approximately(current, this.value))
                {
                    this.ExecuteTrigger(component.gameObject);
                }
                break;

            case Detection.OnIncrease:
                if (current > this.value)
                {
                    this.ExecuteTrigger(component.gameObject);
                }
                break;

            case Detection.OnDecrease:
                if (current < this.value)
                {
                    this.ExecuteTrigger(component.gameObject);
                }
                break;
            }

            this.value = current;
        }
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private void OnChangeStatusEffect(Stats.EventArgs args)
        {
            switch (this.detect)
            {
            case Detection.OnChange:
                if (args.operation == Stats.EventArgs.Operation.Change)
                {
                    this.ExecuteTrigger(component.gameObject);
                }
                break;

            case Detection.OnIncrease:
                if (args.operation == Stats.EventArgs.Operation.Add)
                {
                    this.ExecuteTrigger(component.gameObject);
                }
                break;

            case Detection.OnDecrease:
                if (args.operation == Stats.EventArgs.Operation.Remove)
                {
                    this.ExecuteTrigger(component.gameObject);
                }
                break;
            }
        }
Ejemplo n.º 3
0
        private void UpdateAttrUI(Stats.EventArgs args)
        {
            Stats stats = this.GetStatsTarget();

            if (!stats)
            {
                return;
            }

            string attrID = this.attribute.attribute.uniqueName;

            if (this.icon)
            {
                this.icon.overrideSprite = stats.GetAttrIcon(attrID);
            }
            if (this.color)
            {
                this.color.color = stats.GetAttrColor(attrID);
            }
            if (this.title)
            {
                this.title.text = stats.GetAttrDescription(attrID);
            }
            if (this.description)
            {
                this.description.text = stats.GetAttrDescription(attrID);
            }
            if (this.shortName)
            {
                this.shortName.text = stats.GetAttrShortName(attrID);
            }

            float curAttr = stats.GetAttrValue(attrID);
            float maxAttr = stats.GetAttrMaxValue(attrID);
            float minAttr = this.attribute.attribute.minValue;

            if (this.value)
            {
                this.value.text = string.Format(
                    this.valueFormat,
                    curAttr,
                    maxAttr,
                    minAttr
                    );
            }

            float percent = Mathf.InverseLerp(minAttr, maxAttr, curAttr);

            this.transitionTargetPercent = percent;
            this.transitionVelocity      = 0f;
            this.transitionTime          = Time.time;

            if ((this.transitionCurrentPercent < percent && !this.smoothTransitionUp) ||
                (this.transitionCurrentPercent > percent && !this.smoothTransitionDown))
            {
                this.transitionCurrentPercent = percent;
            }
        }
Ejemplo n.º 4
0
        private void UpdateStatUI(Stats.EventArgs args)
        {
            Stats stats = this.GetStatsTarget();

            if (!stats)
            {
                return;
            }

            string statID = this.stat.stat.uniqueName;

            if (this.icon)
            {
                this.icon.overrideSprite = stats.GetStatIcon(statID);
            }
            if (this.color)
            {
                this.color.color = stats.GetStatColor(statID);
            }
            if (this.title)
            {
                this.title.text = stats.GetStatTitle(statID);
            }
            if (this.description)
            {
                this.description.text = stats.GetStatDescription(statID);
            }
            if (this.shortName)
            {
                this.shortName.text = stats.GetStatShortName(statID);
            }

            if (this.value)
            {
                this.value.text = stats.GetStat(statID, null).ToString();
            }
            if (this.imageFill)
            {
                this.imageFill.fillAmount = stats.GetStat(statID, null);
            }
        }
Ejemplo n.º 5
0
        private void UpdateStatusEffectsList(Stats.EventArgs args)
        {
            if (this.stats == null)
            {
                return;
            }

            List <string> statusEffectsList = (this.show == StatusEffectType.All
                ? this.stats.GetStatusEffects()
                : this.stats.GetStatusEffects((StatusEffect.Type) this.show)
                                               );

            List <string> removeCandidates = new List <string>(this.statusEffects.Keys);

            foreach (string statusEffectItem in statusEffectsList)
            {
                if (this.statusEffects.ContainsKey(statusEffectItem))
                {
                    removeCandidates.Remove(statusEffectItem);
                    this.statusEffects[statusEffectItem].UpdateStatusEffect();
                }
                else
                {
                    GameObject     instance       = Instantiate(this.prefabStatusEffect, this.container);
                    StatusEffectUI statusEffectUI = instance.GetComponentInChildren <StatusEffectUI>();

                    this.statusEffects.Add(statusEffectItem, statusEffectUI);
                    statusEffectUI.Setup(this.stats, statusEffectItem);
                }
            }

            for (int i = removeCandidates.Count - 1; i >= 0; --i)
            {
                string         removeKey      = removeCandidates[i];
                StatusEffectUI statusEffectUI = this.statusEffects[removeKey];

                Destroy(statusEffectUI.gameObject);
                this.statusEffects.Remove(removeKey);
            }
        }
Ejemplo n.º 6
0
        private void UpdateAttrUI(Stats.EventArgs args)
        {
            Stats stats = this.GetStatsTarget();

            if (stats == null)
            {
                return;
            }

            string attrID = this.attribute.attribute.uniqueName;

            if (this.icon != null)
            {
                this.icon.overrideSprite = stats.GetAttrIcon(attrID);
            }
            if (this.color != null)
            {
                this.color.color = stats.GetAttrColor(attrID);
            }
            if (this.title != null)
            {
                this.title.text = stats.GetAttrDescription(attrID);
            }
            if (this.description != null)
            {
                this.description.text = stats.GetAttrDescription(attrID);
            }
            if (this.shortName != null)
            {
                this.shortName.text = stats.GetAttrShortName(attrID);
            }

            float curAttr = stats.GetAttrValue(attrID);
            float maxAttr = stats.GetAttrMaxValue(attrID);

            if (this.value != null)
            {
                this.value.text = string.Format(
                    this.valueFormat,
                    curAttr,
                    maxAttr
                    );
            }

            if (this.valueFillImage != null)
            {
                this.valueFillImage.fillAmount = (curAttr / maxAttr);
            }

            if (this.valueScaleX != null)
            {
                this.valueScaleX.localScale = new Vector3(
                    (curAttr / maxAttr),
                    this.valueScaleX.localScale.y,
                    this.valueScaleX.localScale.z
                    );
            }

            if (this.valueScaleY != null)
            {
                this.valueScaleY.localScale = new Vector3(
                    this.valueScaleY.localScale.x,
                    (curAttr / maxAttr),
                    this.valueScaleY.localScale.z
                    );
            }
        }