Compare commits
2 Commits
6c8269ebb4
...
ed1187fa11
Author | SHA1 | Date | |
---|---|---|---|
ed1187fa11 | |||
0259ecde77 |
50
xiaofang/Assets/Script/DirllInterface/bindMaterial.cs
Normal file
50
xiaofang/Assets/Script/DirllInterface/bindMaterial.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class bindMaterial : 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<BindMaterial> BindMaterial(BindMaterialBody _bindMaterialBody)
|
||||
{
|
||||
|
||||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/material", "POST", JsonConvert.SerializeObject(_bindMaterialBody), CreateHeaders());
|
||||
Debug.Log("模板设备绑定: " + response);
|
||||
BindMaterial serverData = JsonConvert.DeserializeObject<BindMaterial>(response);
|
||||
if (serverData.data == null)
|
||||
{
|
||||
Debug.Log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
}
|
||||
Debug.Log(serverData.data);
|
||||
return serverData;
|
||||
}
|
||||
}
|
||||
//=====请求体===============================================
|
||||
public class BindMaterialBody
|
||||
{
|
||||
public string templateId;
|
||||
MaterialList[] materialList;
|
||||
}
|
||||
//=====返回===============================================
|
||||
public class BindMaterial : Response
|
||||
{
|
||||
public string data;//++++++++++++++++++++++++++++++++++++
|
||||
}
|
11
xiaofang/Assets/Script/DirllInterface/bindMaterial.cs.meta
Normal file
11
xiaofang/Assets/Script/DirllInterface/bindMaterial.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7e8bc78a7741d14ca2051180d8350c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
xiaofang/Assets/Script/DirllInterface/bindNPC.cs
Normal file
50
xiaofang/Assets/Script/DirllInterface/bindNPC.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class bindNPC : 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" }
|
||||
};
|
||||
}
|
||||
//模板NPC绑定
|
||||
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("模板NPC绑定: " + response);
|
||||
BindNPC serverData = JsonConvert.DeserializeObject<BindNPC>(response);
|
||||
return serverData;
|
||||
}
|
||||
}
|
||||
//=========请求体===================================================================
|
||||
public class BindNPCBody
|
||||
{
|
||||
string templateId;//===============必须
|
||||
NpcList[] npcList;//见createTemplate.cs第37行//=========必须
|
||||
}
|
||||
|
||||
|
||||
//==========返回=============================
|
||||
public class BindNPC : Response
|
||||
{
|
||||
public string data;//++++++++++++++++++++++++++++++++++++
|
||||
}
|
11
xiaofang/Assets/Script/DirllInterface/bindNPC.cs.meta
Normal file
11
xiaofang/Assets/Script/DirllInterface/bindNPC.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55a6f185d418b4f4fb02c65aaa7d2315
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,6 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class bindPlayer : MonoBehaviour
|
||||
@ -28,14 +29,15 @@ public class bindPlayer : MonoBehaviour
|
||||
|
||||
|
||||
//친겼鯤소곬땍
|
||||
public async void BindPlayer(bindPlayerBody bindPlayerBody)
|
||||
public async Task<BindPlayer> BindPlayer(bindPlayerBody bindPlayerBody)
|
||||
{
|
||||
bindPlayerBody bindPlayerBody1 = new bindPlayerBody();
|
||||
bindPlayerBody1 = bindPlayerBody;
|
||||
//bindPlayerBody bindPlayerBody1 = new bindPlayerBody();
|
||||
//bindPlayerBody1 = bindPlayerBody;
|
||||
|
||||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/player", "POST", JsonConvert.SerializeObject(bindPlayerBody1), CreateHeaders());
|
||||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/player", "POST", JsonConvert.SerializeObject(bindPlayerBody), CreateHeaders());
|
||||
Debug.Log("친겼鯤소곬땍: " + response);
|
||||
BindPlayer serverData = JsonConvert.DeserializeObject<BindPlayer>(response);
|
||||
return serverData;
|
||||
}
|
||||
}
|
||||
//=====헝헹竟====================================================================================
|
||||
@ -44,3 +46,8 @@ public class bindPlayerBody
|
||||
string templateId;//===============극伎
|
||||
PlayerList[] playerList;//숨createTemplate.cs뒤37契//=========극伎
|
||||
}
|
||||
//===============================================================================================
|
||||
public class BindPlayer : Response
|
||||
{
|
||||
public string data;
|
||||
}
|
48
xiaofang/Assets/Script/DirllInterface/submitTemplate.cs
Normal file
48
xiaofang/Assets/Script/DirllInterface/submitTemplate.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class submitTemplate : 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<SubmitTemplate> SubmitTemplate(submitTemplateBody _submitTemplateBody)
|
||||
{
|
||||
string response = await web.SendRequest(web.URL + "/game/gameRoom/reserve", "POST", JsonConvert.SerializeObject(_submitTemplateBody), CreateHeaders());
|
||||
Debug.Log("提交预定演练模板: " + response);
|
||||
SubmitTemplate serverData = JsonConvert.DeserializeObject<SubmitTemplate>(response);
|
||||
if (serverData.data == null)
|
||||
{
|
||||
Debug.Log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
}
|
||||
Debug.Log(serverData.data);
|
||||
return serverData;
|
||||
}
|
||||
}
|
||||
//========请求体========================================
|
||||
public class submitTemplateBody
|
||||
{
|
||||
public string templateId;
|
||||
public string reserveDate;
|
||||
}
|
||||
//===========返回值============================================
|
||||
public class SubmitTemplate : Response
|
||||
{
|
||||
public string data;//++++++++++++++++++++++++++++++++++++
|
||||
}
|
11
xiaofang/Assets/Script/DirllInterface/submitTemplate.cs.meta
Normal file
11
xiaofang/Assets/Script/DirllInterface/submitTemplate.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5401326285f565747ba6a116a034f249
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -156,22 +156,22 @@ public class loginData
|
||||
// public string roleAttributions; // 与 JSON 中的 "roleAttributions" 字段对应
|
||||
//}
|
||||
//===================================================================
|
||||
public class BindPlayer:Response
|
||||
{
|
||||
public string data;
|
||||
}
|
||||
//public class BindPlayer:Response
|
||||
//{
|
||||
// public string data;
|
||||
//}
|
||||
//=============================================================
|
||||
public class BindNPC : Response
|
||||
{
|
||||
public string data;//++++++++++++++++++++++++++++++++++++
|
||||
}
|
||||
//public class BindNPC : Response
|
||||
//{
|
||||
// public string data;//++++++++++++++++++++++++++++++++++++
|
||||
//}
|
||||
//====================================================
|
||||
public class BindMaterial : Response
|
||||
{
|
||||
public string data;//++++++++++++++++++++++++++++++++++++
|
||||
}
|
||||
//public class BindMaterial : Response
|
||||
//{
|
||||
// public string data;//++++++++++++++++++++++++++++++++++++
|
||||
//}
|
||||
//===================================================
|
||||
public class SubmitTemplate : Response
|
||||
{
|
||||
public string data;//++++++++++++++++++++++++++++++++++++
|
||||
}
|
||||
//public class SubmitTemplate : Response
|
||||
//{
|
||||
// public string data;//++++++++++++++++++++++++++++++++++++
|
||||
//}
|
@ -112,6 +112,7 @@ public class login : MonoBehaviour
|
||||
token = serverData.data.access_token;
|
||||
Debug.Log("===========" + serverData.data.isCreater);
|
||||
}
|
||||
}
|
||||
//삿혤친겼죗깊
|
||||
//public async void TemplaRst()
|
||||
//{
|
||||
@ -253,108 +254,107 @@ public class login : MonoBehaviour
|
||||
//}
|
||||
|
||||
//친겼鯤소곬땍
|
||||
public async void BindPlayer()
|
||||
{
|
||||
string templateId = "1111";
|
||||
string userId = "1";
|
||||
string roleId = "1";
|
||||
string birthAreaId = "11";
|
||||
string chargeAreaId = "2";
|
||||
//public async void BindPlayer()
|
||||
//{
|
||||
// string templateId = "1111";
|
||||
// string userId = "1";
|
||||
// string roleId = "1";
|
||||
// string birthAreaId = "11";
|
||||
// string chargeAreaId = "2";
|
||||
|
||||
string body = $@"
|
||||
{{
|
||||
""templateId"": ""{templateId}"",
|
||||
""playerList"": [
|
||||
{{
|
||||
""userId"": ""{userId}"",
|
||||
""roleId"": ""{roleId}"",
|
||||
""birthAreaId"": ""{birthAreaId}"",
|
||||
""chargeAreaId"": ""{chargeAreaId}""
|
||||
}}
|
||||
]
|
||||
}}";
|
||||
// string body = $@"
|
||||
//{{
|
||||
// ""templateId"": ""{templateId}"",
|
||||
// ""playerList"": [
|
||||
// {{
|
||||
// ""userId"": ""{userId}"",
|
||||
// ""roleId"": ""{roleId}"",
|
||||
// ""birthAreaId"": ""{birthAreaId}"",
|
||||
// ""chargeAreaId"": ""{chargeAreaId}""
|
||||
// }}
|
||||
// ]
|
||||
//}}";
|
||||
|
||||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/player", "POST", body, CreateHeaders());
|
||||
Debug.Log("친겼鯤소곬땍: " + response);
|
||||
BindPlayer serverData = JsonConvert.DeserializeObject<BindPlayer>(response);
|
||||
}
|
||||
//친겼NPC곬땍
|
||||
public async void BindNPC()
|
||||
{
|
||||
string templateId = "1111";
|
||||
string npcId = "1";
|
||||
string areaId = "1";
|
||||
int npcNum = 1;
|
||||
//string chargeAreaId = "2";
|
||||
// string response = await web.SendRequest(web.URL + "/game/gameTemplate/player", "POST", body, CreateHeaders());
|
||||
// Debug.Log("친겼鯤소곬땍: " + response);
|
||||
// BindPlayer serverData = JsonConvert.DeserializeObject<BindPlayer>(response);
|
||||
//}
|
||||
////친겼NPC곬땍
|
||||
//public async void BindNPC()
|
||||
//{
|
||||
// string templateId = "1111";
|
||||
// string npcId = "1";
|
||||
// string areaId = "1";
|
||||
// int npcNum = 1;
|
||||
// //string chargeAreaId = "2";
|
||||
|
||||
string body = $@"
|
||||
{{
|
||||
""templateId"": ""{templateId}"",
|
||||
""npcList"": [
|
||||
{{
|
||||
""npcId"": ""{npcId}"",
|
||||
""areaId"": ""{areaId}"",
|
||||
""npcNum"": ""{npcNum}""
|
||||
}}
|
||||
]
|
||||
}}";
|
||||
// string body = $@"
|
||||
//{{
|
||||
// ""templateId"": ""{templateId}"",
|
||||
// ""npcList"": [
|
||||
// {{
|
||||
// ""npcId"": ""{npcId}"",
|
||||
// ""areaId"": ""{areaId}"",
|
||||
// ""npcNum"": ""{npcNum}""
|
||||
// }}
|
||||
// ]
|
||||
//}}";
|
||||
|
||||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/npc", "POST", body, CreateHeaders());
|
||||
Debug.Log("친겼NPC곬땍: " + response);
|
||||
BindNPC serverData = JsonConvert.DeserializeObject<BindNPC>(response);
|
||||
}
|
||||
//친겼<ECB99C>구곬땍
|
||||
public async void BindMaterial()
|
||||
{
|
||||
string templateId = "1111";
|
||||
string materialId = "1";
|
||||
int num = 0;
|
||||
//string chargeAreaId = "2";
|
||||
// string response = await web.SendRequest(web.URL + "/game/gameTemplate/npc", "POST", body, CreateHeaders());
|
||||
// Debug.Log("친겼NPC곬땍: " + response);
|
||||
// BindNPC serverData = JsonConvert.DeserializeObject<BindNPC>(response);
|
||||
//}
|
||||
////친겼<ECB99C>구곬땍
|
||||
//public async void BindMaterial()
|
||||
//{
|
||||
// string templateId = "1111";
|
||||
// string materialId = "1";
|
||||
// int num = 0;
|
||||
// //string chargeAreaId = "2";
|
||||
|
||||
string body = $@"
|
||||
{{
|
||||
""templateId"": ""{templateId}"",
|
||||
""materialList"": [
|
||||
{{
|
||||
""materialId"": ""{materialId}"",
|
||||
""num"": ""{num}""
|
||||
}}
|
||||
]
|
||||
}}";
|
||||
// string body = $@"
|
||||
//{{
|
||||
// ""templateId"": ""{templateId}"",
|
||||
// ""materialList"": [
|
||||
// {{
|
||||
// ""materialId"": ""{materialId}"",
|
||||
// ""num"": ""{num}""
|
||||
// }}
|
||||
// ]
|
||||
//}}";
|
||||
|
||||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/material", "POST", body, CreateHeaders());
|
||||
Debug.Log("친겼<ECB99C>구곬땍: " + response);
|
||||
BindMaterial serverData = JsonConvert.DeserializeObject<BindMaterial>(response);
|
||||
if (serverData.data == null)
|
||||
{
|
||||
Debug.Log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
}
|
||||
Debug.Log(serverData.data);
|
||||
}
|
||||
// string response = await web.SendRequest(web.URL + "/game/gameTemplate/material", "POST", body, CreateHeaders());
|
||||
// Debug.Log("친겼<ECB99C>구곬땍: " + response);
|
||||
// BindMaterial serverData = JsonConvert.DeserializeObject<BindMaterial>(response);
|
||||
// if (serverData.data == null)
|
||||
// {
|
||||
// Debug.Log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
// }
|
||||
// Debug.Log(serverData.data);
|
||||
//}
|
||||
|
||||
//瓊슥渡땍蘿족친겼
|
||||
public async void SubmitTemplate()
|
||||
{
|
||||
string templateId = "1111";
|
||||
string reserveDate = "2024-11-22";
|
||||
// int num = 0;
|
||||
//string chargeAreaId = "2";
|
||||
// //瓊슥渡땍蘿족친겼
|
||||
// public async void SubmitTemplate()
|
||||
// {
|
||||
// string templateId = "1111";
|
||||
// string reserveDate = "2024-11-22";
|
||||
// // int num = 0;
|
||||
// //string chargeAreaId = "2";
|
||||
|
||||
string body = $@"
|
||||
{{
|
||||
""templateId"": ""{templateId}"",
|
||||
""reserveDate"":""{reserveDate}""
|
||||
}}";
|
||||
string response = await web.SendRequest(web.URL + "/game/gameRoom/reserve", "POST", body, CreateHeaders());
|
||||
Debug.Log("瓊슥渡땍蘿족친겼: " + response);
|
||||
BindMaterial serverData = JsonConvert.DeserializeObject<BindMaterial>(response);
|
||||
if (serverData.data == null)
|
||||
{
|
||||
Debug.Log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
}
|
||||
Debug.Log(serverData.data);
|
||||
}
|
||||
|
||||
}
|
||||
// string body = $@"
|
||||
// {{
|
||||
// ""templateId"": ""{templateId}"",
|
||||
// ""reserveDate"":""{reserveDate}""
|
||||
// }}";
|
||||
// string response = await web.SendRequest(web.URL + "/game/gameRoom/reserve", "POST", body, CreateHeaders());
|
||||
// Debug.Log("瓊슥渡땍蘿족친겼: " + response);
|
||||
// BindMaterial serverData = JsonConvert.DeserializeObject<BindMaterial>(response);
|
||||
// if (serverData.data == null)
|
||||
// {
|
||||
// Debug.Log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
// }
|
||||
// Debug.Log(serverData.data);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user