Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        private void EnemySpecialSkill()
        {
            int randomValue = random.Next(Enemy.SpecjalneAtaki.Count);

            if (Enemy.GetMP() >= Enemy.SpecjalneAtaki.ElementAt(randomValue).GetManaCost())
            {
                if (Enemy.SpecjalneAtaki.ElementAt(randomValue).GetType() == typeof(AtkLeczenie))
                {
                    Enemy.SetHP(Enemy.GetHP() + Enemy.SpecjalneAtaki.ElementAt(randomValue).GetValue());
                    Sound.PlaySound(Sound.Sound_enemyhealingspell);

                    if (Enemy.GetHP() > Enemy.GetMaxHP())
                    {
                        Enemy.SetHP(Enemy.GetMaxHP());
                    }
                }
                else
                {
                    Player.SetHP(Player.GetHP() - (Enemy.SpecjalneAtaki.ElementAt(randomValue).GetValue() * EnemyDmgMultiplier) / PlayerDefMultiplier);
                    Sound.PlaySound(Sound.Sound_enemyattackspell);
                }
                Enemy.SetMP(Enemy.GetMP() - Enemy.SpecjalneAtaki.ElementAt(randomValue).GetManaCost());

                if (Enemy.GetMP() <= 0)
                {
                    Enemy.SetMP(0);
                }

                if (Player.GetHP() <= 0)
                {
                    Player.SetHP(0);
                    Player.SetMP(0);

                    playerWin = false;
                    inCombat  = false;

                    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              = true;
                AttackBtn.Enabled       = true;
                SpecialSkillBtn.Enabled = true;
                BlockBtn.Enabled        = true;
                ItemsBtn.Enabled        = true;

                UpdateStats();
            }
        }
Exemplo n.º 3
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);
        }