123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using System;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Media.Imaging;
- namespace Clicker_2._0
- {
- /// <summary>
- /// Логика взаимодействия для MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- long point = 0;
- static int click = 1;
- double sol_b1 = 10 + 10 * (30 + click * 0.2);
- double sol_b2 = 20 + 20 * (60 + click * 0.4);
- double sol_b3 = 30 + 30 * (90 + click * 0.6);
- double sol_b4 = 40 + 40 * (1200 + click * 0.8);
- public MainWindow()
- {
- InitializeComponent();
- }
- public void Update()
- {
- poi.Text = "Points: " + point; // Вывод Points в первый label
- cli.Text = "Points for click: " + click; // Вывод Points per click во второй label
- b1.Content = (sol_b1).ToString(); //
- b2.Content = (sol_b2).ToString(); // Вывод цены Upgrade для Points per click на кнопке
- b3.Content = (sol_b3).ToString(); //
- b4.Content = (sol_b4).ToString(); //
- }
- // ClickImg
- private void Image_MouseDown(object sender, MouseButtonEventArgs e)
- {
- point = IncreasePoint(point, click);
- Update();
- }
- public long IncreasePoint(long point, int click)
- {
- return point += click;
- }
- // UpgradeBtn1
- private void b1_Click(object sender, RoutedEventArgs e)
- {
- if (IsUpgraded(point, 1))
- {
- point -= Convert.ToInt64(Math.Round(sol_b1));
- click = IncreaseClick(click, 1);
- Update();
- ChangeImage();
- }
- }
- // UpgradeBtn2
- private void b2_Click(object sender, RoutedEventArgs e)
- {
- if (IsUpgraded(point, 2))
- {
- point -= Convert.ToInt64(Math.Round(sol_b2));
- click = IncreaseClick(click, 2);
- Update();
- ChangeImage();
- }
- }
- // UpgradeBtn3
- private void b3_Click(object sender, RoutedEventArgs e)
- {
- if (IsUpgraded(point, 3))
- {
- point -= Convert.ToInt64(Math.Round(sol_b3));
- click = IncreaseClick(click, 3);
- Update();
- ChangeImage();
- }
- }
- // UpgradeBtn4
- private void b4_Click(object sender, RoutedEventArgs e)
- {
- if (IsUpgraded(point, 4))
- {
- point = DecreasePoint(point, 4);
- click = IncreaseClick(click, 4);
- Update();
- ChangeImage();
- }
- }
- public long DecreasePoint(long point, int btnLvl)
- {
- if (btnLvl == 1)
- {
- return point - Convert.ToInt64(Math.Round(sol_b1));
- }
- else if (btnLvl == 2)
- {
- return point - Convert.ToInt64(Math.Round(sol_b2));
- }
- else if (btnLvl == 3)
- {
- return point - Convert.ToInt64(Math.Round(sol_b3));
- }
- else
- {
- return point - Convert.ToInt64(Math.Round(sol_b4));
- }
- }
- public int IncreaseClick(int click, int btnLvl)
- {
- if (btnLvl == 1)
- {
- return click + 3;
- }
- else if (btnLvl == 2)
- {
- return click + 10;
- }
- else if (btnLvl == 3)
- {
- return click + 30;
- }
- else
- {
- return click + 50;
- }
- }
- public bool IsUpgraded(long point, int btnLvl)
- {
- if (btnLvl == 1)
- {
- if (point >= (sol_b1))
- {
- return true;
- }
- return false;
- }
- else if (btnLvl == 2)
- {
- if (point >= (sol_b2))
- {
- return true;
- }
- return false;
- }
- else if (btnLvl == 3)
- {
- if (point >= (sol_b3))
- {
- return true;
- }
- return false;
- }
- else
- {
- if (point >= (sol_b4))
- {
- return true;
- }
- return false;
- }
- }
- private void ChangeImage()
- {
- if (click > 50)
- {
- imgYatoro.Source = BitmapFrame.Create(new Uri(@"Images/YatoroWin.jpg"));
- }
- else if (click > 30)
- {
- imgYatoro.Source = BitmapFrame.Create(new Uri(@"Images/Yatoro.jpg"));
- }
- else if (click > 10)
- {
- imgYatoro.Source = BitmapFrame.Create(new Uri(@"Images/YatoroDnw.jpg"));
- }
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- Close();
- }
- }
- }
|