56 lines
964 B
C#
56 lines
964 B
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class TimeManager : MonoBehaviour
|
|
{
|
|
#region Statication
|
|
|
|
public static TimeManager instance;
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance != null && instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
DontDestroyOnLoad(this);
|
|
instance = this;
|
|
}
|
|
|
|
#endregion
|
|
|
|
public Player player;
|
|
[Header("Time")]
|
|
public int currentDay;
|
|
public int currentTime; //measured in minutes
|
|
[Header("UI")]
|
|
public TextMeshProUGUI timeUI; //i might have to move the main ui off to a different scene?
|
|
|
|
private void Start()
|
|
{
|
|
UpdateTimeUI();
|
|
}
|
|
|
|
public void PassTime(int minutes)
|
|
{
|
|
currentTime += minutes;
|
|
UpdateTimeUI();
|
|
}
|
|
|
|
public void EndDay()
|
|
{
|
|
//full heal player
|
|
//reset gathering spots
|
|
currentDay++;
|
|
currentTime = 360;
|
|
UpdateTimeUI();
|
|
}
|
|
|
|
private void UpdateTimeUI()
|
|
{
|
|
string convertedTime = $"{TimeSpan.FromMinutes(currentTime):hh\\:mm}";
|
|
timeUI.text = $"Time: {convertedTime}";
|
|
}
|
|
}
|