_xiaofang/xiaofang/Assets/Res/gsj/gameRoomList.cs

110 lines
4.3 KiB
C#
Raw Normal View History

2024-12-20 10:10:19 +08:00
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class gameRoomList : MonoBehaviour
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
public Dictionary<string, string> CreateHeaders()
{
if (GlobalData.ServerData == null)
{
Debug.LogError("ServerData is null!");
}
if (GlobalData.ServerData.data == null)
{
Debug.LogError("data is null!");
}
if (string.IsNullOrEmpty(GlobalData.ServerData.data.access_token))
{
Debug.LogError("access_token is null or empty!");
}
//Debug.Log("====5555=====" + GlobalData.ServerData.data.access_token);
return new Dictionary<string, string>
{
{ "Authorization","Bearer "+GlobalData.ServerData.data.access_token },
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
};
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
public async Task<GameRoomListResponse> getGameRoomList()
{
Debug.Log("<22><><EFBFBD><EFBFBD>====="+"{}");
string response = await web.SendRequest(web.URL + "/game/gameRoom/list", "GET","{}", CreateHeaders());
Debug.Log("<22><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>" + response);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
GameRoomListResponse GameRoomListResponse = JsonConvert.DeserializeObject<GameRoomListResponse>(response);
//Debug.Log(GameRoomListResponse.Data[0].CreateBy+"==="+ GameRoomListResponse.Data[0].PlayerList[0].ChargeAreaName+"==="+ GameRoomListResponse.Data[0].NpcList[0].AreaName);
return GameRoomListResponse;
}
}
//====================================
public class GameRoomBody
{
public string templateId;
public string reserveDate;
}
public class GameRoomListResponse : Response
{
public int Code { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string Msg { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
public List<GameRoomListData> Data { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
}
public class GameRoomListData
{
public string CreateBy { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string CreateTime { get; set; } // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
public string UpdateBy { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string UpdateTime { get; set; } // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
public string RoomId { get; set; } // <20><><EFBFBD><EFBFBD>ID
public string TemplateId { get; set; } // ģ<><C4A3>ID
public string SceneId { get; set; } // <20><><EFBFBD><EFBFBD>ID
public string SubjectId { get; set; } // <20><><EFBFBD><EFBFBD>ID
public string SceneName { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string SubjectName { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string Status { get; set; } // ״̬
public string ReserveDate { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string CompanyId { get; set; } // <20><>˾ID
public string DelFlag { get; set; } // ɾ<><C9BE><EFBFBD><EFBFBD>־
public string Remark { get; set; } // <20><>ע
public List<GameRoomListPlayer> PlayerList { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
public List<GameRoomListNPC> NpcList { get; set; } // NPC<50>б<EFBFBD>
public List<GameRoomListMaterial> MaterialList { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
}
public class GameRoomListPlayer
{
public string TemplateId { get; set; } // ģ<><C4A3>ID
public string UserId { get; set; } // <20>û<EFBFBD>ID
public int RoleId { get; set; } // <20><>ɫID
public string RoleName { get; set; } // <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
public int BirthAreaId { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
public string BirthAreaName { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int ChargeAreaId { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
public string ChargeAreaName { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int PlayerStatus { get; set; } // <20><><EFBFBD><EFBFBD>״̬
}
public class GameRoomListNPC
{
public string TemplateId { get; set; } // ģ<><C4A3>ID
public int AreaId { get; set; } // <20><><EFBFBD><EFBFBD>ID
public string AreaName { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int NpcId { get; set; } // NPC ID
public string NpcName { get; set; } // NPC <20><><EFBFBD><EFBFBD>
public int? NpcNum { get; set; } // NPC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>
}
public class GameRoomListMaterial
{
public string TemplateId { get; set; } // ģ<><C4A3>ID
public int MaterialId { get; set; } // <20><><EFBFBD><EFBFBD>ID
public string MaterialName { get; set; } // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int Num { get; set; } // <20><><EFBFBD><EFBFBD>
}