Zombie-Zwischencommit
This commit is contained in:
@ -8,17 +8,17 @@ public class ZombieSpawner : MonoBehaviour
|
||||
[SerializeField]
|
||||
GameObject ZombiePrefab;
|
||||
[SerializeField]
|
||||
private float _spawnRate = 1.0f;
|
||||
private float _spawnRate = 2.0f;
|
||||
[SerializeField, ShowOnly]
|
||||
private float _spawnTimer;
|
||||
|
||||
private float _secondsPerDay;
|
||||
private float _secondsPerAliveTime;
|
||||
|
||||
// Start wird aufgerufen, bevor das erste Frame gezeichnet wird
|
||||
void Start()
|
||||
{
|
||||
_secondsPerDay = (float)TimeManager.Instance.SecondsPerDay;
|
||||
_spawnTimer = _secondsPerDay / _spawnRate;
|
||||
_secondsPerAliveTime = GetComponentInParent<Zeitschaltuhr>().ActiveTimeSpanInSeconds;
|
||||
_spawnTimer = Random.Range(0.5f * _secondsPerAliveTime / _spawnRate, _secondsPerAliveTime / _spawnRate);
|
||||
}
|
||||
|
||||
// Update wird einmal pro Frame aufgerufen
|
||||
@ -29,7 +29,7 @@ public class ZombieSpawner : MonoBehaviour
|
||||
if (_spawnTimer <= 0)
|
||||
{
|
||||
Instantiate(ZombiePrefab, transform.position, Quaternion.identity, transform);
|
||||
_spawnTimer = _secondsPerDay / _spawnRate;
|
||||
_spawnTimer = _secondsPerAliveTime / _spawnRate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,12 @@ public class ZombieSpawner : MonoBehaviour
|
||||
// Destroy all children (zombies)
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
Destroy(transform.GetChild(i).gameObject);
|
||||
KillZombiesByDisable();
|
||||
}
|
||||
}
|
||||
|
||||
private void KillZombiesByDisable()
|
||||
{
|
||||
Destroy(transform.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user