Adjusted door timetables, added clock and wall trashcan
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class ClockManager : MonoBehaviour
|
||||
{
|
||||
public Clock[] clocks;
|
||||
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(UpdateClocks());
|
||||
}
|
||||
|
||||
IEnumerator UpdateClocks()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// Read the computer's local time.
|
||||
DateTime now = DateTime.Now;
|
||||
|
||||
// Synchronize every clock.
|
||||
foreach (Clock clock in clocks)
|
||||
{
|
||||
if (clock != null)
|
||||
{
|
||||
clock.SetTime(now);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait until approximately the next minute.
|
||||
now = DateTime.Now;
|
||||
float waitTime =
|
||||
60f - now.Second - now.Millisecond / 1000f;
|
||||
|
||||
yield return new WaitForSecondsRealtime(waitTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user