Ejemplo n.º 1
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         Przedmiot P = postac.Ekwipunek.ElementAt(listBox1.SelectedIndex) as Przedmiot;
         if (P != null)
         {
             if (P.getItemType() == ItemType.None)
             {
                 uzycie.Enabled = false;
                 uzycie.Visible = false;
             }
             else if (P.getItemType() == ItemType.Armor)
             {
                 uzycie.Enabled = true;
                 uzycie.Visible = true;
                 uzycie.Text    = "Załóż";
             }
             else if (P.getItemType() == ItemType.Consumable)
             {
                 uzycie.Enabled = true;
                 uzycie.Visible = true;
                 uzycie.Text    = "Użyj";
             }
             else if (P.getItemType() == ItemType.Weapon)
             {
                 uzycie.Enabled = true;
                 uzycie.Visible = true;
                 uzycie.Text    = "Wyposaż";
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void uzycie_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem != null)
            {
                Przedmiot P = postac.Ekwipunek.ElementAt(listBox1.SelectedIndex) as Przedmiot;
                if (P != null)
                {
                    if (P.getItemType() == ItemType.Armor)
                    {
                        if (postac.getZalozonaZbroja() != null)
                        {
                            listBox1.Items.Add(postac.getZalozonaZbroja().getNazwa().ToString() + " - " + postac.getZalozonaZbroja().getIlosc().ToString());
                            postac.Ekwipunek.Add(postac.getZalozonaZbroja());
                            EquippedArmor.Clear();
                            imageList1.Images.RemoveAt(0);
                        }

                        postac.ZalozZbroje(P as Zbroja);
                        imageList1.Images.Add((P as Zbroja).getArmorImage());

                        ListViewItem listViewItem = new ListViewItem();
                        listViewItem.ImageIndex = 0;
                        EquippedArmor.Items.Add(listViewItem);

                        postac.Ekwipunek.RemoveAt(listBox1.SelectedIndex);
                        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                        listBox1.ClearSelected();

                        Sound.PlaySound(Sound.Sound_weararmor);
                    }
                    else if (P.getItemType() == ItemType.Consumable)
                    {
                        if (P.GetType() == typeof(Mikstury))
                        {
                            Mikstury potion = P as Mikstury;
                            postac.SetHP(postac.GetHP() + potion.getPotionHp());
                            postac.SetMP(postac.GetMP() + potion.getPotionMp());
                        }

                        postac.addStrenght(P.getItemStrength());
                        postac.addDexterity(P.getItemDexterity());
                        postac.addIntelligence(P.getItemIntelligence());


                        if (postac.Ekwipunek.ElementAt(listBox1.SelectedIndex).getIlosc() == 1)
                        {
                            postac.Ekwipunek.RemoveAt(listBox1.SelectedIndex);
                            listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                            listBox1.ClearSelected();
                        }
                        else
                        {
                            postac.Ekwipunek.ElementAt(listBox1.SelectedIndex).zmniejszIlosc(1);
                            listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                            listBox1.ClearSelected();
                        }

                        Sound.PlaySound(Sound.Sound_healing);
                    }
                    else if (P.getItemType() == ItemType.Weapon)
                    {
                        if (postac.getZalozonaBron() != null)
                        {
                            listBox1.Items.Add(postac.getZalozonaBron().getNazwa().ToString() + " - " + postac.getZalozonaBron().getIlosc().ToString());
                            postac.Ekwipunek.Add(postac.getZalozonaBron());
                            postac.addStrenght(-1 * postac.getZalozonaBron().getItemStrength());
                            EquippedWeapon.Clear();
                            imageList2.Images.RemoveAt(0);
                        }

                        postac.ZalozBron(P as Bron);
                        postac.addStrenght(postac.getZalozonaBron().getItemStrength());
                        imageList2.Images.Add((P as Bron).getWeaponImage());

                        ListViewItem listViewItem = new ListViewItem();
                        listViewItem.ImageIndex = 0;
                        EquippedWeapon.Items.Add(listViewItem);

                        postac.Ekwipunek.RemoveAt(listBox1.SelectedIndex);
                        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                        listBox1.ClearSelected();

                        Sound.PlaySound(Sound.Sound_wearweapon);
                    }
                }

                P = null;
            }

            UpdateEquipment(postac);
        }