Exemple #1
0
    public Modifier(float value, ModifierMode mode, ModifierTarget target)
    {
        _value = value;

        _mode   = mode;
        _target = target;
    }
 private int GetModifierValue (ModifierTarget player, ModifierType modifierType)
 {
     ModifierTarget[] correctTargets = { player, ModifierTarget.All };
     return Modifiers.Where (
         i => correctTargets.Contains (i.Target) &&
         i.Modifier == modifierType).Sum (i => i.Value);
 }
Exemple #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="value">The value of this modifier</param>
 /// <param name="method">How the modifier is applied</param>
 /// <param name="target">What stat/mechanic the modifier applies to</param>
 /// <param name="condition">Optional, what conditions are required for the modifier to apply</param>
 public Modifier(int value, ModifierMethod method, ModifierTarget target, params ModifierCondition[] condition)
 {
     this.value      = value;
     this.method     = method;
     this.target     = target;
     this.conditions = new List <ModifierCondition>(condition);
 }
Exemple #4
0
 public static StatModifier Of (ModifierType modifier, ModifierTarget target, int value)
 {
     return new StatModifier {
         Modifier = modifier,
         Target = target,
         Value = value
     };
 }
Exemple #5
0
 private Modifier(string name, ModifierTarget target, ModifierFeature feature, int duration, float magnitude)
 {
     _name      = name;
     _target    = target;
     _feature   = feature;
     _duration  = duration;
     _remaining = duration;
     _magnitude = magnitude;
 }
    public int CalculateDamageTaken (ModifierTarget player, List<CardAttribute.Type> attacker, List<CardAttribute.Type> defender)
    {
        var physDealtDamage = (attacker.Count (q => q == CardAttribute.Type.Attack) - defender.Count (q => q == CardAttribute.Type.Defense)).NonNegative ();
        var magDealtDamage = (attacker.Count (q => q == CardAttribute.Type.MagicAttack) - defender.Count (q => q == CardAttribute.Type.MagicDefense)).NonNegative ();
        var heal = defender.Count (q => q == CardAttribute.Type.Heal);

        var damageTakenOverall = ResolveDamageWithMods (player, physDealtDamage, magDealtDamage) - heal;
        return damageTakenOverall;
    }
Exemple #7
0
        /// <summary>
        /// Creates a new item for the "Variables" <see cref="ListView"/> on the <see
        /// cref="VariablesTab"/> page, containing the specified <see cref="VariableClass"/>
        /// identifier and associated modifier value for the specified <see cref="ModifierTarget"/>.
        /// </summary>
        /// <param name="id">
        /// The <see cref="VariableClass.Id"/> string of a <see cref="VariableClass"/>.</param>
        /// <param name="target">
        /// A <see cref="ModifierTarget"/> value indicating which modifier value to add.</param>
        /// <returns>
        /// The new <see cref="VariableListItem"/> if one was created and added to the "Variables"
        /// <see cref="ListView"/>; otherwise, a null reference.</returns>
        /// <remarks>
        /// <b>CreateVariableItem</b> immediately returns a null reference if the specified
        /// <paramref name="id"/> is not found in the currently selected default <see
        /// cref="VariableModifierDictionary"/>, or if the element that matches the specified
        /// <paramref name="id"/> does not define a modifier value for the specified <paramref
        /// name="target"/>.</remarks>

        private VariableListItem CreateVariableItem(string id, ModifierTarget target)
        {
            if (this._defaultVariableModifiers == null)
            {
                return(null);
            }

            // get default modifier if present
            VariableModifier defaultModifier;

            if (!this._defaultVariableModifiers.TryGetValue(id, out defaultModifier))
            {
                return(null);
            }

            // get value for specified target, if any
            int?defaultValue = defaultModifier.GetByTarget(target);

            if (defaultValue == null)
            {
                return(null);
            }

            // add current modifier if necessary
            VariableModifier currentModifier;

            if (!this._currentVariableModifiers.TryGetValue(id, out currentModifier))
            {
                currentModifier = (VariableModifier)defaultModifier.Clone();
                this._currentVariableModifiers.Add(id, currentModifier);
            }

            // format variable as modifier value
            int?currentValue         = currentModifier.GetByTarget(target);
            VariableListItem newItem = new VariableListItem(id,
                                                            VariableClass.FormatUnscaled(currentValue, target),
                                                            VariableClass.FormatUnscaled(defaultValue.Value, true), target);

            ItemCollection items = VariableList.Items;

            for (int i = 0; i < items.Count; i++)
            {
                VariableListItem item = (VariableListItem)items[i];

                // sort alphabetically, with basic values before modifiers
                if (String.CompareOrdinal(item.Id, newItem.Id) > 0)
                {
                    items.Insert(i, newItem);
                    return(newItem);
                }
            }

            // append to end of list
            items.Add(newItem);
            return(newItem);
        }
Exemple #8
0
        public ModifierTarget ParseTargetType(string target)
        {
            ModifierTarget modifierTarget = ModifierTarget.None;

            Enum.TryParse <ModifierTarget>(target, out modifierTarget);
            if (modifierTarget == ModifierTarget.None)
            {
                Debug.LogError("ModiferType Error! Type=" + target);
            }
            return(modifierTarget);
        }
Exemple #9
0
 public List <Modifier> GetModifiers(ModifierTarget target, ModifierFeature feature)
 {
     try
     {
         return(_modifiersMap[target]
                .Where(m => m.Feature == feature)
                .ToList());
     }
     catch (Exception e)
     {
         return(new List <Modifier>());
     }
 }
Exemple #10
0
        public Modifier(JObject obj)
        {
            this.value  = (int)obj["Value"];
            this.method = (ModifierMethod)(int)obj["Method"];
            this.target = (ModifierTarget)(int)obj["Target"];
            JArray conditionArray = (JArray)obj["Conditions"];

            foreach (JToken c in conditionArray)
            {
                JValue cval = (JValue)c;
                conditions.Add((ModifierCondition)(int)cval);
            }
        }
Exemple #11
0
 private int ResolveDamageWithMods (ModifierTarget player, int physDealtDamageTaken, int magDealtDamageTaken)
 {
     
     int physicalDamageTotal = (physDealtDamageTaken +
                               GetModifierValue (player, ModifierType.PhysicalDamage) -
                               GetModifierValue (player, ModifierType.PhysicalDefence)).NonNegative ();
     int magicalDamageTaken = (magDealtDamageTaken +
                              GetModifierValue (player, ModifierType.MagicalDamage) -
                              GetModifierValue (player, ModifierType.MagicalDefence)).NonNegative ();
     int heal = GetModifierValue (player, ModifierType.Heal);
     int unblockableDamage = GetModifierValue (player, ModifierType.Damage);
     var damageTakenOverall = (physicalDamageTotal + magicalDamageTaken + unblockableDamage) - heal;
     return damageTakenOverall;
 }
Exemple #12
0
        private void Awake()
        {
            _playerState     = FindObjectOfType <PlayerState>();
            _modifierManager = FindObjectOfType <ModifierManager>();

            GetComponentInChildren <Text>().text = type.ToString();

            _button = GetComponent <Button>();

            _button.onClick.AddListener(() =>
                                        Messenger <ModifierType.Type> .Broadcast(GameEvent.MODIFIER_USED, type)
                                        );

            _target  = ModifierType.GetTarget(type);
            _feature = ModifierType.GetFeature(type);
        }
Exemple #13
0
    public FleetVitalModifier(string reason, int duration, float value, FleetVitalType type, ModifierSetting setting, ModifierMode mode, ModifierTarget target) : base(value, mode, target)
    {
        _reason   = reason;
        _duration = duration;

        _type    = type;
        _setting = setting;

        isInfinite = duration < 0;
    }
Exemple #14
0
 public MainShipModifier(ModifierTarget target)
 {
     this.target = target;
     ModifierManager.Instance.RegisterMainShipModifier(this);
 }
Exemple #15
0
 public FunctionBlockModifier(ModifierTarget target, uint instanceID)
 {
     this.target     = target;
     this.instanceID = instanceID;
 }
Exemple #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="value"></param>
 /// <param name="method"></param>
 /// <param name="target"></param>
 /// <param name="duration"></param>
 /// <param name="condition"></param>
 public ModifierTemporary(int value, ModifierMethod method, ModifierTarget target, int duration, params ModifierCondition[] condition) : base(value, method, target, condition)
 {
     this.duration  = duration;
     this.turnsLeft = duration;
 }
 public VitalModifier(VitalType type, float value, ModifierMode mode, ModifierTarget target) : base(value, mode, target)
 {
     _type = type;
 }