Advertisement
evelynshilosky

TimeManager - Part 38

Apr 18th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using UnityEngine;
  5. using UnityEngine.Events;
  6.  
  7. public class TimeManager : MonoBehaviour
  8. {
  9.     public static TimeManager Instance { get; set; }
  10.  
  11.     public UnityEvent OnDayPass = new UnityEvent(); // Day Passed Event
  12.  
  13.  
  14.     private void Awake()
  15.     {
  16.         if (Instance != null && Instance != this)
  17.         {
  18.             Destroy(gameObject);
  19.         }
  20.         else
  21.         {
  22.             Instance = this;
  23.         }
  24.     }
  25.  
  26.     public int dayInGame = 1;
  27.     public TextMeshProUGUI dayUI;
  28.  
  29.     private void Start()
  30.     {
  31.         dayUI.text = $"Day {dayInGame}";
  32.     }
  33.  
  34.     public void TriggerNextDay()
  35.     {
  36.         dayInGame += 1;
  37.         dayUI.text = $"Day {dayInGame}";
  38.  
  39.         OnDayPass.Invoke();
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement