Blub Mate auf dem Markt jetzt! Kaufen Sie jetzt - Blub Mate! Nur heute, ganz frisch!
This commit is contained in:
@ -45,7 +45,7 @@ public class DeveloperNeeds : MonoBehaviour
|
||||
break;
|
||||
case "mate":
|
||||
spawnedNeed = Instantiate(Needs[1], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
|
||||
context = "The NPC wants a Club Mate";
|
||||
context = "The NPC wants a Blub Mate (Yes, its a drink called Blub Mate)";
|
||||
break;
|
||||
case "toilet":
|
||||
spawnedNeed = Instantiate(Needs[2], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
|
||||
|
||||
97
3d Prototyp/Assets/Scripts/Zeitschaltuhr.cs
Normal file
97
3d Prototyp/Assets/Scripts/Zeitschaltuhr.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Macht genau das was man erwartet: Schaltet je nach Uhrzeit alle Kinder an oder aus.
|
||||
/// </summary>
|
||||
public class Zeitschaltuhr : MonoBehaviour, ISerializationCallbackReceiver
|
||||
{
|
||||
private TimeSpan _turnOnTimeSpan;
|
||||
private TimeSpan _turnOffTimeSpan;
|
||||
|
||||
public bool IsOn;
|
||||
|
||||
[SerializeField] private SimpleTime _turnOnTime;
|
||||
[SerializeField] private SimpleTime _turnOffTime;
|
||||
|
||||
public SimpleTime TurnOnTime
|
||||
{
|
||||
get => _turnOnTime;
|
||||
set
|
||||
{
|
||||
_turnOnTime = value;
|
||||
_turnOnTimeSpan = _turnOnTime.ToTimeSpan();
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleTime TurnOffTime
|
||||
{
|
||||
get => _turnOffTime;
|
||||
set
|
||||
{
|
||||
_turnOffTime = value;
|
||||
_turnOffTimeSpan = _turnOffTime.ToTimeSpan();
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
UpdateOn();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
UpdateOn();
|
||||
}
|
||||
|
||||
void UpdateOn()
|
||||
{
|
||||
if (_turnOnTimeSpan < _turnOffTimeSpan)
|
||||
{
|
||||
// beide Zeiten am selben Tag
|
||||
|
||||
bool wasOn = IsOn;
|
||||
|
||||
IsOn = TimeManager.Instance.TimeOfDay.IsBetween(_turnOnTimeSpan, _turnOffTimeSpan);
|
||||
|
||||
if (IsOn != wasOn)
|
||||
{
|
||||
UpdateChildren();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Zeiten über Mitternacht
|
||||
|
||||
bool wasOn = IsOn;
|
||||
|
||||
IsOn = !TimeManager.Instance.TimeOfDay.IsBetween(_turnOffTimeSpan, _turnOnTimeSpan);
|
||||
|
||||
if (IsOn != wasOn)
|
||||
{
|
||||
UpdateChildren();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateChildren()
|
||||
{
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
transform.GetChild(i).gameObject.SetActive(IsOn);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
_turnOnTimeSpan = _turnOnTime.ToTimeSpan();
|
||||
_turnOffTimeSpan = _turnOffTime.ToTimeSpan();
|
||||
}
|
||||
}
|
||||
11
3d Prototyp/Assets/Scripts/Zeitschaltuhr.cs.meta
Normal file
11
3d Prototyp/Assets/Scripts/Zeitschaltuhr.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1627adb53b4429346a7b0a984867d9d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user