コード例 #1
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);
            }
        }
コード例 #2
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            GameObject targetGO = this.target.GetGameObject(target);

            if (targetGO == null)
            {
                Debug.LogError("Action Stat Sync: No target defined");
                return(true);
            }

            Stats stats = targetGO.GetComponentInChildren <Stats>();

            if (stats == null)
            {
                Debug.LogError("Action Stat Sync: Could not get Stats component in target");
                return(true);
            }

            this.variable.Set(stats.GetStat(this.stat.stat.uniqueName), target);
            return(true);
        }
コード例 #3
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool Check(GameObject target)
        {
            GameObject targetGO = this.target.GetGameObject(target);

            if (targetGO == null)
            {
                Debug.LogError("Condition Stat: No target defined");
                return(false);
            }

            Stats stats = targetGO.GetComponentInChildren <Stats>();

            if (stats == null)
            {
                Debug.LogError("Condition Stat: Could not get Stats component in target");
                return(false);
            }

            float current = stats.GetStat(this.stat.stat.uniqueName);

            switch (this.compare)
            {
            case Comparison.Greater:        return(current > value.GetValue(target));

            case Comparison.Less:           return(current < value.GetValue(target));

            case Comparison.Equal:          return(Mathf.Approximately(current, value.GetValue(target)));

            case Comparison.Different:      return(!Mathf.Approximately(current, value.GetValue(target)));

            case Comparison.GreaterOrEqual: return(current >= value.GetValue(target));

            case Comparison.LessOrEqual:    return(current <= value.GetValue(target));
            }

            return(false);
        }
コード例 #4
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            if (this.stat != null)
            {
                Stats stats = this.target.GetGameObject(target).GetComponentInChildren <Stats>();
                if (stats == null)
                {
                    Debug.Log("Debug Stat: No Stats found in target");
                    return(true);
                }

                Debug.LogFormat(
                    "Stat {0}: {1}",
                    this.stat.stat.uniqueName,
                    stats.GetStat(this.stat.stat.uniqueName)
                    );
            }
            else
            {
                Debug.LogError("Stat is null");
            }

            return(true);
        }