解耦部分预定演练接口
This commit is contained in:
parent
1004dab9da
commit
03d13f552b
8
xiaofang/Assets/Script/DirllInterface.meta
Normal file
8
xiaofang/Assets/Script/DirllInterface.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 889b64a600f8c5a4a805956401d12ff6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
63
xiaofang/Assets/Script/DirllInterface/createTemplate.cs
Normal file
63
xiaofang/Assets/Script/DirllInterface/createTemplate.cs
Normal file
@ -0,0 +1,63 @@
|
||||
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;//空
|
||||
}
|
11
xiaofang/Assets/Script/DirllInterface/createTemplate.cs.meta
Normal file
11
xiaofang/Assets/Script/DirllInterface/createTemplate.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec15685532562834f86746af6ec16907
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
xiaofang/Assets/Script/DirllInterface/getTemplateList.cs
Normal file
43
xiaofang/Assets/Script/DirllInterface/getTemplateList.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting.Antlr3.Runtime;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEngine;
|
||||
|
||||
public class getTemplateList : MonoBehaviour
|
||||
{
|
||||
|
||||
// 创建请求头,使用最新的 token
|
||||
public Dictionary<string, string> CreateHeaders()
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(Global.global.loginResponse.data.access_token))
|
||||
{
|
||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
return new Dictionary<string, string>
|
||||
{
|
||||
{ "Authorization","Bearer "+Global.global.loginResponse.data.access_token },
|
||||
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
|
||||
};
|
||||
}
|
||||
//获取模板列表
|
||||
public async void TemplaRst()
|
||||
{
|
||||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/list", "GET", "", CreateHeaders());
|
||||
Debug.Log("获取模板列表" + response);
|
||||
//解析服务器返回的数据
|
||||
TemplateListData templateListData = JsonConvert.DeserializeObject<TemplateListData>(response);
|
||||
Debug.Log("================" + templateListData.msg);
|
||||
}
|
||||
}
|
||||
//=======================================================================================================
|
||||
public class TemplateListData : Response
|
||||
{
|
||||
public string[] data;
|
||||
}
|
||||
//=================
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebf1a137f8ff7be4ebc15918c07cf94d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
xiaofang/Assets/Script/DirllInterface/loginP.cs
Normal file
15
xiaofang/Assets/Script/DirllInterface/loginP.cs
Normal file
@ -0,0 +1,15 @@
|
||||
//using System.Collections;
|
||||
//using System.Collections.Generic;
|
||||
//using UnityEngine;
|
||||
|
||||
//public class loginP : MonoBehaviour
|
||||
//{
|
||||
|
||||
//}
|
||||
////=====되쩌헝헹竟=================================
|
||||
//public class auth_login
|
||||
//{
|
||||
// public string clientId = "e5cd7e4891bf95d1d19206ce24a7b32e";
|
||||
// public string grantType = "password";
|
||||
//}
|
||||
|
11
xiaofang/Assets/Script/DirllInterface/loginP.cs.meta
Normal file
11
xiaofang/Assets/Script/DirllInterface/loginP.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f31b06d24bd8f744a8101b6a84accf1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
104
xiaofang/Assets/Script/DirllInterface/querySenceList.cs
Normal file
104
xiaofang/Assets/Script/DirllInterface/querySenceList.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class querySenceList : MonoBehaviour
|
||||
{
|
||||
|
||||
// 创建请求头,使用最新的 token
|
||||
public Dictionary<string, string> CreateHeaders()
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(Global.global.loginResponse.data.access_token))
|
||||
{
|
||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
return new Dictionary<string, string>
|
||||
{
|
||||
{ "Authorization","Bearer "+Global.global.loginResponse.data.access_token },
|
||||
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
|
||||
};
|
||||
}
|
||||
//查询场景信息列表
|
||||
public async Task<QuerySceneData> QueryScene()
|
||||
{
|
||||
// 发送请求并获取返回数据
|
||||
string response = await web.SendRequest(web.URL + "/game/scene/list", "GET", "", CreateHeaders());
|
||||
Debug.Log("查询场景信息列表" + response);
|
||||
|
||||
// 使用Newtonsoft.Json来反序列化JSON数据到QuerySceneData对象
|
||||
QuerySceneData senceData = JsonConvert.DeserializeObject<QuerySceneData>(response);
|
||||
|
||||
// 打印整体响应数据的某些属性
|
||||
if (senceData != null && senceData.data != null)
|
||||
{
|
||||
foreach (var scene in senceData.data)
|
||||
{
|
||||
Debug.Log("场景ID: " + scene.id);
|
||||
Debug.Log("场景名称: " + scene.name);
|
||||
Debug.Log("描述: " + scene.description);
|
||||
Debug.Log("价格: " + scene.price);
|
||||
Debug.Log("行业: " + scene.industryName);
|
||||
|
||||
if (scene.fileList != null)
|
||||
{
|
||||
foreach (var file in scene.fileList)
|
||||
{
|
||||
Debug.Log("文件名称: " + file.name);
|
||||
Debug.Log("文件URL: " + file.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("解析服务器数据失败");
|
||||
}
|
||||
return senceData;
|
||||
}
|
||||
}
|
||||
//============================================================================
|
||||
// 根数据类
|
||||
public class QuerySceneData
|
||||
{
|
||||
public int code { get; set; }
|
||||
public string msg { get; set; }
|
||||
public List<Scene> data { get; set; }
|
||||
}
|
||||
|
||||
// 场景信息类
|
||||
public class Scene
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }//场景名称
|
||||
public string type { get; set; }//场景类型
|
||||
public string description { get; set; }//场景描述
|
||||
public int suitIndustry { get; set; }//适用行业
|
||||
public string price { get; set; }//价格 分
|
||||
public int companyId { get; set; }//单位(**小学之类)
|
||||
public string status { get; set; }//场景状态(0启用,1停用)
|
||||
public string delFlag { get; set; }
|
||||
public string remark { get; set; }
|
||||
public string gameName { get; set; }
|
||||
public string gameType { get; set; }
|
||||
public string ossId { get; set; }
|
||||
public List<File> fileList { get; set; }
|
||||
public string gameStoreroom { get; set; }
|
||||
public string industryName { get; set; }
|
||||
public string companyName { get; set; }
|
||||
}
|
||||
|
||||
// 文件信息类
|
||||
public class File
|
||||
{
|
||||
public string ossId { get; set; }
|
||||
public string name { get; set; }
|
||||
public string url { get; set; }
|
||||
public string originalName { get; set; }
|
||||
public string fileSuffix { get; set; }
|
||||
}
|
11
xiaofang/Assets/Script/DirllInterface/querySenceList.cs.meta
Normal file
11
xiaofang/Assets/Script/DirllInterface/querySenceList.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48ff46eafb8924748a1844646686c408
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
71
xiaofang/Assets/Script/DirllInterface/querySubjectList.cs
Normal file
71
xiaofang/Assets/Script/DirllInterface/querySubjectList.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class querySubjectList : MonoBehaviour
|
||||
{
|
||||
|
||||
// 创建请求头,使用最新的 token
|
||||
public Dictionary<string, string> CreateHeaders()
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(Global.global.loginResponse.data.access_token))
|
||||
{
|
||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
return new Dictionary<string, string>
|
||||
{
|
||||
{ "Authorization","Bearer "+Global.global.loginResponse.data.access_token },
|
||||
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
|
||||
};
|
||||
}
|
||||
//查询演练科目信息列表
|
||||
public async void QueryDrillSubject()
|
||||
{
|
||||
|
||||
|
||||
string response = await web.SendRequest(web.URL + "/game/subject/list", "GET", "", CreateHeaders());
|
||||
Debug.Log("查询演练科目信息列表: " + response);
|
||||
|
||||
// 使用 Newtonsoft.Json 进行反序列化
|
||||
DrillSubject drillSubject = JsonConvert.DeserializeObject<DrillSubject>(response);
|
||||
|
||||
// 检查反序列化结果
|
||||
if (drillSubject == null)
|
||||
{
|
||||
Debug.LogError("Failed to deserialize JSON. DrillSubject is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (drillSubject.data == null || drillSubject.data.Count == 0)
|
||||
{
|
||||
Debug.LogWarning("No subjects found in the returned data.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历反序列化后的 data 列表
|
||||
foreach (var subject in drillSubject.data)
|
||||
{
|
||||
Debug.Log("ID: " + subject.id);
|
||||
Debug.Log("Scene Names: " + subject.sceneNames);
|
||||
Debug.Log("Name: " + subject.name);
|
||||
Debug.Log("Suit Version: " + subject.suitVersion);
|
||||
Debug.Log("Type: " + subject.type);
|
||||
Debug.Log("Description: " + subject.description);
|
||||
Debug.Log("Price: " + subject.price);
|
||||
Debug.Log("Company ID: " + subject.companyId);
|
||||
Debug.Log("Status: " + subject.status);
|
||||
Debug.Log("Delete Flag: " + subject.delFlag);
|
||||
Debug.Log("Remark: " + subject.remark);
|
||||
Debug.Log("Game Name: " + subject.gameName);
|
||||
Debug.Log("OSS ID: " + subject.ossId);
|
||||
Debug.Log("File List: " + subject.fileList);
|
||||
// 如果需要进一步处理字段,可以在这里进行
|
||||
// 比如,将价格转换为数字计算,或根据特定类型执行逻辑
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f70eb725b6c69f4d87bf12740bb8fbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -6,9 +6,24 @@ using UnityEngine;
|
||||
public class Global : Singleton<Global>
|
||||
{
|
||||
public static Global global;
|
||||
public server response;
|
||||
public loginResponse loginResponse;
|
||||
|
||||
// 创建请求头,使用最新的 token
|
||||
public Dictionary<string, string> CreateHeaders()
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(Global.global.loginResponse.data.access_token))
|
||||
{
|
||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
return new Dictionary<string, string>
|
||||
{
|
||||
{ "Authorization", Global.global.loginResponse.data.access_token }
|
||||
};
|
||||
}
|
||||
//// 创建请求头,使用最新的 token
|
||||
//public Dictionary<string, string> CreateHeaders()
|
||||
//{
|
||||
@ -30,9 +45,9 @@ public class Global : Singleton<Global>
|
||||
}
|
||||
|
||||
|
||||
public class server : Response
|
||||
public class loginResponse : Response
|
||||
{
|
||||
public Data data;
|
||||
public loginData data;
|
||||
//public string access_token;
|
||||
}
|
||||
public class Response
|
||||
@ -40,7 +55,7 @@ public class Response
|
||||
public int code;
|
||||
public string msg;
|
||||
}
|
||||
public class Data
|
||||
public class loginData
|
||||
{
|
||||
public string access_token;
|
||||
public string companyId;
|
||||
@ -50,54 +65,54 @@ public class Data
|
||||
public string isCreater;//是否是模板创建者,Y是则跳蓝湖预定演练01页面开始创建模板,N否则跳蓝狐回放1页面
|
||||
}
|
||||
//====================================================
|
||||
public class TemplateListData: Response
|
||||
{
|
||||
public string[] data;
|
||||
}
|
||||
public class newTemplateData: Response
|
||||
{
|
||||
public string data;
|
||||
}
|
||||
//public class TemplateListData: Response
|
||||
//{
|
||||
// public string[] data;
|
||||
//}
|
||||
//public class newTemplateData: Response
|
||||
//{
|
||||
// public string data;
|
||||
//}
|
||||
//=============================================================
|
||||
// 根数据类
|
||||
public class QuerySceneData
|
||||
{
|
||||
public int code { get; set; }
|
||||
public string msg { get; set; }
|
||||
public List<Scene> data { get; set; }
|
||||
}
|
||||
//public class QuerySceneData
|
||||
//{
|
||||
// public int code { get; set; }
|
||||
// public string msg { get; set; }
|
||||
// public List<Scene> data { get; set; }
|
||||
//}
|
||||
|
||||
// ³¡¾°ÐÅÏ¢Àà
|
||||
public class Scene
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string type { get; set; }
|
||||
public string description { get; set; }
|
||||
public int suitIndustry { get; set; }
|
||||
public string price { get; set; }
|
||||
public int companyId { get; set; }
|
||||
public string status { get; set; }
|
||||
public string delFlag { get; set; }
|
||||
public string remark { get; set; }
|
||||
public string gameName { get; set; }
|
||||
public string gameType { get; set; }
|
||||
public string ossId { get; set; }
|
||||
public List<File> fileList { get; set; }
|
||||
public string gameStoreroom { get; set; }
|
||||
public string industryName { get; set; }
|
||||
public string companyName { get; set; }
|
||||
}
|
||||
//// 场景信息类
|
||||
//public class Scene
|
||||
//{
|
||||
// public string id { get; set; }
|
||||
// public string name { get; set; }
|
||||
// public string type { get; set; }
|
||||
// public string description { get; set; }
|
||||
// public int suitIndustry { get; set; }
|
||||
// public string price { get; set; }
|
||||
// public int companyId { get; set; }
|
||||
// public string status { get; set; }
|
||||
// public string delFlag { get; set; }
|
||||
// public string remark { get; set; }
|
||||
// public string gameName { get; set; }
|
||||
// public string gameType { get; set; }
|
||||
// public string ossId { get; set; }
|
||||
// public List<File> fileList { get; set; }
|
||||
// public string gameStoreroom { get; set; }
|
||||
// public string industryName { get; set; }
|
||||
// public string companyName { get; set; }
|
||||
//}
|
||||
|
||||
// ÎļþÐÅÏ¢Àà
|
||||
public class File
|
||||
{
|
||||
public string ossId { get; set; }
|
||||
public string name { get; set; }
|
||||
public string url { get; set; }
|
||||
public string originalName { get; set; }
|
||||
public string fileSuffix { get; set; }
|
||||
}
|
||||
//// 文件信息类
|
||||
//public class File
|
||||
//{
|
||||
// public string ossId { get; set; }
|
||||
// public string name { get; set; }
|
||||
// public string url { get; set; }
|
||||
// public string originalName { get; set; }
|
||||
// public string fileSuffix { get; set; }
|
||||
//}
|
||||
//=================================================================
|
||||
public class DrillSubject : Response
|
||||
{
|
||||
|
@ -10,37 +10,36 @@ public class auth_login
|
||||
{
|
||||
public string clientId = "e5cd7e4891bf95d1d19206ce24a7b32e";
|
||||
public string grantType = "password";
|
||||
|
||||
}
|
||||
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;
|
||||
public List<MaterialList> materialList;
|
||||
}
|
||||
public class PlayerList
|
||||
{
|
||||
public string userId;
|
||||
public string roleId;
|
||||
public string birthAreaId;
|
||||
public string chargeAreaId;
|
||||
}
|
||||
public class NpcList
|
||||
{
|
||||
public string userId;
|
||||
public string roleId;
|
||||
public int birthAreaId;
|
||||
}
|
||||
public class MaterialList
|
||||
{
|
||||
public string materialId;
|
||||
public int num;
|
||||
}
|
||||
//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;
|
||||
// public List<MaterialList> materialList;
|
||||
//}
|
||||
//public class PlayerList
|
||||
//{
|
||||
// public string userId;
|
||||
// public string roleId;
|
||||
// public string birthAreaId;
|
||||
// public string chargeAreaId;
|
||||
//}
|
||||
//public class NpcList
|
||||
//{
|
||||
// public string userId;
|
||||
// public string roleId;
|
||||
// public int birthAreaId;
|
||||
//}
|
||||
//public class MaterialList
|
||||
//{
|
||||
// public string materialId;
|
||||
// public int num;
|
||||
//}
|
||||
|
||||
|
||||
//public class TemplateList//可空
|
||||
@ -51,19 +50,18 @@ public class MaterialList
|
||||
// public string subjectId;
|
||||
// public string queryType;
|
||||
//}
|
||||
public class createTemplate
|
||||
{
|
||||
public string templateName;
|
||||
public string sceneId;
|
||||
public string subjectId;
|
||||
public string isTemplate;
|
||||
public string mode;
|
||||
}
|
||||
//public class createTemplate
|
||||
//{
|
||||
// public string templateName;
|
||||
// public string sceneId;
|
||||
// public string subjectId;
|
||||
// public string isTemplate;
|
||||
// public string mode;
|
||||
//}
|
||||
|
||||
|
||||
//============================================================================================
|
||||
public class login : MonoBehaviour
|
||||
|
||||
{
|
||||
public string token;//登录返回的token
|
||||
public Global Global;
|
||||
@ -76,7 +74,7 @@ public class login : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
if (string.IsNullOrEmpty(Global.global.loginResponse.data.access_token))
|
||||
{
|
||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||||
return new Dictionary<string, string>();
|
||||
@ -84,23 +82,23 @@ public class login : MonoBehaviour
|
||||
|
||||
return new Dictionary<string, string>
|
||||
{
|
||||
{ "Authorization","Bearer "+token },
|
||||
{"clientId", clientId }
|
||||
{ "Authorization","Bearer "+Global.global.loginResponse.data.access_token },
|
||||
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
|
||||
};
|
||||
}
|
||||
//=================================================================================================
|
||||
public async void Start()
|
||||
{
|
||||
await loging();
|
||||
SubmitTemplate();
|
||||
BindNPC();
|
||||
BindMaterial();
|
||||
BindPlayer();
|
||||
QueryDrillSubject();
|
||||
TemplateList();
|
||||
createTemplate();
|
||||
QueryScene();
|
||||
queryRoleList();
|
||||
//SubmitTemplate();
|
||||
//BindNPC();
|
||||
//BindMaterial();
|
||||
//BindPlayer();
|
||||
//QueryDrillSubject();
|
||||
//TemplateList();
|
||||
//createTemplate();
|
||||
//QueryScene();
|
||||
//queryRoleList();
|
||||
}
|
||||
//登录
|
||||
public async Task loging()
|
||||
@ -110,67 +108,73 @@ public class login : MonoBehaviour
|
||||
string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(auth_Login));
|
||||
Debug.Log("登录" + response);
|
||||
// 解析服务器返回的数据
|
||||
server serverData = JsonConvert.DeserializeObject<server>(response);
|
||||
loginResponse serverData = JsonConvert.DeserializeObject<loginResponse>(response);
|
||||
token = serverData.data.access_token;
|
||||
Debug.Log("===========" + serverData.data.isCreater);
|
||||
}
|
||||
//获取模板列表
|
||||
public async void TemplateList()
|
||||
{
|
||||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/list", "GET", "", CreateHeaders());
|
||||
Debug.Log("获取模板列表" + response);
|
||||
//解析服务器返回的数据
|
||||
TemplateListData templateListData = JsonConvert.DeserializeObject<TemplateListData>(response);
|
||||
Debug.Log("================" + templateListData.msg);
|
||||
}
|
||||
//public async void TemplaRst()
|
||||
//{
|
||||
// string response = await web.SendRequest(web.URL + "/game/gameTemplate/list", "GET", "", CreateHeaders());
|
||||
// Debug.Log("获取模板列表" + response);
|
||||
// //解析服务器返回的数据
|
||||
// TemplateListData templateListData = JsonConvert.DeserializeObject<TemplateListData>(response);
|
||||
// Debug.Log("================" + templateListData.msg);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//新建模板
|
||||
public async void createTemplate()
|
||||
{
|
||||
auth_createTemplate auth_CreateTemplate = new auth_createTemplate();
|
||||
string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(auth_CreateTemplate));
|
||||
//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);
|
||||
}
|
||||
//public async void createTemplate()
|
||||
//{
|
||||
// auth_createTemplate auth_CreateTemplate = new auth_createTemplate();
|
||||
// string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(auth_CreateTemplate));
|
||||
// //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);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//查询场景信息列表
|
||||
public async void QueryScene()
|
||||
{
|
||||
// 发送请求并获取返回数据
|
||||
string response = await web.SendRequest(web.URL + "/game/scene/list", "GET", "", CreateHeaders());
|
||||
Debug.Log("查询场景信息列表" + response);
|
||||
//public async void QueryScene()
|
||||
//{
|
||||
// // 发送请求并获取返回数据
|
||||
// string response = await web.SendRequest(web.URL + "/game/scene/list", "GET", "", CreateHeaders());
|
||||
// Debug.Log("查询场景信息列表" + response);
|
||||
|
||||
// 使用Newtonsoft.Json来反序列化JSON数据到QuerySceneData对象
|
||||
QuerySceneData serverData = JsonConvert.DeserializeObject<QuerySceneData>(response);
|
||||
// // 使用Newtonsoft.Json来反序列化JSON数据到QuerySceneData对象
|
||||
// QuerySceneData serverData = JsonConvert.DeserializeObject<QuerySceneData>(response);
|
||||
|
||||
// 打印整体响应数据的某些属性
|
||||
if (serverData != null && serverData.data != null)
|
||||
{
|
||||
foreach (var scene in serverData.data)
|
||||
{
|
||||
Debug.Log("场景ID: " + scene.id);
|
||||
Debug.Log("场景名称: " + scene.name);
|
||||
Debug.Log("描述: " + scene.description);
|
||||
Debug.Log("价格: " + scene.price);
|
||||
Debug.Log("行业: " + scene.industryName);
|
||||
// // 打印整体响应数据的某些属性
|
||||
// if (serverData != null && serverData.data != null)
|
||||
// {
|
||||
// foreach (var scene in serverData.data)
|
||||
// {
|
||||
// Debug.Log("场景ID: " + scene.id);
|
||||
// Debug.Log("场景名称: " + scene.name);
|
||||
// Debug.Log("描述: " + scene.description);
|
||||
// Debug.Log("价格: " + scene.price);
|
||||
// Debug.Log("行业: " + scene.industryName);
|
||||
|
||||
if (scene.fileList != null)
|
||||
{
|
||||
foreach (var file in scene.fileList)
|
||||
{
|
||||
Debug.Log("文件名称: " + file.name);
|
||||
Debug.Log("文件URL: " + file.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("解析服务器数据失败");
|
||||
}
|
||||
}
|
||||
// if (scene.fileList != null)
|
||||
// {
|
||||
// foreach (var file in scene.fileList)
|
||||
// {
|
||||
// Debug.Log("文件名称: " + file.name);
|
||||
// Debug.Log("文件URL: " + file.url);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log("解析服务器数据失败");
|
||||
// }
|
||||
//}
|
||||
|
||||
//查询演练科目信息列表
|
||||
public async void QueryDrillSubject()
|
||||
|
Loading…
Reference in New Issue
Block a user