コード例 #1
0
ファイル: Beast.cs プロジェクト: Vaysman/Nightmare
        /// <summary>
        /// Может быть больше одной атаки за раз.
        /// Последовательно должны быть вычеслены Защита, Мощь, Спец.Атака
        /// от соответствующих базовых параметров.
        /// 
        /// </summary>
        /// <returns></returns>
        public List<Attack> GetAttacks()
        {
            var result = new Attack {
                Defence = 0,
                Power = BaseAttack,
                Special = 0
            };

            var val = BaseAttack;

            if (IsFlying == 1) {
                val = val + (int) (Level*0.7m);
            }
            result.Special += val;

            if (IsFlying == 1) {
                val = (int) (Defence*1.2m);
            }
            result.Defence += val;

            if (IsStomping > 0) {
                val = result.Power + IsStomping;
            }
            result.Power = val;

            if (IsStomping > 0) {
                val = result.Special + IsStomping;
            }
            result.Special += val;

            if (IsStunned()) {
                val = Stunned;
            }

            result.Defence -= val;

            // If beast with IsPoison ability he can attack twice
            return IsPoison == 0
                ? new List<Attack> {result}
                : new List<Attack> {result, result};
        }
コード例 #2
0
ファイル: Character.cs プロジェクト: Vaysman/Nightmare
        /// <summary>
        /// Рассчет атак (сила и защита) на основе одетой одежды, оружия\щитов
        /// </summary>
        /// <returns></returns>
        public List<Attack> GetAttacks()
        {
            var weapons = new List<Weapon>();
            var shields = new List<Shield>();
            var wears = new List<Wear>();

            foreach (var item in Bag) {
                if (item.Type == "W") {
                    var weapon = ((Weapon) item);
                    if (!weapon.Equiped == false) {
                        weapons.Add(weapon);
                    }
                }
                if (item.Type == "S") {
                    var shield = ((Shield) item);
                    if (!shield.Equiped == false) {
                        shields.Add(shield);
                    }
                }
                if (item.Type == "Wr") {
                    var wear = ((Wear) item);
                    if (wear.Equiped == false) {
                        wears.Add(wear);
                    }
                }
            }

            var attack = new Attack {
                // power consist of a number different variable and parameters. The main of them and the basement is
                // the GetAttacks parameter. Then it should be summarized with bonus power depends on level.
                // Finally it adds attack abilities from wears.
                Power = (int) (weapons.Sum(i => i.Attack) + weapons.Sum(i => i.Attack)*Level*0.5m + wears.Sum(i => i.Attack) + wears.Sum(i => i.Attack)*Level*0.2m),
                Defence = (int) (shields.Sum(i => i.Defence) + shields.Sum(i => i.Defence)*Level*0.5m + wears.Sum(i => i.Defence) + wears.Sum(i => i.Defence)*Level*0.2m),
                Special = 0
            };

            return new List<Attack> {attack};
        }