Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace KarolDembskiZad2
- {
- public partial class FormMain : Form
- {
- int opponentCounter = 1;
- List<FastFood> fastFoods = new List<FastFood>();
- Freshman player;
- FastFood opponent;
- public FormMain()
- {
- InitializeComponent();
- fastFoods.Add(new FastFood(1, 100, 10, 10, 10, 10, 10, 10));
- fastFoods.Add(new FastFood(2, 200, 10, 10, 10, 10, 10, 20));
- fastFoods.Add(new FastFood(3, 100, 10, 10, 10, 10, 10, 30));
- fastFoods.Add(new FastFood(4, 100, 10, 10, 10, 10, 10, 40));
- fastFoods.Add(new FastFood(5, 100, 10, 10, 10, 10, 10, 50));
- fastFoods.Add(new FastFood(6, 100, 10, 10, 10, 10, 10, 60));
- }
- private void pictureBoxCarrotChosen_Click(object sender, EventArgs e)
- {
- Freshman carrot = new Freshman("Marchewka", 100, 20, 30, 40, 50, 60);
- player = carrot;
- panelIntroduction.Visible = false;
- panelMain.Visible = true;
- UpdateStats();
- }
- private void UpdateStats()
- {
- labelAttackValue.Text = player.ReturnAttack().ToString();
- labelDefenseValue.Text = player.ReturnDefense().ToString();
- labelMaxLifeValue.Text = player.ReturnMaxLife().ToString();
- labelSpecialAttackValue.Text = player.ReturnSpecialAttack().ToString();
- labelSpecialDefenseValue.Text = player.ReturnSpecialDefense().ToString();
- labelSpeedValue.Text = player.ReturnSpeed().ToString();
- labelLevelValue.Text = player.ReturnLevel().ToString();
- labelExperienceValue.Text = player.ReturnExperience().ToString();
- labelNexLevelExperienceValue.Text = player.ReturnNextLevelExp().ToString();
- }
- private void buttonArena_Click(object sender, EventArgs e)
- {
- foreach (FastFood fastFood in fastFoods)
- {
- if (fastFood.ReturnOpponentCounter() == opponentCounter)
- {
- panelBattle.Visible = true;
- opponent = fastFood;
- labelOpponentLife.Text = opponent.ReturnLife().ToString();
- labelPlayerLife.Text = player.ReturnLife().ToString();
- }
- }
- }
- private void EndOfBattle(int playerLife, int opponentLife)
- {
- if (playerLife <= 0)
- {
- MessageBox.Show("Przegrałeś walkę ale możesz spróbować ponownie");
- panelBattle.Visible = false;
- player.SetLife(player.ReturnMaxLife());
- opponent.SetLife(opponent.ReturnMaxLife());
- }
- if (opponentLife <= 0)
- {
- MessageBox.Show("Wygrałeś walkę");
- panelBattle.Visible = false;
- opponentCounter++;
- player.SetLife(player.ReturnMaxLife());
- opponent.SetLife(opponent.ReturnMaxLife());
- player.AddExperience(opponent.ReturnLevel() * 5);
- player.LevelUp();
- UpdateStats();
- }
- }
- private void buttonUseAttack_Click(object sender, EventArgs e)
- {
- player.Attack(opponent);
- labelOpponentLife.Text = opponent.ReturnLife().ToString();
- opponent.Attack(player);
- labelPlayerLife.Text = player.ReturnLife().ToString();
- EndOfBattle(player.ReturnLife(), opponent.ReturnLife());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement