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

50 lines
1.5 KiB
C#
Raw Normal View History

2024-11-30 10:23:05 +08:00
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class bindNPC : MonoBehaviour
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
public Dictionary<string, string> CreateHeaders()
{
2024-12-04 15:26:46 +08:00
if (string.IsNullOrEmpty(MyGlobal.global.loginResponse.data.access_token))
2024-11-30 10:23:05 +08:00
{
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>
{
2024-12-04 15:26:46 +08:00
{ "Authorization","Bearer "+MyGlobal.global.loginResponse.data.access_token },
2024-11-30 10:23:05 +08:00
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
};
}
//ģ<><C4A3>NPC<50><43><EFBFBD><EFBFBD>
public async Task<BindNPC> BindNPC(BindNPCBody _bindNPCBody)
{
//BindNPCBody bindNPCBody = new BindNPCBody();
//bindNPCBody = _bindNPCBody;
string response = await web.SendRequest(web.URL + "/game/gameTemplate/npc", "POST", JsonConvert.SerializeObject(_bindNPCBody), CreateHeaders());
Debug.Log(<><C4A3>NPC<50><43><EFBFBD><EFBFBD>: " + response);
BindNPC serverData = JsonConvert.DeserializeObject<BindNPC>(response);
return serverData;
}
}
//=========<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>===================================================================
public class BindNPCBody
{
string templateId;//===============<3D><><EFBFBD><EFBFBD>
NpcList[] npcList;//<2F><>createTemplate.cs<63><73>37<33><37>//=========<3D><><EFBFBD><EFBFBD>
}
//==========<3D><><EFBFBD><EFBFBD>=============================
public class BindNPC : Response
{
public string data;//++++++++++++++++++++++++++++++++++++
}