This repository was archived by the owner on Oct 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
99 lines (89 loc) · 3 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Threading;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CookieClicker
{
/// <summary>
/*TODO:
* Get button click event
* Store amount of clicks in a variable.
* Update the cookie count by 1
*/
/// </summary>
public partial class MainWindow : Window
{
int currentCookies;
int clickPower = 1;
int currentAutos = 0;
int betterClickCount = 0;
int autoClickerPrice = 50;
int betterClickPrice = 80;
DispatcherTimer autoTimer = new DispatcherTimer();
public MainWindow()
{
InitializeComponent();
}
public void InitTimer()
{
autoTimer.Interval = new TimeSpan(0, 0, 2);
autoTimer.Tick += new EventHandler(timer1_Tick);
}
private void timer1_Tick(object sender, EventArgs e)
{
moreCookie(currentAutos);
}
private void moreCookie(int clickCounts)
{
currentCookies += clickCounts;
cookieText.Content = "Cookies: " + currentCookies.ToString();
}
private void cookieClick(object sender, RoutedEventArgs e)
{
moreCookie(clickPower);
}
private void buyAuto(object sender, RoutedEventArgs e)
{
if (currentCookies >= autoClickerPrice)
{
currentCookies = currentCookies - autoClickerPrice;
currentAutos++;
autoClickerPrice += 10;
cookieText.Content = "Cookies: " + currentCookies.ToString();
afkClickText.Content = "Current AFK Clicks: " + currentAutos.ToString();
currentAFKClicks.Content = "Auto Clickers: " + currentAutos.ToString();
buy1.Content = "Buy \n Cost: " + autoClickerPrice.ToString();
if (autoTimer.IsEnabled == false)
{
InitTimer();
autoTimer.Start();
}
}
}
private void buyBetterClicks(object sender, RoutedEventArgs e)
{
if (currentCookies >= betterClickPrice)
{
currentCookies = currentCookies - betterClickPrice;
clickPower++;
betterClickPrice += 20;
cookieText.Content = "Cookies: " + currentCookies.ToString();
clickPowerText.Content = "Current Click Power: " + clickPower.ToString();
currentBetterClicks.Content = "Better Clicks: " + betterClickCount.ToString();
buy2.Content = "Buy \n Cost: " + betterClickPrice.ToString();
}
}
}
}