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

82 lines
2.6 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-25 22:10:20 +08:00
// Start is called before the first frame update
void Start()
{
instance = this;
gameRoomListInstance = FindObjectOfType<gameRoomList>();
}
//<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)
{
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-26 22:26:18 +08:00
if (room.Status == "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
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
for (int i = 0; i < room.PlayerList.Count; i++)
{
if ((GlobalData.ServerData.data.userId == room.PlayerList[i].UserId) && ("2024/12/20" == room.ReserveDate))
{
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>
}
}
// <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-25 22:10:20 +08:00
}
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-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()
{
}
}