Exemple #1
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;
        }
Exemple #2
0
        private void CalcSurvivalStats()
        {
            // Расчёт бонусов вынести в отдельный сервис, который покрыть модульными тестами
            // На вход принимает SurvivalData. SurvivalData дожен содержать метод увеличение диапазона характеристики.
            Survival.ResetStats();

            for (var i = 0; i < EquipmentCarrier.Count(); i++)
            {
                var equipment = EquipmentCarrier[i];
                if (equipment == null)
                {
                    return;
                }

                var rules = equipment.Scheme.Equip.Rules;

                if (rules == null)
                {
                    return;
                }

                foreach (var rule in rules)
                {
                    switch (rule.Type)
                    {
                    case EquipCommonRuleType.Health:
                        BonusToHealth(rule.Level, rule.Direction);
                        break;

                    case EquipCommonRuleType.HealthIfNoBody:

                        var requirementsCompleted = true;

                        for (var slotIndex = 0; slotIndex < EquipmentCarrier.Count(); slotIndex++)
                        {
                            if ((EquipmentCarrier.Slots[slotIndex].Types & EquipmentSlotTypes.Body) > 0)
                            {
                                if (EquipmentCarrier[slotIndex] != null)
                                {
                                    requirementsCompleted = false;
                                    break;
                                }
                            }
                        }

                        if (requirementsCompleted)
                        {
                            BonusToHealth(rule.Level, rule.Direction);
                        }

                        break;
                    }
                }
            }
        }
        private void FillSurvivalBonusesFromEquipments([NotNull, ItemNotNull] ref List <SurvivalStatBonus> bonusList)
        {
            for (var i = 0; i < EquipmentCarrier.Count(); i++)
            {
                var equipment = EquipmentCarrier[i];
                if (equipment == null)
                {
                    continue;
                }

                var rules = equipment.Scheme.Equip.Rules;

                if (rules == null)
                {
                    continue;
                }

                foreach (var rule in rules)
                {
                    switch (rule.Type)
                    {
                    case EquipCommonRuleType.Health:
                        BonusToHealth(rule.Level, rule.Direction, ref bonusList);
                        break;

                    case EquipCommonRuleType.HealthIfNoBody:

                        var requirementsCompleted = true;

                        for (var slotIndex = 0; slotIndex < EquipmentCarrier.Count(); slotIndex++)
                        {
                            if ((EquipmentCarrier.Slots[slotIndex].Types & EquipmentSlotTypes.Body) > 0)
                            {
                                if (EquipmentCarrier[slotIndex] != null)
                                {
                                    requirementsCompleted = false;
                                    break;
                                }
                            }
                        }

                        if (requirementsCompleted)
                        {
                            BonusToHealth(rule.Level, rule.Direction, ref bonusList);
                        }

                        break;

                    case EquipCommonRuleType.HungerResistance:
                        BonusToDownPass(SurvivalStatType.Satiety, rule.Level, rule.Direction, ref bonusList);
                        break;
                    }
                }
            }
        }
Exemple #4
0
        public HumanPerson(PersonScheme scheme, TacticalActScheme defaultActScheme, IEvolutionData evolutionData)
        {
            Scheme            = scheme ?? throw new ArgumentNullException(nameof(scheme));
            _defaultActScheme = defaultActScheme ?? throw new ArgumentNullException(nameof(defaultActScheme));
            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 = evolutionData;

            if (EvolutionData != null)
            {
                EvolutionData.PerkLeveledUp += EvolutionData_PerkLeveledUp;
            }

            CombatStats = new CombatStats();
            ClearCombatStats((CombatStats)CombatStats);

            if (EvolutionData != null)
            {
                CalcCombatStats(CombatStats, EvolutionData, Effects);
            }
            TacticalActCarrier.Acts = CalcActs(EquipmentCarrier.Equipments, CombatStats);

            Survival = new SurvivalData();
            Survival.StatCrossKeyValue += Survival_StatCrossKeyValue;
        }