_xiaofang/xiaofang/Assets/Res/gsj/scripts/Status.cs

197 lines
5.8 KiB
C#
Raw Normal View History

2024-12-20 10:10:19 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Threading.Tasks;
using UnityEngine.SceneManagement;
public class Status : MonoBehaviour
{
private Button button;
private Text type;//<2F><><EFBFBD><EFBFBD>״̬<D7B4>ı<EFBFBD>
private GameObject three;//<2F>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
private GameObject down;
public bool isParticipate;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
public bool isEnd=false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
public bool isOngoing = false;//<2F>Ƿ<EFBFBD><C7B7>ڽ<EFBFBD><DABD><EFBFBD>
public bool isScheduled=false;//<2F>Ƿ<EFBFBD>Ԥ<EFBFBD><D4A4>
private Image pop;
private Image arrow;
private float time = 3f;
private float await = 0;
private Button Assessmentreport;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>水ť
private Button Review;//<2F><><EFBFBD>̰<EFBFBD>ť;
private Button repair;//<2F>޸<EFBFBD><DEB8><EFBFBD>ť
private Button cancelbooking;//ȡ<><C8A1>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>ť
private bool eventAdded = false; // <20><>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
public bool isadministrator;//<2F>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>Ա
public Drill drill;
private string scenename;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private string accidenttype;//<2F>¹<EFBFBD><C2B9><EFBFBD><EFBFBD><EFBFBD>
private Text text;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>ı<EFBFBD>
private Text timetext;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ı<EFBFBD>
private gameRoomList gameRoomListInstance; // <20><><EFBFBD><EFBFBD> gameRoomList <20>ű<EFBFBD>ʵ<EFBFBD><CAB5>
private List<GameRoomListData> roomDataList; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD>б<EFBFBD>
public string RoomId;
public string status;
public string TemplateId;
public string SceneId;
public string SubjectId;
// Start is called before the first frame update
void Start()
{
button=GetComponent<Button>();
button.onClick.AddListener(OnClickBtn);
type=transform.Find("up/type").GetComponent<Text>();
down = transform.Find("down").gameObject;
Assessmentreport = transform.Find("down/end/repair ").GetComponent<Button>();
Assessmentreport.gameObject.SetActive(false);
Review = transform.Find("down/end/Cancel").GetComponent<Button>();
Review.gameObject.SetActive(false);
repair = transform.Find("down/Reserve/repair ").GetComponent<Button>();
repair.gameObject.SetActive(false);
cancelbooking = transform.Find("down/Reserve/Cancel").GetComponent<Button>();
cancelbooking.gameObject.SetActive(false);
three = transform.Find("down/Schedule").gameObject;
three.SetActive(false);
pop=transform.Find("down/Schedule/pop").GetComponent<Image>();
arrow=transform.Find("down/Schedule/arrowhead ").GetComponent<Image>();
drill=GameObject.Find("Panel").GetComponent<Drill>();
drill.OnBoolAChanged += OnBoolAChanged;
text=transform.Find("down/detail").GetComponent<Text>();
timetext=transform.Find("up/date").GetComponent <Text>();
// <20><><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>е<EFBFBD> gameRoomList <20>ű<EFBFBD>ʵ<EFBFBD><CAB5>
gameRoomListInstance = FindObjectOfType<gameRoomList>();
}
public void SetRoomData(string roomId, string sceneId, string subjectId, string templateId, string statu)
{
RoomId = roomId;
SceneId = sceneId;
SubjectId = subjectId;
TemplateId = templateId;
status = statu;
}
// <20><><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>
public void PrintRoomData()
{
Debug.Log($"<22><><EFBFBD><EFBFBD>: {RoomId}, <20><><EFBFBD><EFBFBD>: {SceneId}, <20><>Ŀ: {SubjectId}, ģ<><C4A3>: {TemplateId}, ״̬: {status}");
}
void OnBoolAChanged(bool value)
{
// <20><><EFBFBD><EFBFBD> bool <20><>ֵ
isadministrator = value;
}
// Update is called once per frame
void Update()
{
if(type.text=="<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
{
isOngoing=true;
}
if (type.text == "<22>ѽ<EFBFBD><D1BD><EFBFBD>")
{
isEnd = true;
three.SetActive(false);
}
if(type.text=="<22><>Ԥ<EFBFBD><D4A4>")
{
isScheduled=true;
if(isParticipate)
{
three.SetActive(true);
await += Time.deltaTime;
if (await >= time)
{
pop.gameObject.SetActive(false);
arrow.gameObject.SetActive(false);
}
}
else
{
three.SetActive(false);
}
}
}
void OnClickBtn()
{
if(isOngoing)
{
//Reserve.SetActive(true);
Debug.Log("<22><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>");
//return;
}
if (isEnd)
{
if (isadministrator)
{
Assessmentreport.gameObject.SetActive(true);
Review.gameObject.SetActive(true);
if (!eventAdded)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//Assessmentreport.onClick.AddListener(OnClickAssessmentreport);
Review.onClick.AddListener(OnClickReviewBtn);
eventAdded = true;
}
}
}
if(isScheduled)
{
if (isadministrator)
{
repair.gameObject.SetActive(true);
cancelbooking.gameObject.SetActive(true);
if (!eventAdded)
{
repair.onClick.AddListener(OnClickrepairBtn);
cancelbooking.onClick.AddListener(OnClickCancelBtn);
eventAdded = true;
}
}
}
}
void OnClickAssessmentreport()
{
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
Game.uiManager.ShowUI<Image>("Panelreport");
UIClose();
}
void OnClickReviewBtn()
{
Debug.Log("<22><><EFBFBD><EFBFBD>");
SceneManager.LoadScene("yhj 1");
}
void OnClickrepairBtn()
{
Debug.Log("<22>޸<EFBFBD>");
}
void OnClickCancelBtn()
{
Debug.Log(<><C8A1>Ԥ<EFBFBD><D4A4>");
}
void OnDestroy()
{
// ȡ<><C8A1><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>ڴ<EFBFBD>й©
if (drill != null)
{
drill.OnBoolAChanged -= OnBoolAChanged;
}
}
async void UIClose()
{
await Task.Delay(3000);
Game.uiManager.CloseUI("Panelreport");
}
}