Collected coin amount is tracked

This commit is contained in:
Soulaha Balde 2022-10-29 22:49:26 -04:00
parent f29d349fde
commit c6ce11ec82
2 changed files with 8 additions and 0 deletions

View File

@ -18,6 +18,7 @@ public class Collectible : MonoBehaviour
private void OnTriggerEnter(Collider other) {
if(other.gameObject.tag.Equals("Player")){
GameController.Instance.AddCoins(amount);
Vanish();
}
}

View File

@ -14,6 +14,8 @@ public class GameController : MonoBehaviour
[SerializeField]
private Image fadeImg;
private Coroutine fadeCoroutine;
private int coinAmount = 0;
public int CoinAmount{get=>coinAmount;}
public static GameController Instance{
get{
if(instance is null)Debug.LogError("Game controller is null");
@ -31,6 +33,11 @@ public class GameController : MonoBehaviour
}
}
public void AddCoins(int amount){
//This should not be like this. Collectible should call the player that hit it and add to their amount
coinAmount += amount;
}
public void StartGame(){