Hello, I am currently making this cookie clicker game just for fun. I got the clicking to work and the power of the click when you buy the upgrade, but there is one problem. The amount of cookies will not go down so I checked the script and forgot one thing to make it decrease.
I get an error like so:
Assets/UpgradeManager.cs(23,13): error CS0266: Cannot implicitly convert type float' to
int’. An explicit conversion exists (are you missing a cast?)
Here is my script
using UnityEngine;
public class UpgradeManager : MonoBehaviour {
public Click click;
public UnityEngine.UI.Text itemInfo;
public float cost;
public int count = 0;
public int clickPower;
public string itemName;
private float _newCost;
void Update() {
itemInfo.text = itemName + "\nCost: " + cost + "\nPower: +" + clickPower;
}
public void PurchasedUpgrade() {
if (click.cookie >= cost) {
click.cookie -= cost;
count += 1;
click.cookieperclick += clickPower;
cost = Mathf.Round(cost * 1.15f);
_newCost = Mathf.Pow(cost, _newCost = cost);
}
}
}
public float cost; makes click.cookie -= cost; wrong. If I change public float to an int it makes cost= Mathf.Round(cost*1.15f);
I am very confused on how and what to fix. Thank you for helping.