Exemple #1
0
        public void Start_Combat(Monster _mob, Character _char, Weapon _weap, RichTextBox myLabel)
        {
            this.mob = _mob;
            this.player = _char;
            this.Weapon_Min_Damage = _weap.Min_Damage;
            this.Weapon_Max_Damage = _weap.Max_Damage;
            rtBox = myLabel;

            //Player Attack Mob
            int tempIncDmg = 0;
            tempIncDmg = Damage_Dealt();
            mob.CurrentHP -= tempIncDmg;

            DamageOutPut("Damage Dealt : " + tempIncDmg.ToString() + "\r\n", 0);

            if (mob.CurrentHP > 0 && _roundNumber != MAX_ROUND)
            {
                _roundNumber++;
            }
            else if (mob.CurrentHP <= 0)
            {
                DamageOutPut("You killed : " + mob.Name + " in " + _roundNumber.ToString() + " round(s)" + "\r\n", 4);
                WinLose = true;
                InCombat = false;
                _roundNumber = 0;
                return;
            }

            //Mob Attack player
            int tempOutDmg = 0;
            tempOutDmg = Damage_Taken();
            player.Player_Current_Health -= tempOutDmg;

            DamageOutPut("Damage Taken : " + tempOutDmg.ToString() + "\r\n", 1);

            if (player.Player_Current_Health > 0 && _roundNumber != MAX_ROUND)
            {
                _roundNumber++;
            }
            else if (player.Player_Current_Health <= 0)
            {
                DamageOutPut("You were killed by " + mob.Name + "\r\n", 5);
                WinLose = false;
                InCombat = false;
                _roundNumber = 0;
                return;
            }
            DamageOutPut("Round : " + _roundNumber.ToString() + "\r\n", 2);
        }
Exemple #2
0
        public Character do_Load_Inventory(Character player, int charIdx)
        {
            /*
                        TODO:
                        Get default item values.
                        Compare default item values with values from dev_char_inventory.
                        If there's a difference, change the item values according to the values set in dev_char_inventory.
                        Add the modified item to players inventory.
            */
            player.Inventory = new List<Inventory>();
            string sql = "SELECT * FROM dev_char_inventory WHERE a_char_idx=" + charIdx + ";";
            logging.Logging(String.Format("DBManager : Loading Player {0} Inventory items", _Player.Character_Name));
            if (charIdx > 0)
            {
                command = new MySqlCommand(sql, connection);
                reader = command.ExecuteReader();
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        Char_Index = Convert.ToInt32(reader["a_char_idx"]);
                        Item_Index = Convert.ToInt32(reader["a_item_idx"]);
                        Item_Type = Convert.ToInt32(reader["a_item_type"]);
                        Item_Quantity = Convert.ToInt32(reader["a_quantity"]);
                        Item_Upgrade_Type = Convert.ToInt32(reader["a_upgradeType"]);
                        Item_Name = reader["a_name"].ToString();
                        Item_Name_Plurel = reader["a_name_long"].ToString();
                        Item_Plus = Convert.ToInt32(reader["a_plus"]);
                        Item_Star = Convert.ToInt32(reader["a_star"]);
                        Item_Grade = reader["a_grade"].ToString();
                        CanUpgrade = Convert.ToBoolean(reader["a_canUpgrade"]);
                        if (item_Type == 1)
                        {
                            Item_Min_Damage = Convert.ToInt32(reader["a_minDmg"]);
                            Item_Max_Damage = Convert.ToInt32(reader["a_maxDmg"]);
                            Weapon weapon = new Weapon(Item_Index,Item_Name,Item_Name_Plurel,Item_Upgrade_Type,Item_Type,Item_Plus,
                                Item_Star,Item_Grade,Item_Min_Damage,Item_Max_Damage, CanUpgrade);
                            player.AddItemToInventory(player, weapon);
                        }
                        else if (Item_Type == 9)
                        {
                            Amount_To_Heal = Convert.ToInt32(reader["a_amountHeal"]);
                            Potions potion = new Potions(Item_Index, Item_Name, Item_Name_Plurel, Item_Upgrade_Type,
                                Item_Type, Item_Plus, Item_Star, Item_Grade, Amount_To_Heal);
                            player.AddItemToInventory(player, potion);
                        }
                        //Standard Item
                        else if (Item_Type < 0)
                        {
                            logging.Logging(String.Format("DBManager cannot find item type {0}", Item_Type));
                            return null;
                        }

                    }
                    reader.Close();
                    return player;
                }
                return null;
            }
            return null;
        }
Exemple #3
0
        public void UseWeapon(Weapon weapon)
        {
            // Determine the amount of damage to do to the monster
            int damageToMonster = RandomNumberGenerator.NumberBetween(weapon.MinimumDamage, weapon.MaximumDamage);

            // Apply the damage to the monster's CurrentHitPoints
            _currentMonster.CurrentHitPoints -= damageToMonster;

            // Display message
            RaiseMessage("You hit the " + _currentMonster.Name + " for " + damageToMonster + " points.");

            // Check if the monster is dead
            if (_currentMonster.CurrentHitPoints <= 0)
            {
                // Monster is dead
                RaiseMessage("");
                RaiseMessage("You defeated the " + _currentMonster.Name);

                // Give player experience points for killing the monster
                AddExperiencePoints(_currentMonster.RewardExperiencePoints);
                RaiseMessage("You receive " + _currentMonster.RewardExperiencePoints + " experience points");

                // Give player gold for killing the monster 
                Gold += _currentMonster.RewardGold;
                RaiseMessage("You receive " + _currentMonster.RewardGold + " gold");

                // Get random loot items from the monster
                List<InventoryItem> lootedItems = new List<InventoryItem>();

                // Add items to the lootedItems list, comparing a random number to the drop percentage
                foreach (LootItem lootItem in _currentMonster.LootTable)
                {
                    if (RandomNumberGenerator.NumberBetween(1, 100) <= lootItem.DropPercentage)
                    {
                        lootedItems.Add(new InventoryItem(lootItem.Details, 1));
                    }
                }

                // If no items were randomly selected, then add the default loot item(s).
                if (lootedItems.Count == 0)
                {
                    foreach (LootItem lootItem in _currentMonster.LootTable)
                    {
                        if (lootItem.IsDefaultItem)
                        {
                            lootedItems.Add(new InventoryItem(lootItem.Details, 1));
                        }
                    }
                }

                // Add the looted items to the player's inventory
                foreach (InventoryItem inventoryItem in lootedItems)
                {
                    AddItemToInventory(inventoryItem.Details);

                    if (inventoryItem.Quantity == 1)
                    {
                        RaiseMessage("You loot " + inventoryItem.Quantity + " " + inventoryItem.Details.Name);
                    }
                    else
                    {
                        RaiseMessage("You loot " + inventoryItem.Quantity + " " + inventoryItem.Details.NamePlural);
                    }
                }

                // Add a blank line to the messages box, just for appearance.
                RaiseMessage("");

                // Move player to current location (to heal player and create a new monster to fight)
                MoveTo(CurrentLocation);
            }
            else
            {
                // Monster is still alive

                // Determine the amount of damage the monster does to the player
                int damageToPlayer = RandomNumberGenerator.NumberBetween(0, _currentMonster.MaximumDamage);

                // Display message
                RaiseMessage("The " + _currentMonster.Name + " did " + damageToPlayer + " points of damage.");

                // Subtract damage from player
                CurrentHitPoints -= damageToPlayer;

                if (CurrentHitPoints <= 0)
                {
                    // Display message
                    RaiseMessage("The " + _currentMonster.Name + " killed you.");

                    // Move player to "Home"
                    MoveHome();
                }
            }
        }
Exemple #4
0
        public void UseWeapon(Weapon weapon)
        {
            //Determine the amount of damage to do to the monster
            int damageToMonster = RandomNumberGenerator.NumberBetween(weapon.MinimumDamage, weapon.MaximumDamage);

            //Apply the damage to the monster's CurrentHitPoints
            _currentMonster.CurrentHitPoints -= damageToMonster;

            //Display message
            RaiseMessage("You hit the " + _currentMonster.Name + " for " + damageToMonster + " points.");

            //Check if the monster is dead
            if (_currentMonster.CurrentHitPoints <= 0)
            {
                //Monster is dead
                RaiseMessage("");
                RaiseMessage("You defeated the " + _currentMonster.Name);

                //Give player experience points ofr killing the monster
                AddExperiencePoints(_currentMonster.RewardExperiencePoints);
                RaiseMessage("You recieve " + _currentMonster.RewardGold + " gold");

                //Get random loot items from the monster
                List <InventoryItem> lootedItems = new List <InventoryItem>();

                //Add items to the lootedItems list, comparing a random number to the drop percentage
                foreach (LootItem lootItem in _currentMonster.LootTable)
                {
                    if (RandomNumberGenerator.NumberBetween(1, 100) <= lootItem.DropPercentage)
                    {
                        lootedItems.Add(new InventoryItem(lootItem.Details, 1));
                    }
                }

                //If no items were randomly selected, then add the default loot item(s).
                if (lootedItems.Count == 0)
                {
                    foreach (LootItem lootItem in _currentMonster.LootTable)
                    {
                        if (lootItem.IsDefaultItem)
                        {
                            lootedItems.Add(new InventoryItem(lootItem.Details, 1));
                        }
                    }
                }

                //Add the looted items to the player's inventory
                foreach (InventoryItem inventoryItem in lootedItems)
                {
                    AddItemToInventory(inventoryItem.Details);

                    if (inventoryItem.Quantity == 1)
                    {
                        RaiseMessage("You loot " + inventoryItem.Quantity + " " + inventoryItem.Details.Name);
                    }
                    else
                    {
                        RaiseMessage("You loot " + inventoryItem.Quantity + " " + inventoryItem.Details.NamePlural);
                    }
                }

                //Add a blank line to the messages box, just for appearance
                RaiseMessage("");

                //Move player to current location (to heal player and create a new monster to fight)
                MoveTo(CurrentLocation);
            }
            else
            {
                //Monster is still alive

                //Determine the amount of damage the monster does to the player
                int damageToPlayer = RandomNumberGenerator.NumberBetween(0, _currentMonster.MaximumDamage);

                //Display message
                RaiseMessage("The " + _currentMonster.Name + " did " + damageToPlayer + " points of damage.");

                //Subtract damage from player
                CurrentHitPoints -= damageToPlayer;

                if (CurrentHitPoints <= 0)
                {
                    //Display message
                    RaiseMessage("The " + _currentMonster.Name + " killed you.");

                    //Move playerto Home
                    MoveHome();
                }
            }
        }