Пример #1
0
        /// <summary>
        /// Помещает в список бонус на ХП.
        /// </summary>
        /// <param name="level"> Уровень бонуса. </param>
        /// <param name="direction"> Направление бонуса. </param>
        /// <param name="bonuses"> Аккумулирующий список бонусов.
        /// Отмечен ref, чтобы показать, что изменяется внутри метода. </param>
        private void BonusToHealth(PersonRuleLevel level, PersonRuleDirection direction,
                                   ref List <SurvivalStatBonus> bonuses)
        {
            const SurvivalStatType hpStatType = SurvivalStatType.Health;
            var hpStat = Survival.Stats.SingleOrDefault(x => x.Type == hpStatType);

            if (hpStat != null)
            {
                var bonus = 0;
                switch (level)
                {
                case PersonRuleLevel.Lesser:
                    bonus = 1;
                    break;

                case PersonRuleLevel.Normal:
                    bonus = 3;
                    break;

                case PersonRuleLevel.Grand:
                    bonus = 5;
                    break;

                case PersonRuleLevel.Absolute:
                    bonus = 10;
                    break;
                }

                if (direction == PersonRuleDirection.Negative)
                {
                    bonus *= -1;
                }

                var currentBonus = bonuses.SingleOrDefault(x => x.SurvivalStatType == hpStatType);
                if (currentBonus == null)
                {
                    currentBonus = new SurvivalStatBonus(hpStatType);
                    bonuses.Add(currentBonus);
                }
                currentBonus.ValueBonus += bonus;
            }
        }
Пример #2
0
        private void BonusToDownPass(
            SurvivalStatType statType,
            PersonRuleLevel level,
            PersonRuleDirection direction,
            ref List <SurvivalStatBonus> bonuses)
        {
            var currentBonusValue = 0;
            var directionQuaff    = direction == PersonRuleDirection.Negative ? -1 : 1;

            switch (level)
            {
            case PersonRuleLevel.Lesser:
                currentBonusValue = 1 * directionQuaff;
                break;

            case PersonRuleLevel.Normal:
                currentBonusValue = 2 * directionQuaff;
                break;

            case PersonRuleLevel.Grand:
                currentBonusValue = 5 * directionQuaff;
                break;

            case PersonRuleLevel.Absolute:
                currentBonusValue = 10 * directionQuaff;
                break;

            case PersonRuleLevel.None:
            default:
                Debug.Fail("Предположительно, это ошибка.");
                break;
            }

            var currentBonus = new SurvivalStatBonus(statType)
            {
                DownPassBonus = currentBonusValue
            };

            bonuses.Add(currentBonus);
        }