Exemplo n.º 1
0
        private void lstb_1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Check if the selected item is of Weapon type
            if (lstb_1.SelectedItem.GetType() == typeof(Weapon))
            {
                Weapon SelectedObject = (Weapon)lstb_1.SelectedItem;
                //We CAST the selected object to a Item object.
                //We can do this because the Weapon types are derived from the Item type
                //This is not super safe. If an object that isn't derived of Item is selected it goes allahu akbar(there are easy ways to check)


                //Fill in the textboxes with info about the selected item
                txtb_Name.Text    = SelectedObject.Name;
                txtb_Value.Text   = SelectedObject.Value.ToString();
                txtb_Weight.Text  = SelectedObject.Weight.ToString();
                txtb_Type.Text    = SelectedObject.DmgType.ToString();
                txtb_Damage.Text  = SelectedObject.Damage.ToString();
                txtb_PDmgMul.Text = SelectedObject.PDmgMul.ToString();
                txtb_MDmgMul.Text = SelectedObject.MDmgMul.ToString();
                txtb_MDrnMul.Text = SelectedObject.MDrnMul.ToString();

                txtb_Def.Text      = "N/A w/ this item";
                txtb_HPBoost.Text  = "N/A w/ this item";
                txtb_MBoost.Text   = "N/A w/ this item";
                txtb_PDefMul.Text  = "N/A w/ this item";
                txtb_MDefMul.Text  = "N/A w/ this item";
                txtb_HPGain.Text   = "N/A w/ this item";
                txtb_StamGain.Text = "N/A w/ this item";
                txtb_ManaGain.Text = "N/A w/ this item";

                //else, check if the selected item is of Armour type
            }
            else if (lstb_1.SelectedItem.GetType() == typeof(Armour))
            {
                Armour SelectedObject = (Armour)lstb_1.SelectedItem;

                //Fill in the textboxes with info about the selected item
                txtb_Name.Text    = SelectedObject.Name;
                txtb_Value.Text   = SelectedObject.Value.ToString();
                txtb_Weight.Text  = SelectedObject.Weight.ToString();
                txtb_Def.Text     = SelectedObject.Defense.ToString();
                txtb_HPBoost.Text = SelectedObject.HPBoost.ToString();
                txtb_MBoost.Text  = SelectedObject.MBoost.ToString();
                txtb_PDefMul.Text = SelectedObject.PDefMul.ToString();
                txtb_MDefMul.Text = SelectedObject.MDefMul.ToString();

                txtb_Type.Text     = "N/A w/ this item";
                txtb_Damage.Text   = "N/A w/ this item";
                txtb_PDmgMul.Text  = "N/A w/ this item";
                txtb_MDmgMul.Text  = "N/A w/ this item";
                txtb_MDrnMul.Text  = "N/A w/ this item";
                txtb_HPGain.Text   = "N/A w/ this item";
                txtb_StamGain.Text = "N/A w/ this item";
                txtb_ManaGain.Text = "N/A w/ this item";
            }
            else if (lstb_1.SelectedItem.GetType() == typeof(Consumable))
            {
                Consumable SelectedObject = (Consumable)lstb_1.SelectedItem;

                //Fill in the textboxes with info about the selected item
                txtb_Name.Text     = SelectedObject.Name;
                txtb_Value.Text    = SelectedObject.Value.ToString();
                txtb_Weight.Text   = SelectedObject.Weight.ToString();
                txtb_HPGain.Text   = SelectedObject.HPGain.ToString();
                txtb_StamGain.Text = SelectedObject.StamGain.ToString();
                txtb_ManaGain.Text = SelectedObject.ManaGain.ToString();

                txtb_Def.Text     = "N/A w/ this item";
                txtb_HPBoost.Text = "N/A w/ this item";
                txtb_MBoost.Text  = "N/A w/ this item";
                txtb_Type.Text    = "N/A w/ this item";
                txtb_Damage.Text  = "N/A w/ this item";
                txtb_PDmgMul.Text = "N/A w/ this item";
                txtb_MDmgMul.Text = "N/A w/ this item";
                txtb_MDrnMul.Text = "N/A w/ this item";
                txtb_PDefMul.Text = "N/A w/ this item";
                txtb_MDefMul.Text = "N/A w/ this item";
            }
        }