Beispiel #1
0
        private void MonsterRewards(Monster monster)
        {
            //Monster is dead
            rtbMessages.Text += Environment.NewLine;
            rtbMessages.Text += "You defeated the " + monster.Name + Environment.NewLine;

            //RewardXP
            _player.XP       += monster.RewardXP;
            rtbMessages.Text += "You receive " + monster.RewardXP.ToString() + " XP." + Environment.NewLine;

            //RewardGold
            _player.Gold     += monster.RewardGold;
            rtbMessages.Text += "You receive " + monster.RewardGold.ToString() + " gold." + Environment.NewLine;
            ScrollToBottom();


            //Get random loot from monster - create list to hold new items
            List <InventoryItem> lootedItems = new List <InventoryItem>();

            //Add lootTable items to list
            foreach (LootItem loot in monster.LootTable)
            {
                if (ComplexRNG.NumberBetween(1, 100) <= loot.DropPercentage)
                {
                    lootedItems.Add(new InventoryItem(loot.Details, 1));
                }
            }

            //no items randomly selected
            if (lootedItems.Count == 0)
            {
                foreach (LootItem loot in monster.LootTable)
                {
                    if (loot.IsDefaultItem)
                    {
                        lootedItems.Add(new InventoryItem(loot.Details, 1));
                    }
                }
            }

            foreach (InventoryItem ii in lootedItems)
            {
                _player.AddItemToInventory(ii.Details);

                if (ii.Quantity == 1)
                {
                    rtbMessages.Text += "You loot " + ii.Quantity.ToString() + " " + ii.Details.Name + Environment.NewLine;
                    ScrollToBottom();
                }
                else
                {
                    rtbMessages.Text += "You loot " + ii.Quantity.ToString() + " " + ii.Details.NamePlural + Environment.NewLine;
                    ScrollToBottom();
                }
            }
        }
Beispiel #2
0
        private void MonsterDamageCalc(Monster monster)
        {
            //Determine monster Damage
            int damageToPlayer = ComplexRNG.NumberBetween(0, monster.MaximumDamage);

            //Display message
            rtbMessages.Text += monster.Name + " dealt " + damageToPlayer.ToString() + " points of damage." + Environment.NewLine;
            ScrollToBottom();

            //Subtract damage from player
            _player.CurrentHP -= damageToPlayer;

            //Refresh player data UI
            UpdatePlayerStats();
        }
Beispiel #3
0
        private void WeaponDamageCalc()
        {
            //Get Current weapon from combobox
            Weapon currentWeapon = (Weapon)cboWeapons.SelectedItem;

            //Calculate Damage
            int damageToMonster = ComplexRNG.NumberBetween(currentWeapon.MinimumDamage, currentWeapon.MaximumDamage);

            //Apply Damage to Monster's current HP
            _currentMonster.CurrentHP -= damageToMonster;

            //Display message
            rtbMessages.Text += Environment.NewLine;
            rtbMessages.Text += "You hit the " + _currentMonster.Name + " for " + damageToMonster.ToString() + " points." + Environment.NewLine;
            ScrollToBottom();
        }