using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using Newtonsoft.Json; using UnityEngine; public class createTemplateInterface : MonoBehaviour { // 创建请求头,使用最新的 token public Dictionary CreateHeaders() { Debug.Log("====5555=====" + GlobalData.ServerData.data.access_token); return new Dictionary { { "Authorization","Bearer "+GlobalData.ServerData.data.access_token }, {"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" } }; } //新建模板 public async Task createTemplate(string reserveDate) { //===================================================================================================================================================== Debug.Log(JsonConvert.SerializeObject(createTemplateInfo.Instance.auth_CreateTemplate) + "====================="); string response = await web.SendRequest(web.URL + "/game/gameTemplate/add", "POST", JsonConvert.SerializeObject(createTemplateInfo.Instance.auth_CreateTemplate), CreateHeaders()); Debug.Log("新建模板列表" + response); // 解析服务器返回的数据 newTemplateData newTemplateData = JsonConvert.DeserializeObject(response); Debug.Log(newTemplateData.data); //======================================================================= gameRoomReserve gameRoomReserve = new gameRoomReserve(); await gameRoomReserve.scheduledDrill(reserveDate, newTemplateData.data); //====================================================================== return newTemplateData; } } //====新建模板请求体========================== public class auth_createTemplate { public string templateName;//模板名称 public string sceneId;//场景编号-----------------------------必须(没有必须就是可选) public string subjectId;//科目编号---------------------------必须 public string isTemplate;//是否保存为模板 public string mode;//模式 public List playerList;//玩家列表 public List npcList;//NPC列表 public List materialList;//设备器材列表 } public class PlayerList//玩家列表 { public string userId;//用户编号------------------------------必须 public string roleId;//角色编号------------------------------必须 public string birthAreaId;//出生区域编号---------------------必须 public string chargeAreaId;//负责区域编号--------------------必须 } public class NpcList//NPC列表 { public string npcId;//NPC编号--------------------------------必须 public string areaId;//区域编号------------------------------必须 public int npcNum;//数量--------------------------------必须 public int isHere;//是否归属 } public class MaterialList//设备器材列表 { public string materialId;//设备器材编号----------------------必须 public int num;//数量 } //===返回值====================================== public class newTemplateData : Response { public string data;//空 }