1118OPSSNew/Assets/Zion/Scripts/UI/Item/RoomItem.cs

95 lines
2.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DataModel.Model;
using System.Net.Sockets;
using System.Net;
using System;
using System.Text;
public class RoomItem : MonoBehaviour
{
public Text roomName;
public Button lookBtn;
public Button qidongBtn;
public Button closeBtn;
//HQB 20250917 去掉practice
//practice practice1;
public void Init( )
{
//HQB 20250917
//practice1 = practice;
//roomName.text = practice.Name;
//if(practice.State==0)
//{
// //未启动
// lookBtn.gameObject.SetActive(false);
// //qidongBtn.gameObject.SetActive(true);
// //closeBtn.gameObject.SetActive(false);
//}
//else if(practice.State==1)
//{
// //进行中
// lookBtn.gameObject.SetActive(true);
// //qidongBtn.gameObject.SetActive(false);
// //closeBtn.gameObject.SetActive(true);
//}
//不显示按钮
qidongBtn.gameObject.SetActive(true);
//closeBtn.gameObject.SetActive(false);
//lookBtn.onClick.AddListener(()=>
//{
// //查看界面
// GameObject obj = Instantiate<GameObject>(RoomListPanel.instance.CheckPanelPrefb,RoomListPanel.instance.canvas.transform);
// obj.GetComponent<CheckPanel>().Init(practice1);
//});
qidongBtn.onClick.AddListener(() =>
{
//启动 HQB 20250917
//qidongBtn.interactable = false;
//Invoke("ReSetBtn", 3);
//byte[] tmps = Encoding.UTF8.GetBytes(practice1.Id);
//byte[] tmpbytes = new byte[8 + tmps.Length];
//Array.Copy(BitConverter.GetBytes(10), 0, tmpbytes, 0, 4);
//Array.Copy(BitConverter.GetBytes(tmps.Length), 0, tmpbytes, 4, 4);
//Array.Copy(tmps, 0, tmpbytes, 8, tmps.Length);
//LoadManage.Instance.UdpSend(tmpbytes, new IPEndPoint(IPAddress.Parse(MyNetMQClient.SyncServerIP.Split(':')[0]), int.Parse(MyNetMQClient.SyncServerIP.Split(':')[1])));
UnityEngine.SceneManagement.SceneManager.LoadScene("GameSencePC");
});
closeBtn.onClick.AddListener(() =>
{
//关闭
closeBtn.interactable = false;
Invoke("ResetCloseBtn", 3);
});
}
public void ReSetBtn()
{
if (qidongBtn != null)
{
qidongBtn.interactable = true;
}
}
public void ResetCloseBtn()
{
if(closeBtn!=null)
{
closeBtn.interactable = true;
}
}
}