Hello everybody i'm having an issue with the score and the currency thing, the game had a coins so the player can collect them so what i want to, the coins add to the currency text ,every time when i play automatically they increase what i took coins in the game and at the end to load and save the currency so when i re-open the game so i can see the collected coins doesn't changed
Here's the GameManager script
public Text scoreText, coinText, modifierText, hiscoreText;
private float score, coinScore, modifierScore;
public void GetCoin()
{
diamondAnim.SetTrigger("Collect");
coinScore++;
coinText.text = coinScore.ToString("0");
score += COIN_SCORE_AMOUNT;
scoreText.text = score.ToString("0");
}
Here's the shopPanel script
//test
public static int money = 0;
public Text coinsTxt;
public Text currencyTxt;
public static int totalMoney;
void Awake()
*{
currencyTxt = PlayerPrefs.GetInt ("Coins");
}*
private void Update()
{
coinsTxt.text = "Coins: " + currencyTxt;
coinsTxt.text = "" + money;
}
void TotalMoney()
{
money += totalMoney;
currencyTxt.text = "" + totalMoney;
}
Coin script !
public class Coin : MonoBehaviour {
private Animator anim;
private void Awake()
{
anim = GetComponent<Animator>();
}
private void OnEnable()
{
anim.SetTrigger("Spawn");
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
//CurrencyManager.gameManager.AddMoney(1);
GameManager.Instance.GetCoin();
anim.SetTrigger("Collected");
}
}
}