public void ToStat(StatDecorator dec)
 {
     dec.stat         = ItemManager.database.statDefinitions.FirstOrDefault(o => o.ID == statID);
     dec.value        = value;
     dec.actionEffect = actionEffect;
     dec.isFactor     = isFactor;
 }
 public void FromStat(StatDecorator dec)
 {
     this.statID       = dec.stat.ID;
     this.value        = dec.value;
     this.actionEffect = dec.actionEffect;
     this.isFactor     = dec.isFactor;
 }
        public StatDecorator ToStat()
        {
            var dec = new StatDecorator();

            ToStat(dec);

            return(dec);
        }
예제 #4
0
        public static void SetItemProperty(IEquippableCharacter character, StatDecorator stat, SetItemPropertiesAction action, bool fireEvents = true)
        {
            Assert.IsNotNull(character, "Null player object passed, make sure the InventoryPlayerManager.instance.currentPlayer is set!");

            float multiplier = GetMultiplier(action);

            character.stats.Set(stat, multiplier);
        }
 public StatDecoratorSerializationModel(StatDecorator decorator)
 {
     FromStat(decorator);
 }
예제 #6
0
        public void Set(StatDecorator stat, float multiplier = 1f, bool fireEvents = true)
        {
            Assert.IsNotNull(stat, "Given stat is null");
            Assert.IsNotNull(stat.stat, "Given stat's definition is null");
            var s = Get(stat.stat.category, stat.stat.statName);

            if (s == null)
            {
                return;
            }

            switch (stat.actionEffect)
            {
            case StatDecorator.ActionEffect.Add:

                if (stat.isFactor)
                {
                    s.ChangeFactorMax((stat.floatValue - 1.0f) * multiplier, true, fireEvents);
                }
                else
                {
                    s.ChangeMaxValueRaw(stat.floatValue * multiplier, true, fireEvents);
                }

                break;

            case StatDecorator.ActionEffect.AddExperience:

                if (stat.isFactor)
                {
                    s.SetExperience(s.currentExperience * (stat.floatValue * multiplier), fireEvents);
                }
                else
                {
                    s.ChangeExperience(stat.floatValue * multiplier, fireEvents);
                }

                break;

            case StatDecorator.ActionEffect.Restore:

                if (stat.isFactor)
                {
                    s.ChangeCurrentValueRaw((s.currentValue * (stat.floatValue - 1.0f)) * multiplier, fireEvents);
                }
                else
                {
                    s.ChangeCurrentValueRaw(stat.floatValue * multiplier, fireEvents);
                }

                break;

            case StatDecorator.ActionEffect.Decrease:

                if (stat.isFactor)
                {
                    s.ChangeCurrentValueRaw(-((s.currentValue * (stat.floatValue - 1.0f)) * multiplier), fireEvents);
                }
                else
                {
                    s.ChangeCurrentValueRaw(-(stat.floatValue * multiplier), fireEvents);
                }

                break;

            default:
                DevdogLogger.LogWarning("Action effect" + stat.actionEffect + " not found.");
                break;
            }
        }