Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Incremental
- {
- public partial class Form1 : Form
- {
- private int score = 0;
- private int clickFactor = 1;
- private double priceIncrement = 1.5;
- private Dictionary<string, Dictionary<string, int>> items = new Dictionary<string, Dictionary<string, int>>
- {
- {"Joke", new Dictionary<string, int> {{"price", 10}, {"score", 1}, {"owned", 0}}},
- {"Feather", new Dictionary<string, int> {{"price", 50}, {"score", 3}, {"owned", 0}}},
- {"Laughing Gas", new Dictionary<string, int> {{"price", 200}, {"score", 5}, {"owned", 0}}}
- };
- private Dictionary<string, Dictionary<string, Control>> controls = new Dictionary<string, Dictionary<string, Control>>();
- public Form1()
- {
- InitializeComponent();
- createButtons();
- }
- private void createButtons()
- {
- int count = 0;
- foreach (KeyValuePair<string, Dictionary<string, int>> item in items)
- {
- Button btn = new Button();
- btn.Text = item.Key;
- btn.Size = new Size(137, 23);
- btn.Location = new Point(329, 32 + 28 * count);
- btn.Click += btnItem_Click;
- Label price = new Label();
- price.Text = items[item.Key]["price"].ToString();
- price.Location = new Point(265, 37 + 28 * count);
- Label owned = new Label();
- owned.Text = items[item.Key]["owned"].ToString();
- owned.Location = new Point(472, 37 + 28 * count);
- this.Controls.Add(btn);
- this.Controls.Add(price);
- this.Controls.Add(owned);
- controls.Add(item.Key, new Dictionary<string, Control> {
- {"button", btn},
- {"price", price},
- {"owned", owned}
- });
- count++;
- }
- }
- private void scoreUpdater_Tick(object sender, EventArgs e)
- {
- int addScore = 0;
- foreach (KeyValuePair<string, Dictionary<string, int>> item in items)
- {
- addScore += items[item.Key]["owned"] * items[item.Key]["score"];
- }
- lblTicklesPerSec.Text = addScore.ToString();
- score += addScore;
- }
- private void gameLoop_Tick(object sender, EventArgs e)
- {
- foreach (KeyValuePair<string, Dictionary<string, Control>> control in controls)
- {
- controls[control.Key]["button"].Enabled = score >= items[control.Key]["price"];
- controls[control.Key]["price"].Text = items[control.Key]["price"].ToString();
- controls[control.Key]["owned"].Text = items[control.Key]["owned"].ToString();
- }
- lblTickles.Text = score.ToString();
- }
- private void btnClick_MouseDown(object sender, MouseEventArgs e)
- {
- btnClick.Text = "^o^";
- }
- private void btnClick_MouseUp(object sender, MouseEventArgs e)
- {
- btnClick.Text = "o_o";
- score += clickFactor;
- }
- private void buyItem(string item)
- {
- score -= items[item]["price"];
- items[item]["price"] = (int)(items[item]["price"] * priceIncrement);
- items[item]["owned"] += 1;
- }
- private void btnItem_Click(object sender, EventArgs e)
- {
- buyItem(((Button)sender).Text);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment