fixed time
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user