in my game i have stores but when i buy 1 store the money goes from 2.5 to 0 so there is not an at the beginning of the number does anyone know why and how??
this is my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class script : MonoBehaviour
{
float BaseStoreCost;
float CurrentBalance;
float BaseStoreProfit;
int StoreCount;
public Text StoreCountText;
public Text CurrentBalancetext;
float StoreTimer = 1f;
float currentTimer = 0;
bool StartTimer;
// Start is called before the first frame update
void Start()
{
StoreCount = 0;
CurrentBalance = 2.50f;
BaseStoreCost = 2.50f;
BaseStoreProfit = 0.50f;
CurrentBalancetext.text = CurrentBalance.ToString(“C2”);
StartTimer = false;
}
// Update is called once per frame
void Update()
{ if (StartTimer)
{
currentTimer += Time.deltaTime;
if (currentTimer > StoreTimer)
{
{
StartTimer = false;
currentTimer = 0f;
CurrentBalance += BaseStoreProfit * StoreCount;
CurrentBalancetext.text = CurrentBalance.ToString(“C2”);
}
}
}
}
public void BuyStoreOnClick()
{
if (BaseStoreCost > CurrentBalance)
return;
StoreCount = StoreCount + 1;
Debug.Log(StoreCount);
StoreCountText.text = StoreCount.ToString();
CurrentBalance = CurrentBalance - BaseStoreCost;
Debug.Log(CurrentBalance);
CurrentBalancetext.text = CurrentBalance.ToString();
}
public void StoreOnClick()
{
Debug.Log(“clicked the store”);
if (!StartTimer)
StartTimer = true;
}
}