fixed time
This commit is contained in:
parent
d5102b868d
commit
731c08bb97
|
@ -267,7 +267,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &37507748
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -282,10 +282,10 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
IsOn: 0
|
||||
_turnOnTime:
|
||||
_hour: 0
|
||||
_hour: 21
|
||||
_minutes: 0
|
||||
_turnOffTime:
|
||||
_hour: 0
|
||||
_hour: 6
|
||||
_minutes: 0
|
||||
--- !u!4 &37507749
|
||||
Transform:
|
||||
|
@ -427,7 +427,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_daysUntilRelease: 20
|
||||
_secondsPerDay: 5
|
||||
_secondsPerDay: 30
|
||||
_totalTime: 0
|
||||
_sun: {fileID: 179279866}
|
||||
--- !u!4 &227416519
|
||||
|
|
|
@ -216,4 +216,22 @@ public partial class GameManager : MonoBehaviourSingleton<GameManager>
|
|||
{
|
||||
_contextBuffer.Add(context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given string from the context
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public void RemoveContext(string context)
|
||||
{
|
||||
if ( _contextBuffer.Contains(context) )
|
||||
{
|
||||
List<string> contextAsList = _contextBuffer.ToArray().ToList();
|
||||
_contextBuffer.Clear();
|
||||
contextAsList.Remove(context);
|
||||
foreach (var c in contextAsList)
|
||||
{
|
||||
_contextBuffer.Add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,11 @@ public class TimeManager : MonoBehaviourSingleton<TimeManager>
|
|||
/// </summary>
|
||||
public DateTime Deadline => _deadline;
|
||||
|
||||
/// <summary>
|
||||
/// Wie viele Sekunden ein Tag im Spiel hat
|
||||
/// </summary>
|
||||
public double SecondsPerDay => _secondsPerDay;
|
||||
|
||||
/// <summary>
|
||||
/// Gibt true zurück, wenn die Deadline verpasst wurde.
|
||||
/// </summary>
|
||||
|
|
|
@ -12,10 +12,13 @@ public class ZombieSpawner : MonoBehaviour
|
|||
[SerializeField, ShowOnly]
|
||||
private float _spawnTimer;
|
||||
|
||||
private float _secondsPerDay;
|
||||
|
||||
// Start wird aufgerufen, bevor das erste Frame gezeichnet wird
|
||||
void Start()
|
||||
{
|
||||
_spawnTimer = 60 / _spawnRate;
|
||||
_secondsPerDay = (float)TimeManager.Instance.SecondsPerDay;
|
||||
_spawnTimer = _secondsPerDay / _spawnRate;
|
||||
}
|
||||
|
||||
// Update wird einmal pro Frame aufgerufen
|
||||
|
@ -26,7 +29,27 @@ public class ZombieSpawner : MonoBehaviour
|
|||
if (_spawnTimer <= 0)
|
||||
{
|
||||
Instantiate(ZombiePrefab, transform.position, Quaternion.identity, transform);
|
||||
_spawnTimer = 60 / _spawnRate;
|
||||
_spawnTimer = _secondsPerDay / _spawnRate;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (GameManager.Instance != null)
|
||||
{
|
||||
if (GameManager.Instance.ContextBuffer != null)
|
||||
GameManager.Instance.AddContext("The Developer informs Gottfried that Zombies appeared outside so Gottfried better not leave the office");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (GameManager.Instance.ContextBuffer != null)
|
||||
GameManager.Instance.RemoveContext("The Developer informs Gottfried that Zombies appeared outside so Gottfried better not leave the office");
|
||||
// Destroy all children (zombies)
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
Destroy(transform.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue