literally half of the game
This commit is contained in:
parent
1590b5faa6
commit
b842289076
77 changed files with 11904 additions and 72 deletions
56
Assets/Scripts/TimeManager.cs
Normal file
56
Assets/Scripts/TimeManager.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
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}";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue