예제 #1
0
        public Damage CalculateDamage(Weapon weapon)
        {
            var roll = Roll();
            var range = weapon.WeaponInfo.MaximumDamage - weapon.WeaponInfo.MinimumDamage;
            var value = weapon.WeaponInfo.MinimumDamage + (range * roll);

            return new Damage(weapon.WeaponInfo.DamageType) { Value = value };
        }
예제 #2
0
        public void PackWeaponInBox()
        {
            var itemFactory = new ItemFactory(new IdResolutionContext(new[] { TestItems.Item(ItemCode.MissileLauncher), }));
            var weaponPacker = new WeaponPacker(new IdGenerator(), itemFactory);
            var itemPacker = new ItemPacker(new[] { weaponPacker });
            var weapon = new Weapon() { WeaponInfo = new WeaponInfo { Code = ItemCode.MissileLauncher} };

            Assert.That(itemPacker.CanPack(weapon), Is.True);
            var weaponInBox = itemPacker.Pack(weapon);

            Assert.That(weaponInBox, Is.Not.Null);
            Assert.That(weaponInBox.ItemInfo, Is.InstanceOf<WeaponInfo>());
        }
예제 #3
0
        public WeaponAttackResult Fire(Weapon weapon)
        {
            if (!DidHit(weapon))
            {
                return Miss(weapon);
            }

            var damage = CalculateDamage(weapon);
            var armour = Target.Statistics.ArmourStrength(weapon.WeaponInfo.DamageType);

            if (damage.Value <= armour.CurrentValue)
            {
                armour.Alter(damage);
                return Hit(damage);
            }

            var hullDamage = new Damage(weapon.WeaponInfo.DamageType) { Value = (damage.Value - armour.CurrentValue) };
            var armourDamage = new Damage(weapon.WeaponInfo.DamageType) { Value = (armour.CurrentValue) };

            armour.Alter(armourDamage);
            Target.Statistics[ShipStatistic.HullIntegrity].Alter(hullDamage);

            return Hit(armourDamage, hullDamage);
        }
예제 #4
0
파일: HardPoint.cs 프로젝트: andy-uq/Echo
 public void EquipWeapon(Weapon weapon)
 {
     Weapon = weapon;
     Weapon.Location = Ship;
 }
예제 #5
0
        public void SetUp()
        {
            _random = new Mock<IRandom>(MockBehavior.Strict);

            Func<ShipState, ObjectBuilder<Ship>> ship = state => Ship.Builder.Build(null, state);
            _target = new Ship {Statistics = new ShipStatistics(Stats())};
            _weapon = new Weapon();

            _combatFactory = (state, idResolver) => new AttackShipCombat(_random.Object) { Ship = ship(state).Build(idResolver), Target = _target };
            _combat = _combatFactory(new ShipState(ItemCode.LightFrigate), new IdResolutionContext(new[] { new ShipInfo() { Code = ItemCode.LightFrigate } }));
        }
예제 #6
0
파일: HardPoint.cs 프로젝트: andy-uq/Echo
 public void EquipWeapon(Weapon weapon)
 {
     Weapon = weapon;
     Weapon.HardPoint = this;
     Weapon.Position = new Position(Ship, Vector.Zero);
 }
예제 #7
0
파일: Blueprint.cs 프로젝트: andy-uq/Echo
        public override IItem CreateItem()
        {
            var item = new Weapon(this);

            return item;
        }
예제 #8
0
        protected WeaponAttackResult Miss(Weapon weapon)
        {
            return new WeaponAttackResult
            {
                Ship = Ship,
                Target = Target,

                Hit = false,
            };
        }
예제 #9
0
 public double ChanceToHit(Weapon weapon)
 {
     return 1.0;
 }
예제 #10
0
 private bool DidHit(Weapon weapon)
 {
     var roll = Roll();
     return (roll < ChanceToHit(weapon));
 }
예제 #11
0
파일: WeaponTests.cs 프로젝트: andy-uq/Echo
 public void ObjectTypeIsWeapon()
 {
     var weapon = new Weapon();
     Assert.That(weapon.ObjectType, Is.EqualTo(ObjectType.Weapon));
 }