예제 #1
0
        private void OpenQuestInformationalScreen(object sender, EventArgs e)
        {
            InformationScreen informationScreen = new InformationScreen(gameSession, ((Location)informationObject).QuestInLocation);

            informationScreen.StartPosition = FormStartPosition.CenterParent;
            informationScreen.ShowDialog(this);
        }
예제 #2
0
 private void OpenInformationScreen(Location location)
 {
     if (location != null && location.HasVisited)
     {
         InformationScreen informationScreen = new InformationScreen(gameSession, location);
         informationScreen.StartPosition = FormStartPosition.CenterParent;
         informationScreen.ShowDialog(this);
     }
 }
예제 #3
0
        private void dgvQuests_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            var questID = dgvQuests.Rows[e.RowIndex].Cells[0].Value;

            // Get the quest object in the row
            Quest quest = World.FindQuestByID(Convert.ToInt32(questID));

            InformationScreen informationScreen = new InformationScreen(gameSession, quest);

            informationScreen.StartPosition = FormStartPosition.CenterParent;
            informationScreen.ShowDialog(this);

            UpdateUI();
        }
예제 #4
0
        private void dgvEquipmentEquip_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            if (e.ColumnIndex != 4 && e.ColumnIndex != 3)
            {
                var equipmentID = dgvEquipment.Rows[e.RowIndex].Cells[0].Value;

                // Get the equipment object in the row
                Equipment equipment = World.FindEquipmentByID(Convert.ToInt32(equipmentID));

                InformationScreen informationScreen = new InformationScreen(gameSession, equipment);
                informationScreen.StartPosition = FormStartPosition.CenterParent;
                informationScreen.ShowDialog(this);
                UpdateUI();
                return;
            }

            if (gameSession.GameStates == GameSession.GameState.Battle)
            {
                return;
            }
            if (((DataGridViewDisableButtonCell)(dgvEquipment.Rows[e.RowIndex].Cells[3])).Enabled == false)
            {
                return;
            }

            if (e.ColumnIndex == 3)
            {
                var equipmentID = dgvEquipment.Rows[e.RowIndex].Cells[0].Value;

                // Get the equipment object in the row
                Equipment equipment = World.FindEquipmentByID(Convert.ToInt32(equipmentID));

                gameSession.EquipCommand(equipment);
                UpdateUI();
                return;
            }
        }
예제 #5
0
        //<-------------Event Functions------------->
        private void dgvItems_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            if (e.ColumnIndex != 4)
            {
                var itemID = dgvItems.Rows[e.RowIndex].Cells[0].Value;

                Item itemBeingUsed = World.FindItemByID(Convert.ToInt32(itemID));

                InformationScreen informationScreen = new InformationScreen(gameSession, itemBeingUsed);
                informationScreen.StartPosition = FormStartPosition.CenterParent;
                informationScreen.ShowDialog(this);
                UpdateUI();
                return;
            }

            if (gameSession.GameStates == GameSession.GameState.Battle)
            {
                return;
            }
            if (((DataGridViewDisableButtonCell)(dgvItems.Rows[e.RowIndex].Cells[4])).Enabled == false)
            {
                return;
            }

            // The 4th column has the "Use" button.
            // Row Index is not -1 is to make sure the user can't buy the column names
            if (e.ColumnIndex == 4)
            {
                // This gets the ID value of the entity, from the hidden 1st column
                var itemID = dgvItems.Rows[e.RowIndex].Cells[0].Value;

                Item itemBeingUsed = World.FindItemByID(Convert.ToInt32(itemID));
                gameSession.UseItemWhileTravelCommand(itemBeingUsed);
                UpdateUI();
                return;
            }
        }
예제 #6
0
        private void dgvSpells_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            if (e.ColumnIndex != 4)
            {
                var spellID = dgvSpells.Rows[e.RowIndex].Cells[0].Value;

                // Get the spell object in the row
                Spell spell = World.FindSpellByID(Convert.ToInt32(spellID));

                InformationScreen informationScreen = new InformationScreen(gameSession, spell);
                informationScreen.StartPosition = FormStartPosition.CenterParent;
                informationScreen.ShowDialog(this);
                UpdateUI();
                return;
            }

            if (gameSession.GameStates == GameSession.GameState.Battle)
            {
                return;
            }
            if (((DataGridViewDisableButtonCell)(dgvSpells.Rows[e.RowIndex].Cells[4])).Enabled == false)
            {
                return;
            }

            if (e.ColumnIndex == 4)
            {
                var spellID = dgvSpells.Rows[e.RowIndex].Cells[0].Value;

                // Get the spell object in the row
                Spell spell = World.FindSpellByID(Convert.ToInt32(spellID));

                gameSession.CastSpellWhileTravelCommand(spell);
                UpdateUI();
            }
        }
예제 #7
0
        private void dgvVendorInventory_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int columnIndex = 0;

            if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorItemInventory != null)
            {
                columnIndex = 5;
            }
            else if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorEquipmentInventory != null)
            {
                columnIndex = 4;
            }
            else if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorSpellInventory != null)
            {
                columnIndex = 4;
            }

            if (e.ColumnIndex != columnIndex)
            {
                var entityID = dgvVendorInventory.Rows[e.RowIndex].Cells[0].Value;

                if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorItemInventory != null)
                {
                    Item itemBeingViewed = World.FindItemByID(Convert.ToInt32(entityID));

                    InformationScreen informationScreen = new InformationScreen(gameSession, itemBeingViewed);
                    informationScreen.StartPosition = FormStartPosition.CenterParent;
                    informationScreen.ShowDialog(this);
                }
                else if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorEquipmentInventory != null)
                {
                    Equipment equipmentBeingViewed = World.FindEquipmentByID(Convert.ToInt32(entityID));

                    InformationScreen informationScreen = new InformationScreen(gameSession, equipmentBeingViewed);
                    informationScreen.StartPosition = FormStartPosition.CenterParent;
                    informationScreen.ShowDialog(this);
                }
                else if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorSpellInventory != null)
                {
                    Spell spellBeingViewed = World.FindSpellByID(Convert.ToInt32(entityID));

                    InformationScreen informationScreen = new InformationScreen(gameSession, spellBeingViewed);
                    informationScreen.StartPosition = FormStartPosition.CenterParent;
                    informationScreen.ShowDialog(this);
                }

                UpdateUI();
                return;
            }

            // The 4th or 5th column has the "Buy 1" button.
            // Row Index is not -1 is to make sure the user can't buy the column names
            if (e.ColumnIndex == columnIndex && e.RowIndex != -1)
            {
                // This gets the ID value of the entity, from the hidden 1st column
                var entityID = dgvVendorInventory.Rows[e.RowIndex].Cells[0].Value;

                if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorItemInventory != null)
                {
                    Item itemBeingSold = World.FindItemByID(Convert.ToInt32(entityID));
                    gameSession.BuyFromStoreCommand(itemBeingSold);
                }
                else if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorEquipmentInventory != null)
                {
                    Equipment equipmentBeingSold = World.FindEquipmentByID(Convert.ToInt32(entityID));
                    if (!gameSession.CurrentPlayer.CheckIfEquippable(equipmentBeingSold))
                    {
                        UpdateUI();
                        return;
                    }
                    gameSession.BuyFromStoreCommand(equipmentBeingSold);
                }
                else if (gameSession.CurrentPlayer.CurrentLocation.VendorInLocation.VendorSpellInventory != null)
                {
                    Spell spellBeingSold = World.FindSpellByID(Convert.ToInt32(entityID));
                    gameSession.BuyFromStoreCommand(spellBeingSold);
                }
            }

            UpdateUI();
        }