mirror of
https://github.com/DerTyp7/example-top-down-unity.git
synced 2025-10-30 04:47:09 +01:00
added TimeSystem
This commit is contained in:
26
Assets/Scripts/TimeManager.cs
Normal file
26
Assets/Scripts/TimeManager.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class TimeManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
float intervalTime = 1.0f; // 1.0f -> 1 real second is 1 ingame minute
|
||||
|
||||
[SerializeField]
|
||||
int minutesPerInterval = 1;
|
||||
|
||||
DateTime dateTime = new DateTime(1, 1, 1, 0, 0, 0);
|
||||
|
||||
public string GetTime() => dateTime.ToString("hh:mm tt");
|
||||
public string GetDate() => dateTime.ToString("dd/mm/yyyy");
|
||||
|
||||
void Start()
|
||||
{
|
||||
InvokeRepeating("TimeUp", intervalTime, intervalTime);
|
||||
}
|
||||
|
||||
void TimeUp()
|
||||
{
|
||||
dateTime = dateTime.AddMinutes(minutesPerInterval);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TimeManager.cs.meta
Normal file
11
Assets/Scripts/TimeManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d46ba76ed78c6c41805320f865295d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user