_xiaofang/xiaofang/Assets/Script/DirllInterface/bindPlayer.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2024-11-29 20:06:53 +08:00
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
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>
public async void BindPlayer(bindPlayerBody bindPlayerBody)
{
bindPlayerBody bindPlayerBody1 = new bindPlayerBody();
bindPlayerBody1 = bindPlayerBody;
string response = await web.SendRequest(web.URL + "/game/gameTemplate/player", "POST", JsonConvert.SerializeObject(bindPlayerBody1), CreateHeaders());
Debug.Log(<><C4A3><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD><D2B0><EFBFBD>: " + response);
BindPlayer serverData = JsonConvert.DeserializeObject<BindPlayer>(response);
}
}
//=====<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>
}