MainWindow.xaml.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Input;
  4. namespace Kliker
  5. {
  6. public partial class MainWindow : Window
  7. {
  8. long point = 0;
  9. static int click = 1;
  10. double sol_b1 = 10 + 10 * (30 + click * 0.2);
  11. double sol_b2 = 20 + 20 * (60 + click * 0.4);
  12. double sol_b3 = 30 + 30 * (90 + click * 0.6);
  13. double sol_b4 = 40 + 40 * (1200 + click * 0.8);
  14. public MainWindow()
  15. {
  16. InitializeComponent();
  17. }
  18. public void Update()
  19. {
  20. poi.Content = "Points: " + point;
  21. cli.Content = "Points for click: " + click;
  22. b1.Content = (sol_b1).ToString();
  23. b2.Content = (sol_b2).ToString();
  24. b3.Content = (sol_b3).ToString();
  25. b4.Content = (sol_b4).ToString();
  26. }
  27. private void Image_MouseDown(object sender, MouseButtonEventArgs e)
  28. {
  29. point = IncreasePoint(point, click);
  30. Update();
  31. }
  32. public long IncreasePoint(long point, int click)
  33. {
  34. return point += click;
  35. }
  36. private void b1_Click(object sender, RoutedEventArgs e)
  37. {
  38. if (IsUpgraded(point, 1))
  39. {
  40. point -= Convert.ToInt64(Math.Round(sol_b1));
  41. click = IncreaseClick(click, 1);
  42. Update();
  43. }
  44. }
  45. private void b2_Click(object sender, RoutedEventArgs e)
  46. {
  47. if (IsUpgraded(point, 2))
  48. {
  49. point -= Convert.ToInt64(Math.Round(sol_b2));
  50. click = IncreaseClick(click, 2);
  51. Update();
  52. }
  53. }
  54. private void b3_Click(object sender, RoutedEventArgs e)
  55. {
  56. if (IsUpgraded(point, 3))
  57. {
  58. point -= Convert.ToInt64(Math.Round(sol_b3));
  59. click = IncreaseClick(click, 3);
  60. Update();
  61. }
  62. }
  63. private void b4_Click(object sender, RoutedEventArgs e)
  64. {
  65. if (IsUpgraded(point, 4))
  66. {
  67. point = DecreasePoint(point, 4);
  68. click = IncreaseClick(click, 4);
  69. Update();
  70. }
  71. }
  72. public long DecreasePoint(long point, int btnLvl)
  73. {
  74. if (btnLvl == 1)
  75. {
  76. return point - Convert.ToInt64(Math.Round(sol_b1));
  77. }
  78. else if (btnLvl == 2)
  79. {
  80. return point - Convert.ToInt64(Math.Round(sol_b2));
  81. }
  82. else if (btnLvl == 3)
  83. {
  84. return point - Convert.ToInt64(Math.Round(sol_b3));
  85. }
  86. else
  87. {
  88. return point - Convert.ToInt64(Math.Round(sol_b4));
  89. }
  90. }
  91. public int IncreaseClick(int click, int btnLvl)
  92. {
  93. if (btnLvl == 1)
  94. {
  95. return click + 3;
  96. }
  97. else if (btnLvl == 2)
  98. {
  99. return click + 10;
  100. }
  101. else if (btnLvl == 3)
  102. {
  103. return click + 30;
  104. }
  105. else
  106. {
  107. return click + 50;
  108. }
  109. }
  110. public bool IsUpgraded(long point, int btnLvl)
  111. {
  112. if (btnLvl == 1)
  113. {
  114. if (point >= (sol_b1))
  115. {
  116. return true;
  117. }
  118. return false;
  119. }
  120. else if (btnLvl == 2)
  121. {
  122. if (point >= (sol_b2))
  123. {
  124. return true;
  125. }
  126. return false;
  127. }
  128. else if (btnLvl == 3)
  129. {
  130. if (point >= (sol_b3))
  131. {
  132. return true;
  133. }
  134. return false;
  135. }
  136. else
  137. {
  138. if (point >= (sol_b4))
  139. {
  140. return true;
  141. }
  142. return false;
  143. }
  144. }
  145. private void b5_Click(object sender, RoutedEventArgs e)
  146. {
  147. Close();
  148. }
  149. }
  150. }