Example #1
0
        public SuperAdventure()
        {
            InitializeComponent();
            player.URL = "Dragon Quest III Symphonic Suite - Adventure.mp3";



            _player = new Player(10, 10, 20, 0, 1);
            MoveTo(World.LocationByID(World.LOCATION_ID_HOME));
            _player.Inventory.Add(new InventoryItem(
                                      World.ItemByID(World.ITEM_ID_RUSTY_SWORD), 1));

            lblHitPoints.Text  = _player.CurrentHitPoints.ToString();
            lblGold.Text       = _player.Gold.ToString();
            lblExperience.Text = _player.ExperiencePoints.ToString();
            lblLevel.Text      = _player.Level.ToString();
        }
Example #2
0
        private void dgvVendorItems_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3)
            {
                var itemID = dgvVendorItems.Rows[e.RowIndex].Cells[0].Value;

                Item itemBeingBought = World.ItemByID(Convert.ToInt32(itemID));

                //checks is player has enough gold to buy the item
                if (_currentPlayer.Gold >= itemBeingBought.Price)
                {
                    //removes gold = to item price
                    _currentPlayer.Gold -= itemBeingBought.Price;

                    _currentPlayer.AddItemToInventory(itemBeingBought);
                }
                else
                {
                    MessageBox.Show("You do not have enough gold to buy the " + itemBeingBought.Name);
                }
            }
        }
Example #3
0
        private void dgvMyItems_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
            {
                var itemID = dgvMyItems.Rows[e.RowIndex].Cells[0].Value;

                Item itemBeingSold = World.ItemByID(Convert.ToInt32(itemID));

                //checks if item is sellable
                if (itemBeingSold.Price == World.UNSELLABLE_ITEM_PRICE)
                {
                    MessageBox.Show("You cannot sell the " + itemBeingSold.Name);
                }
                else
                {
                    //remove item from players inventory
                    _currentPlayer.RemoveItemFromInventory(itemBeingSold);

                    //exchanges item sold for gold
                    _currentPlayer.Gold += itemBeingSold.Price;
                }
            }
        }
Example #4
0
        private void dgvVendorItems_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //4th column has Buy 1 button
            if (e.ColumnIndex == 3)
            {
                //Get ID value of item from hidden 1st column
                var itemID = dgvVendorItems.Rows[e.RowIndex].Cells[0].Value;

                //Get Item object for selected row
                Item itemBeingBought = World.ItemByID(Convert.ToInt32(itemID));

                if (itemBeingBought.Price <= _currentPlayer.Gold)
                {
                    _currentPlayer.AddItemToInventory(itemBeingBought);

                    _currentPlayer.Gold -= itemBeingBought.Price;
                }
                else
                {
                    MessageBox.Show("You do not have enough gold to buy the " + itemBeingBought.Name);
                }
            }
        }
Example #5
0
        private void dgvMyItems_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //5th column has Sell 1 button
            if (e.ColumnIndex == 4)
            {
                //Get ID value of item from hidden 1st column
                var itemID = dgvMyItems.Rows[e.RowIndex].Cells[0].Value;

                //Get Item object for selected row
                Item itemBeingSold = World.ItemByID(Convert.ToInt32(itemID));

                if (itemBeingSold.Price == World.UNSELLABLE_ITEM_PRICE)
                {
                    MessageBox.Show("You cannot sell the " + itemBeingSold.Name);
                }
                else
                {
                    //Remove a copy of the item from the player's inventory
                    _currentPlayer.RemoveItemFromInventory(itemBeingSold);

                    _currentPlayer.Gold += itemBeingSold.Price;
                }
            }
        }