public override void Die() { isAlive = false; int rng = GameWorld.rng.Next(1, 101); if (rng <= lootDropChance) { GameWorld.AddGameObject(selectedWeapon, GameWorld.ActiveRoom); selectedWeapon.Holder = null; } else if (isBoss) { rng = GameWorld.rng.Next(1, 16); if (rng <= lootDropChance) { GameWorld.AddGameObject(new JewelItem(position), GameWorld.ActiveRoom); } } //Randomize walls foreach (Room room in GameWorld.Level.Rooms) { if (room != GameWorld.ActiveRoom) { room.RandomizeWalls(); } } }
// Makes a random GameObject from the Item Class spawn when opened. Has a slight chance of nothing happening public void LootDrop() { ItemAdd(); if (isOpen == true && item != null && didLootDrop == false) { GameWorld.AddGameObject(item, GameWorld.ActiveRoom); didLootDrop = true; } }
public void DropWeapon(Weapon weapon) { if (weapon != null) { weapons.Remove(weapon); SelectedWeapon = null; weapon.Holder = null; GameWorld.AddGameObject(weapon, GameWorld.ActiveRoom); CycleWeapons(); } }
/// <summary> /// Attack with the pistol /// </summary> /// <param name="targetCords">The position the projectile should go to</param> /// <returns></returns> public override ShootResult Attack(Vector2 targetCords) { ShootResult shootResult = base.Attack(targetCords); if (shootResult == ShootResult.Successfull) { ammo--; cooldown = attackSpeed; //Console.WriteLine($"Shoot pistol: {ammo}"); GameWorld.AddGameObject(new Projectile(this, projectileSpeed, targetCords), GameWorld.ActiveRoom); return(shootResult); } return(shootResult); }
public override void OnTakeDamage() { //Chance to drop the first item when taking damage int randomInt = GameWorld.rng.Next(1, 101); const int itemDropChance = 25; if (randomInt <= itemDropChance) { Item item = items.FirstOrDefault(); if (item != null) { items.Remove(item); item.Position = this.position; GameWorld.AddGameObject(item, GameWorld.ActiveRoom); } } }