Zombies machen jetzt Geräusche wenn sie durch Disable sterben
This commit is contained in:
@ -12,6 +12,7 @@ public partial class GameManager : MonoBehaviourSingleton<GameManager>
|
||||
[SerializeField] private Difficulty _difficulty = Difficulty.Medium;
|
||||
|
||||
public GameObject NeedFullfilledParticleEffect;
|
||||
public GameObject ZombieDeathByDisableParticleEffect;
|
||||
|
||||
[SerializeField]
|
||||
private Character _player;
|
||||
|
||||
@ -166,7 +166,7 @@ public class Text2Speech : MonoBehaviour
|
||||
|
||||
IEnumerator GenerateAndSynthesizeText(string context)
|
||||
{
|
||||
var generateTextTask = GenerateText(context);
|
||||
var generateTextTask = GenerateTextAsync(context);
|
||||
|
||||
yield return new WaitUntil(() => generateTextTask.IsCompleted);
|
||||
|
||||
@ -181,7 +181,7 @@ public class Text2Speech : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
async Task<string> GenerateText(string context)
|
||||
async Task<string> GenerateTextAsync(string context)
|
||||
{
|
||||
Model model = Model.ChatGPTTurbo;
|
||||
|
||||
|
||||
@ -5,6 +5,10 @@ using Utility;
|
||||
|
||||
public class ZombieSpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
List<Transform> SpawnPoints;
|
||||
[SerializeField]
|
||||
List<AudioClip> ZombieDeathByDisableSoundeffects;
|
||||
[SerializeField]
|
||||
GameObject ZombiePrefab;
|
||||
[SerializeField]
|
||||
@ -28,7 +32,7 @@ public class ZombieSpawner : MonoBehaviour
|
||||
|
||||
if (_spawnTimer <= 0)
|
||||
{
|
||||
Instantiate(ZombiePrefab, transform.position, Quaternion.identity, transform);
|
||||
SpawnZombie();
|
||||
_spawnTimer = _secondsPerAliveTime / _spawnRate;
|
||||
}
|
||||
}
|
||||
@ -47,14 +51,27 @@ public class ZombieSpawner : MonoBehaviour
|
||||
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++)
|
||||
{
|
||||
KillZombiesByDisable();
|
||||
}
|
||||
KillZombiesByDisable();
|
||||
|
||||
}
|
||||
|
||||
private void SpawnZombie()
|
||||
{
|
||||
Transform pos = SpawnPoints[Random.Range(0, SpawnPoints.Count)];
|
||||
Instantiate(ZombiePrefab, pos.position, Quaternion.identity, transform);
|
||||
}
|
||||
|
||||
private void KillZombiesByDisable()
|
||||
{
|
||||
Destroy(transform.GetChild(i).gameObject);
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
GameObject zombie = transform.GetChild(i).gameObject;
|
||||
Vector3 zombiePosition = zombie.transform.position;
|
||||
Destroy(zombie);
|
||||
GameObject particleEffect = Instantiate(GameManager.Instance.ZombieDeathByDisableParticleEffect, zombiePosition, Quaternion.Euler(-90, 0, 0), GameManager.Instance.transform);
|
||||
AudioSource audio = particleEffect.GetComponent<AudioSource>();
|
||||
audio.clip = ZombieDeathByDisableSoundeffects[Random.Range(0, ZombieDeathByDisableSoundeffects.Count)];
|
||||
audio.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user