using DG.Tweening; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class ZZUIManager : MonoBehaviour { [Header("面板")] /// /// 点击可以弹出右边框 /// public GameObject Right_Box; /// /// 总指挥框 /// public GameObject Warn_Tip; /// /// 学生疏散情况 /// public GameObject Right_Situation; /// /// 撤离方案选择框 /// public GameObject DiaLogBox; /// /// 下楼梯队形选着 /// public GameObject DiaLogBox2; /// /// 已经安全撤离框 /// public GameObject Right_Message; /// /// 为能安全撤离的框 /// public GameObject Right_Message2; /// /// 下拉框 /// public Dropdown dropdwn; /// /// 撤离方案选择 /// public ToggleGroup Tip123; /// /// 地图上的四个点 /// public GameObject MapTapPanel; /// /// 疏散提示 /// public GameObject Command02; //右边框框创建紧急任务 //创建的父对象 public GameObject content; //创建的东西 public GameObject TextPrefab; //疏散情况 //创建的任务 public GameObject content2; //创建的东西 public GameObject TextPrefab2; /// /// 三个楼梯 /// [Header("按钮")] public Button Icn_Stairway_1; public Button Icn_Stairway_2; public Button Icn_Stairway_3; /// /// 疏散顺序 /// public Button Warn; /// /// 呼出队形机 /// public Button Flee; /// /// 死亡图标的一号电梯 /// public Button Die; /// /// 电梯图标的二号电梯 /// public Button Phone; /// /// 地图F4 /// public Button TP_1; public Button TP_2; public Button TP_3; public Button TP_4; /// /// 对讲机 /// public Button Intercom; /// /// 左边的物品栏 /// public Button Prop1; public Button Prop2; public Button Prop3; /// /// 右边物品栏 /// public Button Prop4; public Button Prop5; public Button Prop6; /// /// 撤离教室方案ABC /// public Toggle DialogboxA; public Toggle DialogboxB; public Toggle DialogboxC; /// /// 撤离方案确定 /// public Button DialogboxSure; /// /// 梯队队形选择AB /// public Button Dialogbox2A; public Button Dialogbox2B; /// /// 梯队选择确定 /// public Button Dialogbox2Sure; /// /// 加减号 /// public Button Minus; public Button Plus; /// /// 上报按钮 /// public Button Sumbit; public Button Sumbit2; /// /// 确定起火点按钮 /// public Button FireButton; /// /// 右边的框 /// public Button Right_BoxButton; //两个叉叉 public Button Close1; public Button Close2; [Header("文本")] /// /// 右边框框紧急任务 /// public Text Tip_1; public Text Tip_2; public Text Tip_3; public Text Tip_4; /// /// 现场总指挥 /// public Text Head_Text; /// /// 总指挥介绍 /// public Text WarnTip_Text; /// /// 疏散情况文本 /// public Text Situation_Tip_1; public Text Situation_Tip_2; public Text Situation_Tip_3; public Text Situation_Tip_4; /// /// 撤离方案ABC /// public Text LeftText1; public Text LeftText2; public Text LeftText3; /// /// 撤离方案介绍 /// public Text RightText1; public Text RightText2; public Text RightText3; /// /// 楼梯梯队介绍 /// public Text LeftLT_Text1; public Text RightLT_Text1; /// /// 梯队介绍 /// public Text LeftLT_Text2; public Text RightLT_Text; /// /// 撤离班级 /// public Text Right_MessageText; /// /// 学生人数 /// public InputField Student_Number; /// /// 未撤离班级 /// public Text NO_Left_MessageText; public Text NO_Right_MessageText; /// /// 未撤离学生人数 /// public Text NO_Student; /// /// 时间文本 /// public Text TimeText; /// /// 道具数量左->右 /// public Text PropText1; public Text PropText2; public Text PropText3; public Text PropText4; public Text PropText5; public Text PropText6; /// /// 网络延迟 /// public Text WLYC; /// /// 标题文本 /// public Text TileText; //起火点按钮文本 public Text FireText; //计时器 private float timeElapsed = 0f; //记录 int num = 0; public Image bg; public float moveDuration = 0.5f; // 动画持续时间 public RectTransform buttonRect; // 你的按钮 RectTransform public bool isHidden=true; public float showPositionX; public float hidePositionX; public ZZUIManager instert; public void Awake() { isHidden = true; instert = this; TimeText.text = "00.00"; num = 0; } private void Start() { hidePositionX = 337f; showPositionX = 1.159973f; //右边框框弹出来 Right_BoxButton.onClick.AddListener(() => { OnClickHideButton(); }); #region 道具 Prop1.onClick.AddListener(() => { Prop(1); }); Prop2.onClick.AddListener(() => { Prop(2); }); Prop3.onClick.AddListener(() => { Prop(3); }); Prop4.onClick.AddListener(() => { Prop(4); }); Prop5.onClick.AddListener(() => { Prop(5); }); Prop6.onClick.AddListener(() => { Prop(6); }); #endregion #region 地标点击事件(地图那四个点) TP_1.onClick.AddListener(() => { MapTP(1); }); TP_2.onClick.AddListener(() => { MapTP(2); }); TP_3.onClick.AddListener(() => { MapTP(3); }); TP_4.onClick.AddListener(() => { MapTP(4); }); #endregion //关闭总指挥框 if (Warn_Tip.activeSelf&&(Input.GetMouseButtonDown(0)|| Input.GetMouseButtonDown(1)|| Input.GetMouseButtonDown(2))) { Warn_Tip.SetActive(false); } Minus.onClick.AddListener(() => { int currentValue = int.Parse(Student_Number.text); // 增加1 currentValue--; // 更新 InputField 的文本 Student_Number.text = currentValue.ToString(); }); Plus.onClick.AddListener(() => { int currentValue = int.Parse(Student_Number.text); // 增加1 currentValue++; // 更新 InputField 的文本 Student_Number.text = currentValue.ToString(); }); //打开队形 Flee.onClick.AddListener(() => { DiaLogBox2.SetActive(true); }); Close1.onClick.AddListener(() => { Close(); }); Close2.onClick.AddListener(() => { Close(); }); //下拉列表(人物选着) dropdwn.onValueChanged.AddListener(delegate { DropdownValueChanged(dropdwn); }); //默认开一次这样开局就能默认第一个选项一次 DropdownValueChanged(dropdwn); //右边框框 上报总指 (已经安全撤离的) Sumbit.onClick.AddListener(() => { SumbitButton(); }); //右边框框 上报总指 (未安全撤离的) Sumbit2.onClick.AddListener(() => { Sumbit2Button(); }); //撤离方案选择 DialogboxA.onValueChanged.AddListener(delegate { OnToggleChanged(DialogboxA); }); DialogboxB.onValueChanged.AddListener(delegate { OnToggleChanged(DialogboxB); }); DialogboxC.onValueChanged.AddListener(delegate { OnToggleChanged(DialogboxC); }); //撤离方案确定 DialogboxSure.onClick.AddListener(() => { DiaLogBox.SetActive(false); }); //梯队选择队形 Dialogbox2A.onClick.AddListener(() => { num = 1; }); Dialogbox2B.onClick.AddListener(() => { num = 2; }); //梯队队形确定 Dialogbox2Sure.onClick.AddListener(() => { if(num==1) { num = 0; DiaLogBox2.SetActive(false); } if(num==2) { num = 0; DiaLogBox2.SetActive(false); } }); FireButton.onClick.AddListener(() => { FireText.color = new Color(0.75f, 0.75f, 0.75f); }); } private void Update() { // 更新时间 timeElapsed += Time.deltaTime; // 计算分钟和秒数 int minutes = Mathf.FloorToInt(timeElapsed / 60); int seconds = Mathf.FloorToInt(timeElapsed % 60); // 格式化时间为 "00.00" 格式 TimeText.text = string.Format("{0:00}.{1:00}", minutes, seconds); } //动画部分 public void OnClickHideButton() { // 如果按钮已隐藏,点击后显示 if (isHidden) { // 恢复按钮到原位置 buttonRect.DOAnchorPosX(showPositionX, moveDuration).SetEase(Ease.InOutCubic); bg.transform.Rotate(0, 0,180f); isHidden = false; // 更新状态为未隐藏 } else { // 隐藏按钮 buttonRect.DOAnchorPosX(hidePositionX, moveDuration).SetEase(Ease.InOutCubic); bg.transform.Rotate(0, 0,180f); isHidden = true; // 更新状态为隐藏 } } /// /// 道具需要执行的 /// /// 从左->右 public void Prop(int a) { switch (a) { case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; } } /// /// 地图地点 /// /// 1-操场 2-教室 3-厨房 4-楼道 public void MapTP(int a) { switch(a) { case 1: FireText.color = new Color(1f, 1f, 1f); TileText.text = "请选择无法用于疏散的楼道"; break; case 2: FireText.color = new Color(1f, 1f, 1f); TileText.text = "请选择无法用于疏散的楼道"; break; case 3: FireText.color = new Color(1f, 1f, 1f); TileText.text = "请选择无法用于疏散的楼道"; break; case 4: FireText.color = new Color(1f, 1f, 1f); TileText.text = "请选择无法用于疏散的楼道"; break; } } /// /// 下拉列表执行的事件 /// /// void DropdownValueChanged(Dropdown change) { int index = change.value; switch (index) { case 0: // 执行 Option 1 相关的事件 Debug.Log("Option 1 selected"); break; case 1: // 执行 Option 2 相关的事件 Debug.Log("Option 2 selected"); break; case 2: // 执行 Option 3 相关的事件 Debug.Log("Option 3 selected"); break; case 3: break; case 4: break; case 5: break; } } /// /// 修改右边框框内容 /// /// 内容 /// 从上到下 public void FixWarn(string str,int a) { switch (a) { case 1: break; case 2: break; case 3: break; case 4: break; } } /// /// 修改网络延迟 /// /// 网络延迟的数字部分 public void FixDelay(string str) { WLYC.text = "网络延迟:" + str; } /// /// 修改疏散班级情况 /// /// 班级撤离情况 /// 更新第几条消息从上往下 public void FixSituation(string str,int a) { switch (a) { case 1: Situation_Tip_1.text = str; break; case 2: Situation_Tip_2.text = str; break; case 3: Situation_Tip_3.text = str; break; case 4: Situation_Tip_4.text = str; break; } } /// /// 修改成功撤离班级的信息 /// /// 撤离班级的名字 /// 人数 public void FixFledOk(string str,int a) { Right_MessageText.text = str; int currentValue = int.Parse(Student_Number.text); currentValue = a; // 更新 InputField 的文本 Student_Number.text = currentValue.ToString(); } /// /// 修改未撤离班级 /// /// 未撤离的班级 /// 未撤离的人数 public void FixNo(string str,int a) { NO_Left_MessageText.text = str; NO_Right_MessageText.text = str; NO_Student.text =a.ToString(); } /// /// 修改撤离方案的介绍 /// /// 内容 /// A=1,B=2,C=3选项 public void FixFled(string str,int a) { switch (a) { case 1: RightText1.text = str; break; case 2: RightText2.text = str; break; case 3: RightText3.text = str; break; } } /// /// 撤离方案选择 /// /// A-1 B-2 C-3 public void OnToggleChanged(Toggle changedToggle) { if (changedToggle.isOn) { if (changedToggle == DialogboxA) { Debug.Log("Toggle 1 is selected"); } else if (changedToggle == DialogboxB) { Debug.Log("Toggle 2 is selected"); } else if (changedToggle == DialogboxC) { Debug.Log("Toggle 3 is selected"); } } } /// /// 已经安全撤离的班级 上报总指 按钮事件 /// public void SumbitButton() { } /// /// 未安全撤离的班级 上报总指 按钮事件 /// public void Sumbit2Button() { } /// /// 打开关闭点火界面 /// public void FirePanel() { FireText.color = new Color(0.75f, 0.75f, 0.75f); if (MapTapPanel.activeSelf) { MapTapPanel.SetActive(false); } else { MapTapPanel.SetActive(true); } } /// /// 疏散提示 /// public void WarnPanel() { if(Command02.activeSelf) { Command02.SetActive(false); } else { Command02.SetActive(true); } } /// /// 撤离方案选着 /// public void DialogboxPanel() { if(DiaLogBox.activeSelf) { DiaLogBox.SetActive(false); } else { DiaLogBox.SetActive(true); } } /// /// 下楼梯队形选择 /// public void DialogBoxPanel2Panel() { if (DiaLogBox2.activeSelf) { DiaLogBox2.SetActive(false); } else { DiaLogBox2.SetActive(true); } } /// /// 创建紧急通告 /// /// 文本内容 public void CreateWarn(string str) { GameObject newText = Instantiate(TextPrefab); newText.transform.SetParent(content.transform, false); Text text=newText.GetComponentInChildren(); text.text = str; } /// /// 创建疏散情况内容 /// /// 文本内容 public void CreateSituation(string str) { GameObject newText = Instantiate(TextPrefab2); newText.transform.SetParent(content2.transform, false); Text text = newText.GetComponentInChildren(); text.text = str; } private void Close() { DiaLogBox2?.SetActive(false); DiaLogBox?.SetActive(false); } }