using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System.Threading.Tasks; using UnityEngine.SceneManagement; using Unity.VisualScripting; using System.Runtime.CompilerServices; public class Starthost : MonoBehaviour { // 定义委托事件 public delegate void BoolValueChanged(bool newValue); public static event BoolValueChanged OnBoolValueChanged; //定义委托事件是否开始 public delegate void BoolIsStart(bool newValue); public static event BoolIsStart OnBoolStart; private bool isRotating = false; // 默认旋转状态 private GameObject panel; private Button posiBtn;//人员到位情况按钮 private Button start;//开始演练按钮 public bool isReady;//在线玩家是否准备 public bool isSatisfy;//人员是否满足 public bool isStart=false;//演习是否开始 private GameObject time;//计时 private Text timeText;//计时时间 private bool isTimerRunning=false;//是否开始计时 private float timer = 0f; public float moveDuration = 2f; // 移动时间 public float scaleDuration = 2f; // 缩放时间 private RectTransform rectTransform; private Canvas canvas; private Panel2 GetPanel2; public Alertwindow alertwindow; private bool isButtonClicked = false; // 监听的变量 private GameObject peopleposition;//人员的位置信息 //非主持人的画面 public bool ishost=false; public Button ready; private Image image; //语音内容 public GameObject walkieTalkieIcon; // 对讲机图标(动态效果) public Text dialogueText; // 显示语音内容的文本框 private AudioSource audioSource; // 用于播放语音的 AudioSource public AudioClip staticNoiseClip; // 对讲机噪音音效 public AudioClip[] voiceClips; // 语音音频数组 public string[] dialogueLines; // 对应的语音内容 public float textSpeed = 0.1f; // 逐字显示的速度(每个字的间隔时间) private int currentLineIndex = 0; // 当前语音和文本索引 private GameObject right;//右边图标 private void Awake() { DontDestroyOnLoad(this.gameObject); } void Start() { audioSource= GetComponent(); // 确保对讲机图标默认隐藏 walkieTalkieIcon.SetActive(false); ishost = ReadRoom.instance.isenter; right =transform.Find("Panel1/right").gameObject; panel = transform.Find("Panel1").gameObject; posiBtn = transform.Find("Panel1/right/under/btnRenYuanDaoWei").GetComponent