Esempio n. 1
0
 /// <summary>
 /// Called by parent class for drawing specific variables at top.
 /// Parent class should automatically check for when it is dirty.
 /// </summary>
 protected override void DrawChildInspector()
 {
     /*public string statName = "";
      * public GameSystem_StatTracker.ModType modType = GameSystem_StatTracker.ModType.Add;
      * public float modValue = 1;*/
     statID   = (TrackedStatType)EditorGUILayout.EnumPopup("Stat ID", statID);
     modType  = (StatTracker.ModType)EditorGUILayout.EnumPopup("Mod Type", modType);
     modValue = EditorGUILayout.FloatField("Mod Value", modValue);
 }
Esempio n. 2
0
        public override void DrawInspector()
        {
            base.DrawInspector();

            textLine = EditorGUILayout.ObjectField
                           ("Text Line", textLine, typeof(TextObject))
                       as TextObject;

            trackedStat = (TrackedStatType)EditorGUILayout.EnumPopup("Tracked Stat", trackedStat);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the stat value.
        /// If no stat exists, returns float.MinValue.
        /// </summary>
        public float GetStatValue(TrackedStatType statType)
        {
            StatData theStat = GetStat(statType);

            if (theStat == null)
            {
                return(float.MinValue);
            }

            return(theStat.currentValue);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns the stat matching the given string.
        /// Returns null if no stat matches.
        /// </summary>
        public StatData GetStat(TrackedStatType statType)
        {
            for (int i = 0; i < sceneStats.Count; i++)
            {
                if (sceneStats[i].id.Equals(statType))
                {
                    return(sceneStats[i]);
                }
            }

            return(null);
        }
Esempio n. 5
0
        //TODO: Setup to be through events, that will make
        //		it MUCH easier to do things like update text
        //		displaying a given stat.
        #region ModStats

        public void ModStat(TrackedStatType statType, ModType modType, float value)
        {
            StatData theStat = GetStat(statType);

            if (theStat == null)
            {
                                #if UNITY_EDITOR
                Debug.LogError("StatTracker.ModStat() could not find stat with given name: " + statType.ToString());
                                #endif
                return;
            }

            float oldStat = theStat.currentValue;

            switch (modType)
            {
            case ModType.Set:
                theStat.currentValue = value;
                break;

            case ModType.Add:
                theStat.currentValue += value;
                break;

            case ModType.Mult:
                theStat.currentValue *= value;
                break;
            }

            float newStat = theStat.currentValue;

            EventData_Gameplay eventData = new EventData_Gameplay();
            eventData.TheStatType  = statType;
            eventData.OldStatValue = oldStat;
            eventData.NewStatValue = newStat;
            GameManager.Events.Broadcast <EventType_Gameplay> ((int)EventType_Gameplay.StatTracker_StatModified, eventData);
        }
Esempio n. 6
0
 public StatData(TrackedStatType id, float value)
 {
     this.id           = id;
     this.startValue   = value;
     this.currentValue = value;
 }
Esempio n. 7
0
 public StatData()
 {
     this.id           = TrackedStatType.None;
     this.startValue   = 0;
     this.currentValue = 0;
 }
Esempio n. 8
0
        private StatTracker.StatData GetStatDataOfType(List <StatTracker.StatData> datas, TrackedStatType statType)
        {
            for (int i = 0; i < datas.Count; i++)
            {
                if (datas[i].id == statType)
                {
                    return(datas[i]);
                }
            }

            return(null);
        }