2024-11-29 20:06:53 +08:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class getRoleList : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
|
2024-12-20 14:38:57 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
|
2024-11-29 20:06:53 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
|
|
|
|
|
public Dictionary<string, string> CreateHeaders()
|
|
|
|
|
{
|
|
|
|
|
|
2024-12-20 14:38:57 +08:00
|
|
|
|
Debug.Log("====5555=====" + GlobalData.ServerData.data.access_token);
|
2024-11-29 20:06:53 +08:00
|
|
|
|
return new Dictionary<string, string>
|
|
|
|
|
{
|
2024-12-20 14:38:57 +08:00
|
|
|
|
{ "Authorization","Bearer "+GlobalData.ServerData.data.access_token },
|
2024-11-29 20:06:53 +08:00
|
|
|
|
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ɫ<EFBFBD>б<EFBFBD>
|
|
|
|
|
public async void queryRoleList(string secneId)
|
|
|
|
|
{
|
2024-12-20 14:38:57 +08:00
|
|
|
|
//getRoleListBody getRoleListBody = new getRoleListBody();
|
|
|
|
|
//getRoleListBody.sceneId = secneId;//==============================================================================
|
|
|
|
|
string response = await web.SendRequest(web.URL + "/game/role/list?sceneId=" + secneId, "GET","{}", CreateHeaders());
|
2024-11-29 20:06:53 +08:00
|
|
|
|
Debug.Log("<22><>ѯ<EFBFBD><D1AF>ɫ<EFBFBD>б<EFBFBD>: " + response);
|
|
|
|
|
RoleList serverData = JsonConvert.DeserializeObject<RoleList>(response);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>鷴<EFBFBD><E9B7B4><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (serverData == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("Failed to deserialize JSON. RoleList is null.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (serverData.data == null || serverData.data.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning("No role data found in the returned data.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD>Ľ<EFBFBD>ɫ<EFBFBD>б<EFBFBD>
|
|
|
|
|
foreach (var role in serverData.data)
|
|
|
|
|
{
|
|
|
|
|
//Debug.Log("Role ID: " + role.id);
|
|
|
|
|
//Debug.Log("Role Name: " + role.roleName);
|
|
|
|
|
//Debug.Log("Scene ID: " + role.sceneId);
|
|
|
|
|
//Debug.Log("Game Name: " + role.gameName);
|
|
|
|
|
//Debug.Log("Role Attributions: " + role.roleAttributions);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//====<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>==========================================================================================
|
|
|
|
|
public class getRoleListBody
|
|
|
|
|
{
|
|
|
|
|
public string sceneId;//=====<3D><><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
//====<3D><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>==========================================================================================
|
|
|
|
|
public class RoleList
|
|
|
|
|
{
|
|
|
|
|
public int code; // <20><> JSON <20>е<EFBFBD> "code" <20>ֶζ<D6B6>Ӧ
|
|
|
|
|
public string msg; // <20><> JSON <20>е<EFBFBD> "msg" <20>ֶζ<D6B6>Ӧ
|
|
|
|
|
public List<RoleData> data; // <20><> JSON <20>е<EFBFBD> "data" <20>ֶζ<D6B6>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>б<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class RoleData
|
|
|
|
|
{
|
|
|
|
|
public string id; // <20><> JSON <20>е<EFBFBD> "id" <20>ֶζ<D6B6>Ӧ
|
|
|
|
|
public string roleName; // <20><> JSON <20>е<EFBFBD> "roleName" <20>ֶζ<D6B6>Ӧ
|
|
|
|
|
public string sceneId; // <20><> JSON <20>е<EFBFBD> "sceneId" <20>ֶζ<D6B6>Ӧ
|
|
|
|
|
public int gameName; // <20><> JSON <20>е<EFBFBD> "gameName" <20>ֶζ<D6B6>Ӧ<EFBFBD><D3A6>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> int <20><><EFBFBD><EFBFBD>
|
|
|
|
|
public string roleAttributions; // <20><> JSON <20>е<EFBFBD> "roleAttributions" <20>ֶζ<D6B6>Ӧ
|
|
|
|
|
}
|