コード例 #1
0
        public void DodajPrzedmiot(int id)
        {
            Przedmiot DodawanyPrzedmiot = Item.ItemsById(id).Kopia();

            if (DodawanyPrzedmiot.getStackable() == false)  // jesli przedmiot nie jest stackowalny to go dodaje do ekwipunku
            {
                DodawanyPrzedmiot.setIlosc(1);
                Ekwipunek.Add(DodawanyPrzedmiot);
            }
            else
            {
                bool czyZnaleziono = false;
                foreach (Przedmiot istniejacyPrzedmiot in Ekwipunek) // jesli przedmiot jest stackowalny, sprawdza czy w ekwipunku jest juz przedmiot o tej samej nazwie aby jedynie zwiekszyc jego ilosc o 1
                {
                    if (istniejacyPrzedmiot.getId() == id)
                    {
                        czyZnaleziono = true;
                        istniejacyPrzedmiot.zwiekszIlosc(1);
                        break;
                    }
                }
                if (czyZnaleziono == false)  // jesli przedmiot jest stackowalny i go nie znaleziono w ekwipunku do stackowania to go dodaje w ilosci 1
                {
                    DodawanyPrzedmiot.setIlosc(1);
                    Ekwipunek.Add(DodawanyPrzedmiot);
                }
            }
        }
コード例 #2
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ż";
             }
         }
     }
 }
コード例 #3
0
        private void zdjecie_Click(object sender, EventArgs e)
        {
            if (EquippedArmor.Items.Count > 0 && EquippedArmor.Items[0].Selected == true)
            {
                Przedmiot P = postac.getZalozonaZbroja() as Przedmiot;
                if (P != null)
                {
                    EquippedArmor.Items[0].Selected = false;

                    if (EquippedWeapon.Items.Count > 0 && EquippedWeapon.Items[0].Selected == true)
                    {
                        EquippedWeapon.Items[0].Selected = false;
                    }

                    listBox1.Items.Add(postac.getZalozonaZbroja().getNazwa().ToString() + " - " + postac.getZalozonaZbroja().getIlosc().ToString());
                    postac.Ekwipunek.Add(postac.getZalozonaZbroja());
                    EquippedArmor.Clear();
                    imageList1.Images.RemoveAt(0);
                    postac.ZalozZbroje(null);

                    Sound.PlaySound(Sound.Sound_weararmor);
                }

                P = null;
            }
            else if (EquippedWeapon.Items.Count > 0 && EquippedWeapon.Items[0].Selected == true)
            {
                Przedmiot P = postac.getZalozonaBron() as Przedmiot;
                if (P != null)
                {
                    EquippedWeapon.SelectedItems[0].Selected = false;

                    if (EquippedArmor.Items.Count > 0 && EquippedArmor.Items[0].Selected == true)
                    {
                        EquippedArmor.Items[0].Selected = false;
                    }

                    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(null);

                    Sound.PlaySound(Sound.Sound_wearweapon);
                }

                P = null;
            }

            UpdateEquipment(postac);
        }
コード例 #4
0
        private void button_kupno_Click(object sender, EventArgs e)
        {
            selling = false;

            if (listBox2.SelectedItem != null)
            {
                Przedmiot P = seller.Ekwipunek.ElementAt(listBox2.SelectedIndex) as Przedmiot;
                if (P != null)
                {
                    if (postac.GetGold() >= P.getItemBuyPrice())
                    {
                        seller.DodajGold(P.getItemBuyPrice());
                        postac.DecreaseGold(P.getItemBuyPrice());

                        if (seller.Ekwipunek.ElementAt(listBox2.SelectedIndex).getIlosc() == 1)
                        {
                            seller.Ekwipunek.RemoveAt(listBox2.SelectedIndex);
                        }

                        else
                        {
                            seller.Ekwipunek.ElementAt(listBox2.SelectedIndex).zmniejszIlosc(1);
                        }

                        postac.DodajPrzedmiot(P.getId());

                        infoBox      = new ShopInfoBox();
                        infoBox.Size = new Size(this.Width / 2, this.Height / 3);

                        infoBox.PointToScreen(new Point(this.Width / 2, this.Height / 2));

                        infoBox.checkTradeState(selling, P.getNazwa().ToString());

                        infoBox.Show();
                        infoBox.Focus();

                        UpdateEquipment(postac);
                        UpdateProducts(seller);

                        Sound.PlaySound(Sound.Sound_goldpickup);
                    }
                }
            }



            /*string listbox_nazwa;
             * int indeks;
             *
             * selling = false;
             *
             * for (int i = 0; i < listBox2.Items.Count; i++)
             * {
             *  if (listBox2.GetSelected(i) == true)
             *  {
             *      listbox_nazwa = listBox2.SelectedItem.ToString();
             *
             *      bool czySpacja = false;
             *
             *      for (int k = listbox_nazwa.Length - 1; k >= 0; k--)
             *      {
             *          if (listbox_nazwa[k] == ' ' && czySpacja == true)
             *          {
             *              indeks = listbox_nazwa.Length - k;
             *              listbox_nazwa = listbox_nazwa.Remove(k, indeks);
             *
             *              break;
             *          }
             *          else if (listbox_nazwa[k] == ' ' && czySpacja == false)
             *              czySpacja = true;
             *      }
             *
             *      int j = 0;
             *
             *      foreach (Przedmiot istniejacyPrzedmiot in seller.Ekwipunek)
             *      {
             *          if (istniejacyPrzedmiot.getNazwa().ToString() == listbox_nazwa)
             *          {
             *              if (postac.GetGold() >= istniejacyPrzedmiot.getItemBuyPrice())
             *              {
             *                  seller.DodajGold(istniejacyPrzedmiot.getItemBuyPrice());
             *                  postac.DecreaseGold(istniejacyPrzedmiot.getItemBuyPrice());
             *
             *                  if (seller.Ekwipunek.ElementAt(i).getIlosc() == 1)
             *                      seller.Ekwipunek.RemoveAt(i);
             *                  else
             *                      seller.Ekwipunek.ElementAt(i).zmniejszIlosc(1);
             *
             *                  postac.DodajPrzedmiot(istniejacyPrzedmiot.getId());
             *
             *                  infoBox.Height = this.Height / 3;
             *                  infoBox.Width = this.Width / 2;
             *                  infoBox.PointToScreen(new Point(this.Width / 2, this.Height / 2));
             *
             *                  infoBox.checkTradeState(selling, istniejacyPrzedmiot.getNazwa().ToString());
             *
             *                  infoBox.Show();
             *                  infoBox.Focus();
             *              }
             *
             *              UpdateEquipment(postac);
             *              UpdateProducts(seller);
             *
             *              break;
             *          }
             *          else
             *              j++;
             *      }
             *  }
             * }*/
        }
コード例 #5
0
        public virtual Przedmiot Kopia()  //wirtualna metoda glebokiej kopii
        {
            Przedmiot temp = new Przedmiot(this.getIlosc(), this.getId(), this.getNazwa(), this.getStackable(), this.getItemHP(), this.getItemMP(), this.getItemStrength(), this.getItemDexterity(), this.getItemIntelligence(), this.getItemSellPrice(), this.getItemBuyPrice(), this.getItemType());

            return(temp);
        }
コード例 #6
0
 public WorldMapItem(Point location, Image image, Przedmiot item) : base(location, image)
 {
     id     = item.getId();
     amount = item.getIlosc();
 }
コード例 #7
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);
        }