Ejemplo n.º 1
0
        public GameValueModifier(GameValueModifier template, int count, int key, string description)
        {
            this.key         = key;
            this.count       = count;
            this.description = description;

            gameValueName        = template.gameValueName;
            modifyValueComponent = template.modifyValueComponent;
            modifyBehavior       = template.modifyBehavior;
            modifyValue          = template.modifyValue;
        }
Ejemplo n.º 2
0
        public string GetModifiersSummary()
        {
            string r = "";

            for (int i = 0; i < modifiers.Count; i++)
            {
                GameValueModifier m = modifiers[i];
                r += m.description + ": " + m.modifyValueComponent + " " + ModifyBehaviorString(m.modifyBehavior) + m.modifyValue + (m.isStackable ? "(" + m.count + ")" : "") + "\n";
            }

            return(r);
        }
Ejemplo n.º 3
0
        void ModifyPermanent(GameValueModifier modifier)
        {
            float origValue = GetValue();

            if (modifier.modifyValueComponent == GameValueComponent.BaseValue)
            {
                baseValue = modifier.Modify(baseValue);
            }

            if (modifier.modifyValueComponent == GameValueComponent.BaseMinValue)
            {
                if (!valueCapped)
                {
                    Debug.LogWarning("Game Value '" + name + "' is uncapped, BaseMinValue cant be modified");
                }
                else
                {
                    capMin = modifier.Modify(capMin);
                }
            }
            if (modifier.modifyValueComponent == GameValueComponent.BaseMaxValue)
            {
                if (!valueCapped)
                {
                    Debug.LogWarning("Game Value '" + name + "' is uncapped, BaseMaxValue cant be modified");
                }
                else
                {
                    capMax = modifier.Modify(capMax);
                }
            }

            float minVal = GetMinValue(false);
            float maxVal = GetMaxValue(false);

            if (valueCapped)
            {
                //clamp the base value
                baseValue = Mathf.Clamp(baseValue, minVal, maxVal);
            }

            BroadcastValueChange(origValue, minVal, maxVal);
        }
Ejemplo n.º 4
0
        // anything modifying base values is permanent, and doesnt get stored in
        // our modifiers list
        public void AddModifier(GameValueModifier modifier, int count, int key, string description)
        {
            if (modifier.isPermanent)
            {
                ModifyPermanent(modifier);
                return;
            }

            float origValue = GetValue();

            if (!valueCapped)
            {
                if (modifier.modifyValueComponent == GameValueComponent.MinValue)
                {
                    Debug.LogWarning("Game Value '" + name + "' is uncapped, MinValue cant be modified");
                    return;
                }
                if (modifier.modifyValueComponent == GameValueComponent.MaxValue)
                {
                    Debug.LogWarning("Game Value '" + name + "' is uncapped, MaxValue cant be modified");
                    return;
                }
            }

            GameValueModifier existingModifier = GetModifier(key);

            if (existingModifier != null)
            {
                if (existingModifier.description != description)
                {
                    Debug.LogWarning("Game Value '" + name + "' Description mismatch for same key! 1) " + description + " :: 2) " + existingModifier.description);
                }
                existingModifier.count += count;
            }
            else
            {
                modifiers.Add(new GameValueModifier(modifier, count, key, description));
            }

            BroadcastValueChange(origValue, GetMinValue(false), GetMaxValue(false));
        }
Ejemplo n.º 5
0
        public void RemoveModifier(GameValueModifier modifier, int count, int key)
        {
            if (modifier.isPermanent)
            {
                return;
            }

            GameValueModifier existingModifier = GetModifier(key);

            if (existingModifier != null)
            {
                float origValue = GetValue();

                existingModifier.count -= count;
                if (existingModifier.count <= 0)
                {
                    modifiers.Remove(existingModifier);
                }

                BroadcastValueChange(origValue, GetMinValue(), GetMaxValue());
            }
        }