MainWindow.xaml.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace KLIKER1
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для MainWindow.xaml
  19. /// </summary>
  20. public partial class MainWindow : Window
  21. {
  22. long point = 110;
  23. static int click = 1;
  24. double sol_b1 = 10 + 10 * (30 + click * 0.2);
  25. double sol_b2 = 20 + 20 * (60 + click * 0.4);
  26. double sol_b3 = 30 + 30 * (90 + click * 0.6);
  27. double sol_b4 = 40 + 40 * (120 + click * 0.8);
  28. public MainWindow()
  29. {
  30. InitializeComponent();
  31. }
  32. public void Update()
  33. {
  34. poi.Content = "Points:" + point;
  35. cli.Content = "Points for click:" + click;
  36. b1.Content = (sol_b1).ToString();
  37. b2.Content = (sol_b2).ToString();
  38. b3.Content = (sol_b3).ToString();
  39. b4.Content = (sol_b4).ToString();
  40. }
  41. private void Image_MouseDown(object sender, MouseButtonEventArgs e)
  42. {
  43. point += IncrPoint(point, click);
  44. Update();
  45. }
  46. public long IncrPoint(long point, int click)
  47. {
  48. return point += click;
  49. }
  50. private void b1_Click(object sender, RoutedEventArgs e)
  51. {
  52. if (Upgraded(point, 1))
  53. {
  54. point -= Convert.ToInt64(Math.Round(sol_b1));
  55. click = IncreaseClick(click, 1);
  56. Update();
  57. ChangeImage();
  58. }
  59. }
  60. private void b2_Click(object sender, RoutedEventArgs e)
  61. {
  62. if (Upgraded(point, 2))
  63. {
  64. point -= Convert.ToInt64(Math.Round(sol_b2));
  65. click = IncreaseClick(click, 2);
  66. Update();
  67. ChangeImage();
  68. }
  69. }
  70. private void b3_Click(object sender, RoutedEventArgs e)
  71. {
  72. if (Upgraded(point, 3))
  73. {
  74. point -= Convert.ToInt64(Math.Round(sol_b3));
  75. click = IncreaseClick(click, 3);
  76. Update();
  77. ChangeImage();
  78. }
  79. }
  80. private void b4_Click(object sender, RoutedEventArgs e)
  81. {
  82. if (Upgraded(point, 4))
  83. {
  84. point = DecPoint(point, 4);
  85. click = IncreaseClick(click, 4);
  86. Update();
  87. ChangeImage();
  88. }
  89. }
  90. public long DecPoint(long point, int BTN)
  91. {
  92. if (BTN == 1)
  93. {
  94. return point - Convert.ToInt64(Math.Round(sol_b1));
  95. }
  96. else if (BTN == 2)
  97. {
  98. return point - Convert.ToInt64(Math.Round(sol_b2));
  99. }
  100. else if (BTN == 3)
  101. {
  102. return point - Convert.ToInt64(Math.Round(sol_b3));
  103. }
  104. else
  105. {
  106. return point - Convert.ToInt64(Math.Round(sol_b4));
  107. }
  108. }
  109. public int IncreaseClick(int click, int BTN)
  110. {
  111. if (BTN == 1)
  112. {
  113. return click + 3;
  114. }
  115. else if (BTN == 2)
  116. {
  117. return click + 10;
  118. }
  119. else if (BTN == 3)
  120. {
  121. return click + 30;
  122. }
  123. else
  124. {
  125. return click + 60;
  126. }
  127. }
  128. public bool Upgraded(long point, int BTN)
  129. {
  130. if (BTN == 1)
  131. {
  132. if (point >= (sol_b1))
  133. {
  134. return true;
  135. }
  136. return false;
  137. }
  138. else if (BTN == 2)
  139. {
  140. if (point >= (sol_b2))
  141. {
  142. return true;
  143. }
  144. return false;
  145. }
  146. else if (BTN == 3)
  147. {
  148. if (point >= (sol_b3))
  149. {
  150. return true;
  151. }
  152. return false;
  153. }
  154. else
  155. {
  156. if (point >= (sol_b4))
  157. {
  158. return true;
  159. }
  160. return false;
  161. }
  162. }
  163. private void ChangeImage()
  164. {
  165. if (click > 60)
  166. {
  167. romashki.Source = BitmapFrame.Create(new Uri(@"KARTINKI/romashki-tsvety-belye-romashka-lepestki-tsvetochnyi-fon-fon.jpg"));
  168. }
  169. else if (click > 30)
  170. {
  171. romashki.Source = BitmapFrame.Create(new Uri(@"KARTINKI/romashki-tsvety-belye-romashka-lepestki-tsvetochnyi-fon-fon.jpg"));
  172. }
  173. else if (click > 10)
  174. {
  175. romashki.Source = BitmapFrame.Create(new Uri(@"KARTINKI/romashki-tsvety-belye-romashka-lepestki-tsvetochnyi-fon-fon.jpg"));
  176. }
  177. }
  178. private void exit_Click(object sender, RoutedEventArgs e)
  179. {
  180. Application.Current.Shutdown();
  181. }
  182. }
  183. }