Esempio n. 1
0
        private void button_sprzedaz_Click(object sender, EventArgs e)
        {
            selling = true;

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

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

                    else
                    {
                        postac.Ekwipunek.ElementAt(listBox1.SelectedIndex).zmniejszIlosc(1);
                    }

                    seller.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 = true;
             *
             * for (int i = 0; i < listBox1.Items.Count; i++)
             * {
             *  if (listBox1.GetSelected(i) == true)
             *  {
             *      listbox_nazwa = listBox1.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 postac.Ekwipunek)
             *      {
             *          if (istniejacyPrzedmiot.getNazwa().ToString() == listbox_nazwa)
             *          {
             *              postac.DodajGold(istniejacyPrzedmiot.getItemSellPrice());
             *
             *              if (postac.Ekwipunek.ElementAt(i).getIlosc() == 1)
             *                  postac.Ekwipunek.RemoveAt(i);
             *              else
             *                  postac.Ekwipunek.ElementAt(i).zmniejszIlosc(1);
             *
             *              seller.DodajPrzedmiot(istniejacyPrzedmiot.getId());
             *
             *              UpdateProducts(seller);
             *              UpdateEquipment(postac);
             *
             *
             *              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();
             *
             *              break;
             *          }
             *          else
             *              j++;
             *      }
             *  }
             * }*/
        }
Esempio n. 2
0
        private void AttackBtn_Click(object sender, EventArgs e)
        {
            if (playerTurn)
            {
                Enemy.SetHP(Enemy.GetHP() - (Player.GetObrazenia() * PlayerDmgMultiplier) / EnemyDefMultiplier);
                Sound.PlaySound(Sound.Sound_playerbasicattack);

                if (Enemy.GetHP() <= 0)
                {
                    Enemy.SetHP(0);
                    Enemy.SetMP(0);
                    Enemy.setIsAlive(false);

                    playerWin = true;
                    inCombat  = false;

                    Player.DodajEXP(Enemy.getNagrodaExp());
                    Player.DodajGold(Enemy.getNagrodaGold());

                    foreach (Quest quest in Player.quests)
                    {
                        if (quest.getStatus() == QuestStatus.Active)
                        {
                            if (quest.GetType() == typeof(QuestKillEnemy))
                            {
                                QuestKillEnemy _quest = quest as QuestKillEnemy;
                                if (_quest.GetQuestEnemyID() == Enemy.getId())
                                {
                                    _quest.IncrementCounter();
                                    _quest.CheckCompletion();
                                }
                            }
                        }
                    }

                    Enemy = null;

                    if (CombatSoundPlayer.settings.volume > 0)
                    {
                        timer2.Start();
                    }

                    if (Sound.SongPlayer.settings.volume < 100)
                    {
                        timer1.Start();
                    }

                    this.Close();
                }
            }

            PlayerDmgMultiplier = 1;
            PlayerDefMultiplier = 1;
            EnemyDmgMultiplier  = 1;
            EnemyDefMultiplier  = 1;

            playerTurn              = false;
            AttackBtn.Enabled       = false;
            SpecialSkillBtn.Enabled = false;
            BlockBtn.Enabled        = false;
            ItemsBtn.Enabled        = false;

            UpdateStats();
            Delay.Start();
        }