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

63 lines
2.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
using UnityEngine;
public class createTemplateInterface : MonoBehaviour
{
//新建模板
public async Task<newTemplateData> createTemplate()
{
auth_createTemplate CreateTemplateBody = new auth_createTemplate();
CreateTemplateBody.templateName="模板名称";
string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(CreateTemplateBody));
//string body = "{\"templateName\": \"11111\",\"sceneId\": \"11111\",\"subjectId\": \"111\",\"isTemplate\": \"111\",\"mode\": \"111\",\"playerList\": [{\"userId\": \"111\",\"roleId\": \"1111\",\"birthAreaId\": \"111\",\"chargeAreaId\": \"111\"}],\"npcList\": [{\"npcId\": \"111\",\"areaId\": \"111\",\"npcNum\": 0}],\"materialList\": [{\"materialId\": \"111\",\"num\": 0}]}";
//string response = await web.SendRequest(web.URL + "/game/gameTemplate/add", "POST", body, CreateHeaders());
Debug.Log("新建模板列表" + response);
// 解析服务器返回的数据
newTemplateData newTemplateData = JsonConvert.DeserializeObject<newTemplateData>(response);
Debug.Log(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> playerList;//玩家列表
public List<NpcList> npcList;//NPC列表
public List<MaterialList> materialList;//设备器材列表
}
public class PlayerList//玩家列表
{
public string userId;//用户编号------------------------------必须
public string roleId;//角色编号------------------------------必须
public string birthAreaId;//出生区域编号---------------------必须
public string chargeAreaId;//负责区域编号--------------------必须
}
public class NpcList//NPC列表
{
public string userId;//NPC编号-------------------------------必须
public string roleId;//区域编号------------------------------必须
public int birthAreaId;//数量--------------------------------必须
}
public class MaterialList//设备器材列表
{
public string materialId;//设备器材编号----------------------必须
public int num;//数量
}
//===返回值======================================
public class newTemplateData : Response
{
public string data;//空
}