public void generateLoot(Field f) { Random r = new Random(); int generatedValue = randomGenerator.Next(23); if (0 <= generatedValue && generatedValue <= 3) { int spread = randomGenerator.Next(4) + 1; f.placeObject(new GrenadeWeapon() { Damage = randomGenerator.Next(9) + 5, Range = 1 + randomGenerator.Next(9) + spread, Spread = spread, Ammo = 1 + randomGenerator.Next(3) }); } else if (4 <= generatedValue && generatedValue <= 7) { MeleeWeapon w = new MeleeWeapon() { Damage = randomGenerator.Next(10) + 1 }; w.BrokeChance = (double)(1 + w.Damage/5 + r.Next(4)) / 100; f.placeObject(w); } else if (8 <= generatedValue && generatedValue <= 11) { f.placeObject(new RangedWeapon() { Damage = randomGenerator.Next(10) + 1, Range = randomGenerator.Next(10) + 1, Chance = 0.1 + 0.9*randomGenerator.NextDouble(), Ammo = 10 + r.Next(15) }); } else if (12 <= generatedValue && generatedValue <= 16) { f.placeObject(new Ammo() { Bullets = randomGenerator.Next(8) + 4, Grenades = randomGenerator.Next(3) }); } else if (17 <= generatedValue && generatedValue <= 22) { f.placeObject(new MedKit() { Health = randomGenerator.Next(8) + 3 }); } else { } }
public void WeaponPickupTest() { MeleeWeapon weaponPickup = new MeleeWeapon() { Damage = 10 }; map[0, 0].placeObject(weaponPickup); new PickupCommand(player).execute(); Assert.AreSame(weaponPickup, player.MeleeWeapon); }
public void MultipleWeaponsPickupTest() { MeleeWeapon weaponPickup = new MeleeWeapon() { Damage = 10 }; map[0, 0].placeObject(weaponPickup); MeleeWeapon newerWeapon = new MeleeWeapon() { Damage = 15 }; map[0, 0].placeObject(newerWeapon); new PickupCommand(player).execute(); Assert.AreSame(newerWeapon, player.MeleeWeapon); }
public void MiltipleObjectPickupsTest() { Ammo ammoPickup = new Ammo() { Bullets = 4, Grenades = 1 }; map[0, 0].placeObject(ammoPickup); int playerBullets = player.RangedWeapon.Ammo; int playerGrenades = player.GrenadeWeapon.Ammo; MeleeWeapon weaponPickup = new MeleeWeapon() { Damage = 5 }; map[0, 0].placeObject(weaponPickup); new PickupCommand(player).execute(); Assert.AreEqual(player.RangedWeapon.Ammo, playerBullets + 4); Assert.AreEqual(player.GrenadeWeapon.Ammo, playerGrenades + 1); Assert.AreEqual(weaponPickup, player.MeleeWeapon); }