Пример #1
0
        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();
                }
            }
        }
Пример #2
0
        // 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;
            }
        }
Пример #3
0
 public void DropWeapon(Weapon weapon)
 {
     if (weapon != null)
     {
         weapons.Remove(weapon);
         SelectedWeapon = null;
         weapon.Holder  = null;
         GameWorld.AddGameObject(weapon, GameWorld.ActiveRoom);
         CycleWeapons();
     }
 }
Пример #4
0
        /// <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);
        }
Пример #5
0
        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);
                }
            }
        }