Collected coin amount is tracked
This commit is contained in:
parent
f29d349fde
commit
c6ce11ec82
@ -18,6 +18,7 @@ public class Collectible : MonoBehaviour
|
||||
|
||||
private void OnTriggerEnter(Collider other) {
|
||||
if(other.gameObject.tag.Equals("Player")){
|
||||
GameController.Instance.AddCoins(amount);
|
||||
Vanish();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
@ -32,6 +34,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(){
|
||||
fadeCoroutine = StartCoroutine(FadeToBlack(mainScene, true,fadeSpeed));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user