BloodknightStudios icon

Untitled

BloodknightStudios | PRO | 11/07/22 06:33:16 PM UTC | 0 ⭐ | 404 👁️ | Never ⏰ | []
text |

1 KB

|

None

|

0 👍

/

0 👎

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();    }} 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎