// iterates over click mining objects and adds their Quantity * generation Value to you Cheese.
 public void Mine()
 {
     ClickUpgrades.ForEach(miner =>
     {
         Cheese += miner.Quantity * miner.GenValue;
     });
 }
Exemple #2
0
    private void CheckButton() //Deals with purchasing an upgrade
    {
        if (selectedObject != null)
        {
            if (selectedObject.GetComponent <UpgradeScriptBuilding>() != null)
            {
                script = selectedObject.GetComponent <UpgradeScriptBuilding>();
                textBox.SetActive(true);
                print(script.desc);
                Desc.text = (script.Desc);
            }
            else
            {
                textBox.SetActive(false);
            }

            if (selectedObject.GetComponent <ClickUpgrades>() != null)
            {
                script2 = selectedObject.GetComponent <ClickUpgrades>();
                textBox.SetActive(true);
                print(script2.Desc);
                Desc.text = (script2.Desc);
            }
        }
    }
        // 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;
        }