コード例 #1
0
ファイル: MagevsOpponent.cs プロジェクト: Narvel2/GameRPG
        private void buttonAttackMage_Click(object sender, EventArgs e)
        {
            monster.HP -= mag.Attack();
            mag.HP     -= monster.Attack();

            if (monster.HP <= 0)
            {
                monster.HP = 0;
                progressBarHPMonster.Value = monster.PercentHP();
                string message = "Good job my friend your opponent has been killed!";
                MessageBox.Show(message);
                this.Visible = false;
            }
            else
            {
                progressBarHPMonster.Value = monster.PercentHP();
            }
            if (mag.HP <= 0)
            {
                mag.HP = 0;
                progressBarHPMage.Value = mag.PercentHP();
                string message = "You are death, try again!";
                MessageBox.Show(message);
                this.Visible = false;
            }
            else
            {
                progressBarHPMage.Value = mag.PercentHP();
            }
        }
コード例 #2
0
        private void buttonShuriken_Click(object sender, EventArgs e)
        {
            assassin.Mana -= 50;
            assassin.HP   -= monster.Attack();

            if (assassin.Mana <= 0)
            {
                buttonShuriken.Enabled = false;
            }
            else
            {
                progressBarManaAssassin.Value = assassin.PercentMana();
            }
            textBoxSpellsVoice.Text = assassin.Spellfirst();
            monster.HP -= 100;
            if (monster.HP <= 0)
            {
                monster.HP = 0;
                progressBarHPMonster.Value = monster.PercentHP();
                string message = "Good job my friend your opponent has been killed!";
                MessageBox.Show(message);
                this.Visible = false;
            }
            else
            {
                progressBarHPMonster.Value = monster.PercentHP();
            }
            if (assassin.HP <= 0)
            {
                assassin.HP = 0;
                progressBarHPAssassin.Value = assassin.PercentHP();
                string message = "You are death, try again!";
                MessageBox.Show(message);
                this.Visible = false;
            }
            else
            {
                progressBarHPAssassin.Value = assassin.PercentHP();
            }
        }
コード例 #3
0
 private void buttonAttackWarrior_Click(object sender, EventArgs e)
 {
     /// <summary>
     /// Po nacisnieciu przycisku HP monstera i warriora zostaja pomniejszone w zaleznosci od wartosci jakie znajduja sie w funkcji Attack() w klasie Warrior i Opponent
     /// </summary>
     monster.HP -= warrior.Attack();
     warrior.HP -= monster.Attack();
     /// <summary>
     /// Sprawdzam czy zycie potwora jest mniejsze badz rowne 0 jesli tak to uzytkownik wygrywa i wyskakuje komunikat oraz chowa sie dotychczasowe okno jesli zycie jest >0 do progressbar monstera jest przypisywana funkcja PercentHP() wywolywana dla obiektu monster
     /// </summary>
     if (monster.HP <= 0)
     {
         monster.HP = 0;
         progressBarHPMonster.Value = monster.PercentHP();
         string message = "Good job my friend your opponent has been killed!";
         MessageBox.Show(message);
         this.Visible = false;
     }
     else
     {
         progressBarHPMonster.Value = monster.PercentHP();
     }
     /// <summary>
     /// Sprawdzam czy zycie warriora jest mniejsze badz rowne 0 jesli tak to uzytkownik rpzegrywa i wyskakuje komunikat oraz chowa sie dotychczasowe okno jesli zycie jest >0 do progressbar uzytkownika jest przypisywana funkcja PercentHP() wywolywana dla obiektu warrior
     /// </summary>
     if (warrior.HP <= 0)
     {
         warrior.HP = 0;
         progressBarHPWarrior.Value = warrior.PercentHP();
         string message = "You are death, try again!";
         MessageBox.Show(message);
         this.Visible = false;
     }
     else
     {
         progressBarHPWarrior.Value = warrior.PercentHP();
     }
 }