MainWindow.xaml.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Input;
  4. using System.Windows.Media.Imaging;
  5. namespace Clicker_2._0
  6. {
  7. public partial class MainWindow : Window
  8. {
  9. long point = 0;
  10. static int click = 1;
  11. double sol_b1 = 10 + 10 * (30 + click * 0.2);
  12. double sol_b2 = 20 + 20 * (60 + click * 0.4);
  13. double sol_b3 = 30 + 30 * (90 + click * 0.6);
  14. double sol_b4 = 40 + 40 * (1200 + click * 0.8);
  15. public MainWindow()
  16. {
  17. InitializeComponent();
  18. }
  19. public void Update()
  20. {
  21. poi.Text = "Points: " + point; // Вывод Points в первый label
  22. cli.Text = "Points for click: " + click; // Вывод Points per click во второй label
  23. b1.Content = (sol_b1).ToString(); //
  24. b2.Content = (sol_b2).ToString(); // Вывод цены Upgrade для Points per click на кнопке
  25. b3.Content = (sol_b3).ToString(); //
  26. b4.Content = (sol_b4).ToString(); //
  27. }
  28. // ClickImg
  29. private void Image_MouseDown(object sender, MouseButtonEventArgs e)
  30. {
  31. point = IncreasePoint(point, click);
  32. Update();
  33. }
  34. public long IncreasePoint(long point, int click)
  35. {
  36. return point += click;
  37. }
  38. // UpgradeBtn1
  39. private void b1_Click(object sender, RoutedEventArgs e)
  40. {
  41. if (IsUpgraded(point, 1))
  42. {
  43. point -= Convert.ToInt64(Math.Round(sol_b1));
  44. click = IncreaseClick(click, 1);
  45. Update();
  46. ChangeImage();
  47. }
  48. }
  49. // UpgradeBtn2
  50. private void b2_Click(object sender, RoutedEventArgs e)
  51. {
  52. if (IsUpgraded(point, 2))
  53. {
  54. point -= Convert.ToInt64(Math.Round(sol_b2));
  55. click = IncreaseClick(click, 2);
  56. Update();
  57. ChangeImage();
  58. }
  59. }
  60. // UpgradeBtn3
  61. private void b3_Click(object sender, RoutedEventArgs e)
  62. {
  63. if (IsUpgraded(point, 3))
  64. {
  65. point -= Convert.ToInt64(Math.Round(sol_b3));
  66. click = IncreaseClick(click, 3);
  67. Update();
  68. ChangeImage();
  69. }
  70. }
  71. // UpgradeBtn4
  72. private void b4_Click(object sender, RoutedEventArgs e)
  73. {
  74. if (IsUpgraded(point, 4))
  75. {
  76. point = DecreasePoint(point, 4);
  77. click = IncreaseClick(click, 4);
  78. Update();
  79. ChangeImage();
  80. }
  81. }
  82. public long DecreasePoint(long point, int btnLvl)
  83. {
  84. if (btnLvl == 1)
  85. {
  86. return point - Convert.ToInt64(Math.Round(sol_b1));
  87. }
  88. else if (btnLvl == 2)
  89. {
  90. return point - Convert.ToInt64(Math.Round(sol_b2));
  91. }
  92. else if (btnLvl == 3)
  93. {
  94. return point - Convert.ToInt64(Math.Round(sol_b3));
  95. }
  96. else
  97. {
  98. return point - Convert.ToInt64(Math.Round(sol_b4));
  99. }
  100. }
  101. public int IncreaseClick(int click, int btnLvl)
  102. {
  103. if (btnLvl == 1)
  104. {
  105. return click + 3;
  106. }
  107. else if (btnLvl == 2)
  108. {
  109. return click + 10;
  110. }
  111. else if (btnLvl == 3)
  112. {
  113. return click + 30;
  114. }
  115. else
  116. {
  117. return click + 50;
  118. }
  119. }
  120. public bool IsUpgraded(long point, int btnLvl)
  121. {
  122. if (btnLvl == 1)
  123. {
  124. if (point >= (sol_b1))
  125. {
  126. return true;
  127. }
  128. return false;
  129. }
  130. else if (btnLvl == 2)
  131. {
  132. if (point >= (sol_b2))
  133. {
  134. return true;
  135. }
  136. return false;
  137. }
  138. else if (btnLvl == 3)
  139. {
  140. if (point >= (sol_b3))
  141. {
  142. return true;
  143. }
  144. return false;
  145. }
  146. else
  147. {
  148. if (point >= (sol_b4))
  149. {
  150. return true;
  151. }
  152. return false;
  153. }
  154. }
  155. private void ChangeImage()
  156. {
  157. if (click > 50)
  158. {
  159. imgYatoro.Source = BitmapFrame.Create(new Uri(@"Images/Fu52dUuNjnw.jpg"));
  160. }
  161. else if (click > 30)
  162. {
  163. imgYatoro.Source = BitmapFrame.Create(new Uri(@"Images/NBDNXdMmbvo.jpg"));
  164. }
  165. else if (click > 10)
  166. {
  167. imgYatoro.Source = BitmapFrame.Create(new Uri(@"Images/pB7_36sqGuY.jpg"));
  168. }
  169. }
  170. private void Button_Click(object sender, RoutedEventArgs e)
  171. {
  172. Close();
  173. }
  174. }
  175. }