Esempio n. 1
0
        private static ITacticalAct[] CalcActs(ITacticalActScheme defaultActScheme,
                                               IEnumerable <Equipment> equipments,
                                               EffectCollection effects,
                                               IEnumerable <IPerk> perks)
        {
            if (equipments == null)
            {
                throw new ArgumentNullException(nameof(equipments));
            }

            var actList = new List <ITacticalAct>();

            var defaultAct = CreateTacticalAct(defaultActScheme, equipment: null, effects: effects, perks: perks);

            actList.Insert(0, defaultAct);

            foreach (var equipment in equipments)
            {
                if (equipment == null)
                {
                    continue;
                }

                foreach (var actScheme in equipment.Acts)
                {
                    var act = CreateTacticalAct(actScheme, equipment, effects, perks);

                    actList.Insert(0, act);
                }
            }

            return(actList.ToArray());
        }
Esempio n. 2
0
        public HumanPerson([NotNull] IPersonScheme scheme,
                           [NotNull] ITacticalActScheme defaultActScheme,
                           [NotNull] IEvolutionData evolutionData,
                           [NotNull] ISurvivalRandomSource survivalRandomSource)
        {
            _defaultActScheme = defaultActScheme ?? throw new ArgumentNullException(nameof(defaultActScheme));

            Scheme                = scheme ?? throw new ArgumentNullException(nameof(scheme));
            EvolutionData         = evolutionData ?? throw new ArgumentNullException(nameof(evolutionData));
            _survivalRandomSource = survivalRandomSource ?? throw new ArgumentNullException(nameof(survivalRandomSource));

            Name = scheme.Sid;

            Effects          = new EffectCollection();
            Effects.Added   += Effects_CollectionChanged;
            Effects.Removed += Effects_CollectionChanged;
            Effects.Changed += Effects_CollectionChanged;

            EquipmentCarrier = new EquipmentCarrier(Scheme.Slots);
            EquipmentCarrier.EquipmentChanged += EquipmentCarrier_EquipmentChanged;

            TacticalActCarrier = new TacticalActCarrier();

            EvolutionData.PerkLeveledUp += EvolutionData_PerkLeveledUp;


            CombatStats = new CombatStats();
            ClearCalculatedStats();
            CalcCombatStats();

            TacticalActCarrier.Acts = CalcActs(EquipmentCarrier);

            Survival = new HumanSurvivalData(scheme, survivalRandomSource);
            Survival.StatCrossKeyValue += Survival_StatCrossKeyValue;
        }
Esempio n. 3
0
 public HumanPerson(IPersonScheme scheme,
                    [NotNull] ITacticalActScheme defaultScheme,
                    [NotNull] IEvolutionData evolutionData,
                    [NotNull] ISurvivalRandomSource survivalRandomSource,
                    [NotNull] Inventory inventory) :
     this(scheme, defaultScheme, evolutionData, survivalRandomSource)
 {
     Inventory = inventory;
 }
Esempio n. 4
0
    private void WriteDamageAct(List <string> descriptionLines, ITacticalActScheme act, string actName, string efficient)
    {
        var currentLanguage = _uiSettingService.CurrentLanguage;

        var actImpact         = act.Stats.Offence.Impact;
        var actImpactLangKey  = actImpact.ToString().ToLowerInvariant();
        var impactDisplayName = StaticPhrases.GetValue($"impact-{actImpactLangKey}", currentLanguage);

        var apRankDisplayName = StaticPhrases.GetValue("ap-rank", currentLanguage);

        descriptionLines.Add($"{actName}: {impactDisplayName} {efficient} ({act.Stats.Offence.ApRank} {apRankDisplayName})");
    }
Esempio n. 5
0
        public CombatActModule(
            ITacticalActScheme defaultActScheme,
            IEquipmentModule equipmentModule,
            IEffectsModule effectsModule,
            IEvolutionModule evolutionModule)
        {
            IsActive = true;

            _defaultActScheme = defaultActScheme;
            _equipmentModule  = equipmentModule;
            _effectsModule    = effectsModule;
            _evolutionModule  = evolutionModule;
        }
Esempio n. 6
0
        public CombatActModule(
            ITacticalActScheme defaultActScheme,
            IEquipmentModule equipmentModule,
            IConditionsModule сonditionsModule,
            IEvolutionModule evolutionModule)
        {
            IsActive = true;

            _defaultActScheme = defaultActScheme;
            _equipmentModule  = equipmentModule;
            _сonditionsModule = сonditionsModule;
            _evolutionModule  = evolutionModule;
        }
Esempio n. 7
0
        private static IEnumerable <ITacticalAct> CalcActs(ITacticalActScheme defaultActScheme,
                                                           IEnumerable <Equipment> equipments,
                                                           IEffectsModule effects,
                                                           IEnumerable <IPerk> perks)
        {
            var defaultAct = CreateTacticalAct(defaultActScheme, null, effects, perks);

            yield return(defaultAct);

            var equipmentActs = CalcActsFromEquipments(equipments, effects, perks);

            foreach (var act in equipmentActs)
            {
                yield return(act);
            }
        }
Esempio n. 8
0
        public TacticalAct([NotNull] ITacticalActScheme scheme,
                           [NotNull] Roll efficient,
                           [NotNull] Roll toHit,
                           [CanBeNull] Equipment equipment)
        {
            Scheme = scheme ?? throw new System.ArgumentNullException(nameof(scheme));

            Stats = scheme.Stats ?? throw new System.ArgumentNullException(nameof(scheme));

            Efficient = efficient ?? throw new System.ArgumentNullException(nameof(efficient));

            ToHit = toHit ?? throw new System.ArgumentNullException(nameof(toHit));

            Equipment = equipment;

            Constrains = scheme.Constrains;
        }
Esempio n. 9
0
    private static string GetEfficientString(ITacticalActScheme act)
    {
        var efficient         = act.Stats.Efficient;
        var maxEfficientValue = efficient.Count * efficient.Dice;

        if (maxEfficientValue <= 5)
        {
            return("low");
        }
        else if (6 <= maxEfficientValue && maxEfficientValue <= 8)
        {
            return("normal");
        }
        else
        {
            return("high");
        }
    }
Esempio n. 10
0
    private Sprite CalcIcon(ITacticalActScheme scheme, Equipment equipment)
    {
        var schemeSid = scheme.Sid;

        if (scheme.IsMimicFor != null)
        {
            schemeSid = scheme.IsMimicFor;
        }

        var iconFromActs = Resources.Load <Sprite>($"Icons/acts/{schemeSid}");

        if (iconFromActs == null)
        {
            if (equipment != null)
            {
                var equipmentScheme    = equipment.Scheme;
                var equipmentSchemeSid = equipmentScheme.Sid;
                if (equipmentScheme.IsMimicFor != null)
                {
                    equipmentSchemeSid = equipmentScheme.IsMimicFor;
                }

                var iconFromProps = Resources.Load <Sprite>($"Icons/props/{equipmentSchemeSid}");
                if (iconFromProps == null)
                {
                    var defaultIcon = Resources.Load <Sprite>($"Icons/acts/default");
                    return(defaultIcon);
                }
                else
                {
                    return(iconFromProps);
                }
            }
            else
            {
                var defaultIcon = Resources.Load <Sprite>($"Icons/acts/default");
                return(defaultIcon);
            }
        }
        else
        {
            return(iconFromActs);
        }
    }
Esempio n. 11
0
        private static ITacticalAct CreateTacticalAct([NotNull] ITacticalActScheme scheme,
                                                      [NotNull] Equipment equipment,
                                                      [NotNull] IEffectsModule effects,
                                                      [NotNull][ItemNotNull] IEnumerable <IPerk> perks)
        {
            var toHitModifierValue      = 0;
            var efficientModifierValue  = 0;
            var efficientRollUnmodified = scheme.Stats.Efficient;

            CalcSurvivalHazardOnTacticalAct(effects, ref toHitModifierValue, ref efficientModifierValue);
            CalcPerksBonusesOnTacticalAct(perks, equipment, ref toHitModifierValue, ref efficientModifierValue);

            var toHitRoll     = CreateTacticalActRoll(6, 1, toHitModifierValue);
            var efficientRoll = CreateTacticalActRoll(efficientRollUnmodified.Dice,
                                                      efficientRollUnmodified.Count,
                                                      efficientModifierValue);

            return(new TacticalAct(scheme, efficientRoll, toHitRoll, equipment));
        }
Esempio n. 12
0
        private static ITacticalAct CreateTacticalAct([NotNull] ITacticalActScheme scheme,
                                                      [MaybeNull] Equipment?equipment,
                                                      [NotNull] IConditionsModule сonditionModule,
                                                      [NotNull] IEnumerable <IPerk> perks)
        {
            var toHitModifierValue      = 0;
            var efficientModifierValue  = 0;
            var efficientRollUnmodified = scheme.Stats?.Efficient ?? new Roll(1, 1);

            CalcSurvivalHazardOnTacticalAct(сonditionModule, ref toHitModifierValue, ref efficientModifierValue);
            CalcPerksBonusesOnTacticalAct(perks, equipment, ref toHitModifierValue, ref efficientModifierValue);

            var toHitRoll = CreateTacticalActRoll(6, 1, toHitModifierValue);

            var efficientRoll = CreateTacticalActRoll(efficientRollUnmodified.Dice,
                                                      efficientRollUnmodified.Count,
                                                      efficientModifierValue);

            return(new TacticalAct(scheme, efficientRoll, toHitRoll, equipment));
        }
Esempio n. 13
0
        /// <inheritdoc />
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="propScheme"> Схема экипировки. </param>
        /// <param name="acts"> Действия, которые может дать эта экипировка. </param>
        /// <exception cref="T:System.ArgumentException">
        /// Выбрасывает, если на вход подана схема,
        /// не содержащая характеристики экипировки <see cref="P:Zilon.Core.Schemes.PropScheme.Equip" />.
        /// </exception>
        public Equipment(IPropScheme propScheme,
                         IEnumerable <ITacticalActScheme> acts) :
            base(propScheme)
        {
            if (propScheme.Equip == null)
            {
                throw new ArgumentException("Не корректная схема.", nameof(propScheme));
            }

            if (acts != null)
            {
                Acts = acts.ToArray();
            }
            else
            {
                Acts = new ITacticalActScheme[0];
            }

            Durable = new Stat(EQUIPMENT_DURABLE, 0, EQUIPMENT_DURABLE);
        }
Esempio n. 14
0
        private ITacticalAct CreateTacticalAct(ITacticalActScheme scheme, EffectCollection effects, Equipment equipment)
        {
            var greaterSurvivalEffect = effects.Items.OfType <SurvivalStatHazardEffect>()
                                        .OrderByDescending(x => x.Level).FirstOrDefault();

            if (greaterSurvivalEffect == null)
            {
                return(new TacticalAct(scheme, scheme.Stats.Efficient, new Roll(6, 1), equipment));
            }
            else
            {
                var effecientBuffRule = greaterSurvivalEffect.Rules
                                        .FirstOrDefault(x => x.RollType == RollEffectType.Efficient);

                var toHitBuffRule = greaterSurvivalEffect.Rules
                                    .FirstOrDefault(x => x.RollType == RollEffectType.ToHit);

                var efficientRoll = scheme.Stats.Efficient;
                if (effecientBuffRule != null)
                {
                    var modifiers = new RollModifiers(-1);
                    efficientRoll = new Roll(efficientRoll.Dice, efficientRoll.Count, modifiers);
                }

                Roll toHitRoll;
                if (toHitBuffRule == null)
                {
                    toHitRoll = new Roll(6, 1);
                }
                else
                {
                    var modifiers = new RollModifiers(-1);
                    toHitRoll = new Roll(6, 1, modifiers);
                }

                return(new TacticalAct(scheme, efficientRoll, toHitRoll, equipment));
            }
        }
Esempio n. 15
0
        public CombatAct([NotNull] ITacticalActScheme scheme,
                         [NotNull] Roll efficient,
                         [NotNull] Roll toHit,
                         [MaybeNull] Equipment?equipment)
        {
            Scheme = scheme;

            if (scheme.Stats is null)
            {
                throw new InvalidOperationException();
            }

            Stats = scheme.Stats;

            Efficient = efficient;

            ToHit = toHit;

            Equipment = equipment;

            Constrains = scheme.Constrains;

            CurrentCooldown = scheme.Constrains?.Cooldown != null ? 0 : null;
        }
Esempio n. 16
0
 private static string GetEfficientString(ITacticalActScheme act)
 {
     return($"{act.Stats.Efficient.Count}D{act.Stats.Efficient.Dice}");
 }