hello I am making an incremental game but it is not adding the gold after each second even after buying the items, heres my code:
using UnityEngine;
using System.Collections;
public class GoldPerSec : MonoBehaviour {
public UnityEngine.UI.Text gpsDisplay;
public Click1 click;
public ItemManager[]items;
void start (){
StartCoroutine (AutoTick ());
}
void Update(){
gpsDisplay.text = GetGoldPerSec () + "gold/sec";
}
public int GetGoldPerSec(){
int tick = 0;
foreach(ItemManager item in items) {
tick += item.count * item.tickValue;
}
return tick;
}
public void AutoGoldPerSec(){
}
IEnumerator AutoTick(){
while(true) {
AutoGoldPerSec();
yield return new WaitForSeconds(1);
}
}
}
using UnityEngine;
using System.Collections;
public class ItemManager : MonoBehaviour {
public UnityEngine.UI.Text itemInfo;
public Click1 click;
public float cost;
public int tickValue;
public int count;
public string itemName;
private float baseCost;
void start(){
baseCost = cost;
}
void Update(){
itemInfo.text = itemName + "\nCost: " + cost + "\nGold " + tickValue + "/s";
}
public void PurchasedItem(){
if (click.gold >= cost)
click.gold -= cost;
count +=1;
cost = Mathf.Round (baseCost * Mathf.Pow (1.15f, count));
}
}