Exemplo n.º 1
0
        private void UnequipConsumable(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            if ((ButtonToBag[BagButtonPressed] != -1))
            //mono ean to button den einai keno(dhladh den exei item),ekteleitai
            //o parakatw kodikas.(epeidh an einai keno, dhladh xwris item, tote
            //to item einai = me null, kai buggarei to programma)
            {
                EquipUnequipGUI UnequipWeapon = new EquipUnequipGUI(inv.Bag[ButtonToBag[BagButtonPressed]], "Unequip");
                if (UnequipWeapon.ShowDialog(this) == DialogResult.OK)
                {
                    inv.InventoryAddItem(inv.Bag[ButtonToBag[BagButtonPressed]]);
                    inv.DeleteBagItem(inv.Bag[ButtonToBag[BagButtonPressed]], ButtonToBag[BagButtonPressed]);


                    InventorySpaceReload();//kane reload to GUI
                }
            }
        }
Exemplo n.º 2
0
        private void Equip(object?sender, EventArgs e)
        {
            if (!((sender as Control)?.Tag is Item item))
            {
                return;
            }

            using EquipUnequipGUI Equip =
                      new EquipUnequipGUI(item, "Equip");
            if (Equip.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            if (item is Weapon weapon)
            {
                inv.EquipWeapon(weapon);
            }
            else if (item is Armor armor)
            {
                inv.EquipArmor(armor);
            }
            else if (!inv.IsBagFull && item is ConsumableItem spell)
            {
                if (!inv.TryAddToBag(spell))
                {
                    MessageBox.Show("Your bag is full.\nTry to unequip something from there.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("You cannot equip the item.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void Equip(object sender, EventArgs e)
        {
            //GIA THN WRA DOULEVEI MONO GIA WEAPONS KAI ARMOR//
            Button btn = sender as Button;

            if (ButtonToChest[ChestButtonPressed] != -1)
            //mono ean to button den einai keno(dhladh den exei item),ekteleitai o parakatw kodikas.
            //(epeidh an einai keno, dhladh xwris item, tote to item einai = me null, kai buggarei to programma)
            {
                EquipUnequipGUI Equip = new EquipUnequipGUI(inv.ChestSpace[ButtonToChest[ChestButtonPressed]], "Equip");
                if (Equip.ShowDialog(this) == DialogResult.OK)
                {
                    if ((inv.WeaponEquiped == null) && (inv.ChestSpace[ButtonToChest[ChestButtonPressed]].GetType() == typeof(Weapon)))
                    //ean to weaponbutton einai empty, kai to button pou
                    //pathses einai Weapon
                    {
                        //kwdikas gia na prosthetei to buff tou weapon
                        Weapon weapon = (Weapon)inv.ChestSpace[ButtonToChest[ChestButtonPressed]];
                        DamageBuff            = DamageBuff + weapon.Damage;
                        DamageTextNumber.Text = DamageBuff.ToString();
                        //

                        inv.AddWeapon(inv.ChestSpace[ButtonToChest[ChestButtonPressed]], ButtonToChest[ChestButtonPressed]); //prosthese to Weapon pou foreses sto WeaponButton kai afairese to apo to inventory

                        InventorySpaceReload();                                                                              //allaxe tis allages sto GUI
                    }
                    else if ((inv.ArmorEquiped == null) && (inv.ChestSpace[ButtonToChest[ChestButtonPressed]].GetType() == typeof(Armor)))
                    //ean to armorbutton einai empty, kai to button pou pathses einai Armor
                    {
                        //kwdikas gia na prosthetei to buff tou Armor
                        Armor Armor = (Armor)inv.ChestSpace[ButtonToChest[ChestButtonPressed]];
                        ArmorBuff = ArmorBuff + Armor.Defence;
                        DefenceTextNumber.Text = ArmorBuff.ToString();
                        //



                        inv.AddArmor(inv.ChestSpace[ButtonToChest[ChestButtonPressed]], ButtonToChest[ChestButtonPressed]); //prosthese to armor pou foreses sto ArmorButton kai afairese to apo to inventory

                        InventorySpaceReload();                                                                             //allaxe tis allages sto GUI
                    }
                    else if ((inv.BagNotFull()) && (inv.ChestSpace[ButtonToChest[ChestButtonPressed]].GetType() == typeof(Spell)))
                    //ean to bag einai empty, kai to button pou pathses exei einai NonConsumableItems
                    {
                        inv.AddToBagFromInventory(inv.ChestSpace[ButtonToChest[ChestButtonPressed]], ButtonToChest[ChestButtonPressed]); //prosthese to armor pou foreses sto ArmorButton kai afairese to apo to inventory

                        InventorySpaceReload();                                                                                          //allaxe tis allages sto GUI
                    }
                    else if ((inv.BagNotFull()) && (inv.ChestSpace[ButtonToChest[ChestButtonPressed]].GetType() == typeof(Potion)))
                    //ean to bag einai empty, kai to button pou pathses exei einai NonConsumableItems
                    {
                        inv.AddToBagFromInventory(inv.ChestSpace[ButtonToChest[ChestButtonPressed]], ButtonToChest[ChestButtonPressed]); //prosthese to armor pou foreses sto ArmorButton kai afairese to apo to inventory

                        InventorySpaceReload();                                                                                          //allaxe tis allages sto GUI
                    }
                    else
                    {
                        MessageBox.Show("Δεν Μπορεις να βάλεις το αντικείμενο");
                    }
                }
            }
        }