using System.Collections; using System.Collections.Generic; using UnityEngine; public class Conversation_Trigger_Script : MonoBehaviour { private AudioSource audioPlayer; private Queue lines = new Queue(); private bool triggered; void Start() { audioPlayer = gameObject.AddComponent(); foreach (Conversation_Line line in GetComponents()) { lines.Enqueue(line); } } void Update() { if (triggered) { if (lines.Count > 0) { Static_GlobalStats.paused = true; if (!audioPlayer.isPlaying) { Conversation_Line line = lines.Dequeue(); audioPlayer.clip = line.clip; audioPlayer.Play(); if (line.bauteil) { Static_GlobalStats.bauteileLevel++; } } } else if (!audioPlayer.isPlaying) { Static_GlobalStats.paused = false; Destroy(gameObject); } } } void OnTriggerEnter2D(Collider2D col) { if (!triggered && col && col.gameObject && col.gameObject.tag == "Player") { triggered = true; } } }