Example #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="UnitData" /> struct.
        /// </summary>
        /// <param name="unit">The unit.</param>
        /// <param name="bonusProvider">The bonus provider.</param>
        /// <param name="useLandTransportData">if set to <c>true</c> land transport data is used instead of the main equipment.</param>
        public UnitData(UnitDecorator unit, IBonusProvider bonusProvider, bool useLandTransportData = false)
        {
            this._unit = unit;
            this._useLandTransportData = useLandTransportData;

            double numStars        = Math.Floor(this._unit.CurrentExperience / 100.0);
            Bonus  experienceBonux = bonusProvider.ExperienceBoni[this._unit.Type.Value] * numStars;
            Bonus  firstHeroBonus  = bonusProvider.GetHeroBonusFor(this._unit.CurrentFirstHero.Value);
            Bonus  secondHeroBonus = bonusProvider.GetHeroBonusFor(this._unit.CurrentSecondHero.Value);
            Bonus  thirdHeroBonus  = bonusProvider.GetHeroBonusFor(this._unit.CurrentThirdHero.Value);
            Bonus  totalHeroBonus  = firstHeroBonus + secondHeroBonus + thirdHeroBonus;

            var experienceBonus = new Bonus
            {
                Initiative  = (Equipment.Initiative != 0) ? experienceBonux.Initiative : 0,
                SoftAttack  = (Equipment.SoftAttack != 0) ? experienceBonux.SoftAttack : 0,
                HardAttack  = (Equipment.HardAttack != 0) ? experienceBonux.HardAttack : 0,
                AirAttack   = (Equipment.AirAttack != 0) ? experienceBonux.AirAttack : 0,
                NavalAttack =
                    (Equipment.NavalAttack != 0) ? experienceBonux.NavalAttack : 0,
                GroundDefense =
                    (Equipment.GroundDefense != 0) ? experienceBonux.GroundDefense : 0,
                AirDefense   = (Equipment.AirDefense != 0) ? experienceBonux.AirDefense : 0,
                CloseDefense =
                    (Equipment.CloseDefense != 0) ? experienceBonux.CloseDefense : 0,
                Range    = (Equipment.Range != 0) ? experienceBonux.Range : 0,
                Movement = (Equipment.Movement != 0) ? experienceBonux.Movement : 0,
                Spotting = (Equipment.Spotting != 0) ? experienceBonux.Spotting : 0,
            };

            var heroBonus = new Bonus
            {
                Initiative    = (Equipment.Initiative != 0) ? totalHeroBonus.Initiative : 0,
                SoftAttack    = (Equipment.SoftAttack != 0) ? totalHeroBonus.SoftAttack : 0,
                HardAttack    = (Equipment.HardAttack != 0) ? totalHeroBonus.HardAttack : 0,
                AirAttack     = (Equipment.AirAttack != 0) ? totalHeroBonus.AirAttack : 0,
                NavalAttack   = (Equipment.NavalAttack != 0) ? totalHeroBonus.NavalAttack : 0,
                GroundDefense =
                    (Equipment.GroundDefense != 0) ? totalHeroBonus.GroundDefense : 0,
                AirDefense   = (Equipment.AirDefense != 0) ? totalHeroBonus.AirDefense : 0,
                CloseDefense = (Equipment.CloseDefense != 0) ? totalHeroBonus.CloseDefense : 0,
                Range        = (Equipment.Range != 0) ? totalHeroBonus.Range : 0,
                Movement     = (Equipment.Movement != 0) ? totalHeroBonus.Movement : 0,
                Spotting     = (Equipment.Spotting != 0) ? totalHeroBonus.Spotting : 0,
            };

            this._bonusInfo = new BonusInfo(heroBonus, experienceBonus);

            this._bonus = experienceBonus + heroBonus;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="UnitData" /> struct.
        /// </summary>
        /// <param name="unit">The unit.</param>
        /// <param name="bonusProvider">The bonus provider.</param>
        /// <param name="useLandTransportData">if set to <c>true</c> land transport data is used instead of the main equipment.</param>
        public UnitData(UnitDecorator unit, IBonusProvider bonusProvider, bool useLandTransportData = false)
        {
            this._unit = unit;
            this._useLandTransportData = useLandTransportData;

            double numStars = Math.Floor(this._unit.CurrentExperience / 100.0);
            Bonus experienceBonux = bonusProvider.ExperienceBoni[this._unit.Type.Value] * numStars;
            Bonus firstHeroBonus = bonusProvider.GetHeroBonusFor(this._unit.CurrentFirstHero.Value);
            Bonus secondHeroBonus = bonusProvider.GetHeroBonusFor(this._unit.CurrentSecondHero.Value);
            Bonus thirdHeroBonus = bonusProvider.GetHeroBonusFor(this._unit.CurrentThirdHero.Value);
            Bonus totalHeroBonus = firstHeroBonus + secondHeroBonus + thirdHeroBonus;

            var experienceBonus = new Bonus
                                  {
                                      Initiative = (Equipment.Initiative != 0) ? experienceBonux.Initiative : 0,
                                      SoftAttack = (Equipment.SoftAttack != 0) ? experienceBonux.SoftAttack : 0,
                                      HardAttack = (Equipment.HardAttack != 0) ? experienceBonux.HardAttack : 0,
                                      AirAttack = (Equipment.AirAttack != 0) ? experienceBonux.AirAttack : 0,
                                      NavalAttack =
                                          (Equipment.NavalAttack != 0) ? experienceBonux.NavalAttack : 0,
                                      GroundDefense =
                                          (Equipment.GroundDefense != 0) ? experienceBonux.GroundDefense : 0,
                                      AirDefense = (Equipment.AirDefense != 0) ? experienceBonux.AirDefense : 0,
                                      CloseDefense =
                                          (Equipment.CloseDefense != 0) ? experienceBonux.CloseDefense : 0,
                                      Range = (Equipment.Range != 0) ? experienceBonux.Range : 0,
                                      Movement = (Equipment.Movement != 0) ? experienceBonux.Movement : 0,
                                      Spotting = (Equipment.Spotting != 0) ? experienceBonux.Spotting : 0,
                                  };

            var heroBonus = new Bonus
                            {
                                Initiative = (Equipment.Initiative != 0) ? totalHeroBonus.Initiative : 0,
                                SoftAttack = (Equipment.SoftAttack != 0) ? totalHeroBonus.SoftAttack : 0,
                                HardAttack = (Equipment.HardAttack != 0) ? totalHeroBonus.HardAttack : 0,
                                AirAttack = (Equipment.AirAttack != 0) ? totalHeroBonus.AirAttack : 0,
                                NavalAttack = (Equipment.NavalAttack != 0) ? totalHeroBonus.NavalAttack : 0,
                                GroundDefense =
                                    (Equipment.GroundDefense != 0) ? totalHeroBonus.GroundDefense : 0,
                                AirDefense = (Equipment.AirDefense != 0) ? totalHeroBonus.AirDefense : 0,
                                CloseDefense = (Equipment.CloseDefense != 0) ? totalHeroBonus.CloseDefense : 0,
                                Range = (Equipment.Range != 0) ? totalHeroBonus.Range : 0,
                                Movement = (Equipment.Movement != 0) ? totalHeroBonus.Movement : 0,
                                Spotting = (Equipment.Spotting != 0) ? totalHeroBonus.Spotting : 0,
                            };

            this._bonusInfo = new BonusInfo(heroBonus, experienceBonus);

            this._bonus = experienceBonus + heroBonus;
        }