// iterates over automine objects and adds their Quantity * generation Value to you Cheese. Timer callbacks need to take in an object as a parameter. public void AutoMine(object o) { AutoUpgrades.ForEach(miner => { Cheese += (miner.Quantity * miner.GenValue) * 5; }); // keeps our auto interval from interupting our user while in another game screen if (inShop == false) { DrawGameScreen(); } }
// Purchases an item from the shop menu public void BuyUpgrade(int shopIndex) { Upgrade item = Shop[shopIndex]; if (Cheese >= item.Price) { Cheese -= item.Price; item.Price += item.Price; if (item.Type == "click") { // This checks to see if we already have purchased this upgrade, if we have not, we will add it to our upgrades, if we do it will increment the quantity of the upgrade we have. int index = ClickUpgrades.FindIndex(i => i.Name == item.Name); if (index == -1) { ClickUpgrades.Add(item); index = ClickUpgrades.Count - 1; } ClickUpgrades[index].Quantity++; Stats[item.Name] = ClickUpgrades[index].Quantity; } else { // This checks to see if we already have purchased this upgrade, if we have not, we will add it to our upgrades, if we do it will increment the quantity of the upgrade we have. int index = AutoUpgrades.FindIndex(i => i.Name == item.Name); if (index == -1) { AutoUpgrades.Add(item); index = AutoUpgrades.Count - 1; } AutoUpgrades[index].Quantity++; Stats[item.Name] = AutoUpgrades[index].Quantity; } Console.Beep(1000, 90); Console.Beep(1200, 90); Console.WriteLine($"You Purchezed 1 {item.Name}... tank you for you buzinez"); } else { Console.Beep(400, 450); Console.WriteLine($"you don't heav enough cheez to by {item.Name}... go away."); } // Using a Readkey so the user has a moment to read the message before they continue. Console.WriteLine("press any key to continue"); Console.ReadKey(); inShop = false; }