2024-11-29 20:06:53 +08:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2024-11-30 10:23:05 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2024-11-29 20:06:53 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class bindPlayer : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
|
|
|
|
|
public Dictionary<string, string> CreateHeaders()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(Global.global.loginResponse.data.access_token))
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning("<22><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷʱ<CDB7><CAB1>token δ<><CEB4><EFBFBD>á<EFBFBD>");
|
|
|
|
|
return new Dictionary<string, string>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "Authorization","Bearer "+Global.global.loginResponse.data.access_token },
|
|
|
|
|
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD><D2B0><EFBFBD>
|
2024-11-30 10:23:05 +08:00
|
|
|
|
public async Task<BindPlayer> BindPlayer(bindPlayerBody bindPlayerBody)
|
2024-11-29 20:06:53 +08:00
|
|
|
|
{
|
2024-11-30 10:23:05 +08:00
|
|
|
|
//bindPlayerBody bindPlayerBody1 = new bindPlayerBody();
|
|
|
|
|
//bindPlayerBody1 = bindPlayerBody;
|
2024-11-29 20:06:53 +08:00
|
|
|
|
|
2024-11-30 10:23:05 +08:00
|
|
|
|
string response = await web.SendRequest(web.URL + "/game/gameTemplate/player", "POST", JsonConvert.SerializeObject(bindPlayerBody), CreateHeaders());
|
2024-11-29 20:06:53 +08:00
|
|
|
|
Debug.Log("ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD><D2B0><EFBFBD>: " + response);
|
|
|
|
|
BindPlayer serverData = JsonConvert.DeserializeObject<BindPlayer>(response);
|
2024-11-30 10:23:05 +08:00
|
|
|
|
return serverData;
|
2024-11-29 20:06:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//=====<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>====================================================================================
|
|
|
|
|
public class bindPlayerBody
|
|
|
|
|
{
|
|
|
|
|
string templateId;//===============<3D><><EFBFBD><EFBFBD>
|
|
|
|
|
PlayerList[] playerList;//<2F><>createTemplate.cs<63><73>37<33><37>//=========<3D><><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
2024-11-30 10:23:05 +08:00
|
|
|
|
//===============================================================================================
|
|
|
|
|
public class BindPlayer : Response
|
|
|
|
|
{
|
|
|
|
|
public string data;
|
|
|
|
|
}
|