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

118 lines
3.8 KiB
C#
Raw Normal View History

2024-12-25 22:10:20 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ReadRoom : MonoBehaviour
{
public static ReadRoom instance;
public gameRoomList gameRoomListInstance; // <20><><EFBFBD><EFBFBD> gameRoomList <20>ű<EFBFBD>ʵ<EFBFBD><CAB5>
public GameRoomListResponse gameRoomListResponse;
private List<GameRoomListData> roomDataList;
public JSONReader js;
2024-12-26 03:46:07 +08:00
public bool isenter=false;//<2F><><EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>
2024-12-27 16:29:07 +08:00
public bool isadministrator = false;//<2F>Ƿ<EFBFBD><C7B7>ǹ<EFBFBD><C7B9><EFBFBD>Ա
private bool isStartRoom = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ
2024-12-25 22:10:20 +08:00
// Start is called before the first frame update
void Start()
{
instance = this;
gameRoomListInstance = FindObjectOfType<gameRoomList>();
}
2024-12-27 16:29:07 +08:00
void OnEnable()
{
// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
Starthost.OnBoolStart += HandleRoomControl;
}
void OnDisable()
{
// ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
Starthost.OnBoolStart -= HandleRoomControl;
}
2024-12-25 22:10:20 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӽ<EFBFBD><D3BD>뷿<EFBFBD><EBB7BF>Ҫ<EFBFBD><D2AA>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public async void head()
{
var response = await gameRoomListInstance.getGameRoomList();
if (response != null && response.Data != null)
{
2024-12-27 16:29:07 +08:00
if(GlobalData.ServerData.data.isCreater == "Y")
{
SceneManager.LoadScene("yhj");
isadministrator=true;
}
2024-12-25 22:10:20 +08:00
roomDataList = response.Data;
Debug.Log($"<22><>ȡ<EFBFBD><C8A1><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{roomDataList.Count}");
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
DateTime currentDate = DateTime.Now;
//<2F><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ڸ<EFBFBD>ʽ<EFBFBD><CABD>Ϊ "yyyy/MM/dd" <20><>ʽ
string formattedDate = currentDate.ToString("yyyy/MM/dd");
2024-12-26 22:26:18 +08:00
2024-12-25 22:10:20 +08:00
// <20><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>Ԫ<EFBFBD><D4AA>
foreach (var room in roomDataList)
{
2024-12-27 16:29:07 +08:00
if (room.Status == "1"||room.Status=="0")
2024-12-25 22:10:20 +08:00
{
2024-12-26 22:26:18 +08:00
bool found = false; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD> ID
2024-12-27 16:29:07 +08:00
if (!isStartRoom)
2024-12-26 22:26:18 +08:00
{
2024-12-27 16:29:07 +08:00
for (int i = 0; i < room.PlayerList.Count; i++)
2024-12-26 22:26:18 +08:00
{
2024-12-27 16:29:07 +08:00
if ((GlobalData.ServerData.data.userId == room.PlayerList[i].UserId))// && ("2024/12/20" == room.ReserveDate))
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְҵID
//Player.CSZS.SetPlayerID(room.PlayerList[i].RoleId);
Debug.Log("<22><><EFBFBD><EFBFBD>ֱ<EFBFBD>ӽ<EFBFBD><D3BD>뷿<EFBFBD><EBB7BF>");
SceneManager.LoadScene("Tmap 1");
isenter = true;
found = true; // <20>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>û<EFBFBD> ID
break; // ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
}
2024-12-26 22:26:18 +08:00
}
}
2024-12-27 16:29:07 +08:00
else
{
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>˿<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>,<2C><>û<EFBFBD>н<EFBFBD><D0BD><EFBFBD><EBB3A1><><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
SceneManager.LoadScene("yhj");
break;
}
2024-12-26 22:26:18 +08:00
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD> ID<49><44><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> "yhj" <20><><EFBFBD><EFBFBD>
if (!found)
2024-12-25 22:10:20 +08:00
{
2024-12-26 22:26:18 +08:00
Debug.Log(<>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>û<EFBFBD> ID<49><44><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 'yhj'");
SceneManager.LoadScene("yhj");
2024-12-27 16:29:07 +08:00
break;
2024-12-25 22:10:20 +08:00
}
2024-12-27 16:29:07 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ƥ<EFBFBD>䷿<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD>Ҫ<EFBFBD>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (found) break;
2024-12-26 22:26:18 +08:00
}
else
{
Debug.Log("״̬<D7B4><CCAC><EFBFBD><EFBFBD> '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'<27><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 'yhj'");
SceneManager.LoadScene("yhj");
2024-12-27 16:29:07 +08:00
break;
2024-12-25 22:10:20 +08:00
}
}
2024-12-26 22:26:18 +08:00
2024-12-25 22:10:20 +08:00
}
else
{
Debug.LogError("<22><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>");
}
}
// Update is called once per frame
void Update()
{
}
2024-12-27 16:29:07 +08:00
void HandleRoomControl(bool isStart)
{
isStartRoom = isStart;
}
2024-12-25 22:10:20 +08:00
}