Beispiel #1
0
        public void RemoveModifier(GameValueModifier modifier, int count, int senderKey, int modifierKey)
        {
            if (modifier.modifyValueComponent == GameValueComponent.BaseValue)
            {
                return;
            }
            if (modifier.modifyValueComponent == GameValueComponent.BaseMinValue)
            {
                return;
            }
            if (modifier.modifyValueComponent == GameValueComponent.BaseMaxValue)
            {
                return;
            }

            // if (modifier.isPermanent) {

            // }
            // else {
            GameValueModifier existingModifier = GetModifier(senderKey, modifierKey);

            if (existingModifier != null)
            {
                existingModifier.count -= count;
                if (existingModifier.count <= 0)
                {
                    modifiers.Remove(existingModifier);
                }
            }
            // }
        }
        public void OnItemConsumed(Inventory inventory, ItemBehavior item, int count, int equipSlot)
        {
            Actor actor = inventory.GetComponent <Actor>();

            if (actor != null)
            {
                for (int i = 0; i < consumeBuffs.Length; i++)
                {
                    for (int x = 0; x < consumeBuffs[i].buffs.Length; x++)
                    {
                        GameValueModifier mod = consumeBuffs[i].buffs[x];

                        if (
                            mod.modifyValueComponent == GameValue.GameValueComponent.Value ||
                            mod.modifyValueComponent == GameValue.GameValueComponent.MinValue ||
                            mod.modifyValueComponent == GameValue.GameValueComponent.MaxValue
                            )
                        {
                            Debug.LogError("non permanent stacked buff found in OnItemConsumed. Buff: " + consumeBuffs[i].name + " on " + name);
                            break;
                        }
                    }

                    actor.AddBuffs(consumeBuffs[i], count, item.GetInstanceID());
                }
            }
        }
Beispiel #3
0
        public GameValueModifier(GameValueModifier template, int count, int senderKey, int modifierKey)
        {
            this.senderKey   = senderKey;
            this.modifierKey = modifierKey;
            this.count       = count;

            gameValueName        = template.gameValueName;
            modifyValueComponent = template.modifyValueComponent;
            modifyBehavior       = template.modifyBehavior;
            modifyValue          = template.modifyValue;
        }
Beispiel #4
0
        public void AddModifier(GameValueModifier modifier, int count, int senderKey, int modifierKey)
        {
            //permanent modifiers
            if (modifier.modifyValueComponent == GameValueComponent.BaseValue)
            {
                baseValue = modifier.Modify(baseValue);
                return;
            }
            if (modifier.modifyValueComponent == GameValueComponent.BaseMinValue)
            {
                baseMinValue = modifier.Modify(baseMinValue);
                return;
            }
            if (modifier.modifyValueComponent == GameValueComponent.BaseMaxValue)
            {
                baseMaxValue = modifier.Modify(baseMaxValue);
                return;
            }

            // if (modifier.isPermanent) {
            // if (modifier.modifyComponent == GameValueComponent.Value) {
            //     baseValue = modifier.Modify(baseValue);
            // }
            // if (modifier.modifyComponent == GameValueComponent.MinValue) {
            //     baseMinValue = modifier.Modify(baseMinValue);
            // }
            // if (modifier.modifyComponent == GameValueComponent.MaxValue) {
            //     baseMaxValue = modifier.Modify(baseMaxValue);
            // }
            // }
            // else {
            GameValueModifier existingModifier = GetModifier(senderKey, modifierKey);

            if (existingModifier != null)
            {
                existingModifier.count += count;
            }
            else
            {
                modifiers.Add(new GameValueModifier(modifier, count, senderKey, modifierKey));
            }
            // }
        }