1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Conversation_Trigger_Script : MonoBehaviour
- {
- private AudioSource audioPlayer;
- private Queue<Conversation_Line> lines = new Queue<Conversation_Line>();
- private bool triggered;
- void Start() {
- audioPlayer = gameObject.AddComponent<AudioSource>();
- foreach (Conversation_Line line in GetComponents<Conversation_Line>()) {
- 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;
- }
- }
- }
|