示例#1
0
        private ITacticalAct[] CalcActs(IEnumerable <Equipment> equipments, ICombatStats combatStats)
        {
            if (equipments == null)
            {
                throw new ArgumentNullException(nameof(equipments));
            }

            var actList = new List <ITacticalAct>();

            var defaultAct = new TacticalAct(1, _defaultActScheme, combatStats);

            actList.Insert(0, defaultAct);

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

                foreach (var actScheme in equipment.Acts)
                {
                    var equipmentPower = CalcEquipmentEfficient(equipment);
                    var act            = new TacticalAct(equipmentPower, actScheme, combatStats);

                    actList.Insert(0, act);
                }
            }

            return(actList.ToArray());
        }
示例#2
0
        private float CalcEfficient(float baseEfficient,
                                    TacticalActScheme scheme,
                                    float equipmentPower,
                                    ICombatStats stats)
        {
            if (stats == null)
            {
                throw new ArgumentNullException(nameof(stats));
            }

            var sum = 0f;

            foreach (var dependecyItem in scheme.Dependency)
            {
                var factStat = stats.Stats.SingleOrDefault(x => x.Stat == dependecyItem.Stat);
                if (factStat == null)
                {
                    continue;
                }

                var factStatValue = factStat.Value / 10f;

                var dependencyEfficient = baseEfficient * equipmentPower * factStatValue;
                sum += dependencyEfficient;
            }

            return((float)Math.Ceiling(sum));
        }
示例#3
0
 public TacticalAct(float equipmentPower, TacticalActScheme scheme, ICombatStats stats)
 {
     Scheme       = scheme;
     Stats        = scheme.Stats;
     MinEfficient = CalcEfficient(Stats.Efficient.Min, scheme, equipmentPower, stats);
     MaxEfficient = CalcEfficient(Stats.Efficient.Max, scheme, equipmentPower, stats);
 }
示例#4
0
        private static void CalcCombatStats(ICombatStats combatStats, IEvolutionData evolutionData, EffectCollection effects)
        {
            var bonusDict = new Dictionary <CombatStatType, float>();

            var archievedPerks = evolutionData.Perks.Where(x => x.CurrentLevel != null).ToArray();

            foreach (var archievedPerk in archievedPerks)
            {
                var currentLevel       = archievedPerk.CurrentLevel;
                var currentLevelScheme = archievedPerk.Scheme.Levels[currentLevel.Primary];

                if (currentLevelScheme.Rules == null)
                {
                    continue;
                }

                for (var i = 0; i <= currentLevel.Sub; i++)
                {
                    foreach (var rule in currentLevelScheme.Rules)
                    {
                        var ruleType = rule.Type;
                        switch (ruleType)
                        {
                        case PersonRuleType.Melee:
                            AddStatToDict(bonusDict, CombatStatType.Melee, PersonRuleLevel.Lesser, PersonRuleDirection.Positive);
                            break;

                        case PersonRuleType.Ballistic:
                            AddStatToDict(bonusDict, CombatStatType.Ballistic, PersonRuleLevel.Lesser, PersonRuleDirection.Positive);
                            break;
                        }
                    }
                }
            }

            foreach (var effect in effects.Items)
            {
                foreach (var rule in effect.Rules)
                {
                    AddStatToDict(bonusDict, rule.StatType, rule.Level, PersonRuleDirection.Negative);
                }
            }

            foreach (var bonusItem in bonusDict)
            {
                var stat = combatStats.Stats.SingleOrDefault(x => x.Stat == bonusItem.Key);
                if (stat != null)
                {
                    stat.Value += stat.Value * bonusItem.Value;

                    if (stat.Value <= 1)
                    {
                        stat.Value = 1;
                    }
                }
            }

            foreach (var statItem in combatStats.Stats)
            {
                statItem.Value = (float)Math.Round(statItem.Value, 1);
            }
        }