Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. namespace KarolDembskiZad2
  2. {
  3. public partial class FormMain : Form
  4. {
  5. int opponentCounter = 1;
  6. List<FastFood> fastFoods = new List<FastFood>();
  7. Freshman player;
  8. FastFood opponent;
  9.  
  10. public FormMain()
  11. {
  12. InitializeComponent();
  13. fastFoods.Add(new FastFood(1, 100, 10, 10, 10, 10, 10, 10));
  14. fastFoods.Add(new FastFood(2, 200, 10, 10, 10, 10, 10, 20));
  15. fastFoods.Add(new FastFood(3, 100, 10, 10, 10, 10, 10, 30));
  16. fastFoods.Add(new FastFood(4, 100, 10, 10, 10, 10, 10, 40));
  17. fastFoods.Add(new FastFood(5, 100, 10, 10, 10, 10, 10, 50));
  18. fastFoods.Add(new FastFood(6, 100, 10, 10, 10, 10, 10, 60));
  19.  
  20. }
  21.  
  22. private void pictureBoxCarrotChosen_Click(object sender, EventArgs e)
  23. {
  24. Freshman carrot = new Freshman("Marchewka", 100, 20, 30, 40, 50, 60);
  25. player = carrot;
  26. panelIntroduction.Visible = false;
  27. panelMain.Visible = true;
  28. UpdateStats();
  29. }
  30.  
  31. private void UpdateStats()
  32. {
  33. labelAttackValue.Text = player.ReturnAttack().ToString();
  34. labelDefenseValue.Text = player.ReturnDefense().ToString();
  35. labelMaxLifeValue.Text = player.ReturnMaxLife().ToString();
  36. labelSpecialAttackValue.Text = player.ReturnSpecialAttack().ToString();
  37. labelSpecialDefenseValue.Text = player.ReturnSpecialDefense().ToString();
  38. labelSpeedValue.Text = player.ReturnSpeed().ToString();
  39. labelLevelValue.Text = player.ReturnLevel().ToString();
  40. labelExperienceValue.Text = player.ReturnExperience().ToString();
  41. labelNexLevelExperienceValue.Text = player.ReturnNextLevelExp().ToString();
  42. }
  43.  
  44. private void buttonArena_Click(object sender, EventArgs e)
  45. {
  46. foreach (FastFood fastFood in fastFoods)
  47. {
  48. if (fastFood.ReturnOpponentCounter() == opponentCounter)
  49. {
  50. panelBattle.Visible = true;
  51. opponent = fastFood;
  52. labelOpponentLife.Text = opponent.ReturnLife().ToString();
  53. labelPlayerLife.Text = player.ReturnLife().ToString();
  54. }
  55. }
  56.  
  57. }
  58.  
  59. private void EndOfBattle(int playerLife, int opponentLife)
  60. {
  61. if (playerLife <= 0)
  62. {
  63. MessageBox.Show("Przegrałeś walkę ale możesz spróbować ponownie");
  64. panelBattle.Visible = false;
  65. player.SetLife(player.ReturnMaxLife());
  66. opponent.SetLife(opponent.ReturnMaxLife());
  67. }
  68. if (opponentLife <= 0)
  69. {
  70. MessageBox.Show("Wygrałeś walkę");
  71. panelBattle.Visible = false;
  72. opponentCounter++;
  73. player.SetLife(player.ReturnMaxLife());
  74. opponent.SetLife(opponent.ReturnMaxLife());
  75. player.AddExperience(opponent.ReturnLevel() * 5);
  76. player.LevelUp();
  77. UpdateStats();
  78.  
  79. }
  80. }
  81.  
  82. private void buttonUseAttack_Click(object sender, EventArgs e)
  83. {
  84. player.Attack(opponent);
  85. labelOpponentLife.Text = opponent.ReturnLife().ToString();
  86. opponent.Attack(player);
  87. labelPlayerLife.Text = player.ReturnLife().ToString();
  88. EndOfBattle(player.ReturnLife(), opponent.ReturnLife());
  89. }
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement