Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- public class ScoreManger : MonoBehaviour
- {
- [SerializeField] int lives = 20; // number of enemies allowed to pass the level before failure
- public int gold = 200; // Sufficient starting capital to build the beginning set of towers
- public Text moneyText;
- public Text livesText;
- private void Start() {
- moneyText.text = "Gold:";
- livesText.text = "20";
- DontDestroyOnLoad(gameObject);
- }
- public void ReduceLife(int val){
- lives -= val;
- if (lives <= 0){
- GameOver();
- }
- }
- void GameOver(){
- // Add menus or reload scene
- Debug.Log("Game Over");
- SceneManager.LoadScene(SceneManager.GetActiveScene().name);
- }
- private void Update() {
- moneyText.text = gold.ToString();
- livesText.text = lives.ToString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement