Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. //there is defined Player valiables - 'HP', 'ATK','DEF' etc..
  2. void FightAction(int ATKf, int DEFf, TYPEf)
  3. {
  4. Random generator = new Random();
  5. int PlayerHP = Convert.ToInt32(HP); // 100
  6. int FighterHP = HPf; // 20
  7.  
  8. fight:
  9.  
  10. int PlayerATK = ATK + generator.Next(0, 3);
  11. int PlayerDEF = DEF + generator.Next(0, 3);
  12. int FighterATK = ATKf + generator.Next(0, 3);
  13. int FighterDEF = DEFf + generator.Next(0, 3);
  14.  
  15. txt_CalcPlayer.Content = NAME + "\nHP: " + PlayerHP + "\nÚtok: " + PlayerATK + "\nObrana: " + PlayerDEF;
  16. txt_CalcEnemy.Content = NAMEf + "\n" + FighterHP + " :HP\n" + FighterATK + " :Útok\n" + FighterDEF + " :Obrana";
  17.  
  18. int PlayerAttack = PlayerATK - FighterDEF; //(5-7) - (2-4) = 5
  19. int FighterAttack = FighterATK - PlayerDEF; //(5-7) - (2-4) = 7
  20.  
  21.  
  22.  
  23. if (FighterAttack <= 0) { FighterAttack = 0; }
  24. if (PlayerAttack <= 0) { PlayerAttack = 0; }
  25.  
  26. PlayerHP = (PlayerHP - FighterAttack);
  27. FighterHP = (FighterHP - PlayerAttack);
  28.  
  29. HP = PlayerHP;
  30. HPControl();
  31.  
  32.  
  33.  
  34. if (FighterHP < 0) { FighterHP = 0; }
  35. if (PlayerHP < 0) { PlayerHP = 0; }
  36.  
  37. if (isAlive == true)
  38. {
  39. txt_CalcPlayer.Content = NAME + "\nHP: " + PlayerHP + "\nÚtok: " + PlayerATK + "\nObrana: " + PlayerDEF;
  40. txt_CalcEnemy.Content = NAMEf + "\n" + FighterHP + " :HP\n" + FighterATK + " :Útok\n" + FighterDEF + " :Obrana";
  41. while (!gotResponse)
  42. {
  43. btn_FightRound.Visibility = Visibility.Visible;
  44. btn_FightRound.Content = "FIGHT";
  45. }
  46. btn_FightRound.Visibility = Visibility.Hidden;
  47. gotResponse = false;
  48. goto fight;
  49. }
  50. private void btn_FightRound_Click(object sender, RoutedEventArgs e)
  51. {
  52. gotResponse = true;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement