huang
This commit is contained in:
parent
107ebcde62
commit
2bb3a4898b
@ -10439,8 +10439,8 @@ GameObject:
|
|||||||
- component: {fileID: 2127674356}
|
- component: {fileID: 2127674356}
|
||||||
- component: {fileID: 2127674357}
|
- component: {fileID: 2127674357}
|
||||||
- component: {fileID: 2127674358}
|
- component: {fileID: 2127674358}
|
||||||
- component: {fileID: 2127674359}
|
|
||||||
- component: {fileID: 2127674360}
|
- component: {fileID: 2127674360}
|
||||||
|
- component: {fileID: 2127674361}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: InfoObject
|
m_Name: InfoObject
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -10495,20 +10495,6 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 8ee1a43c8ad7f8c41bad48013bf5af49, type: 3}
|
m_Script: {fileID: 11500000, guid: 8ee1a43c8ad7f8c41bad48013bf5af49, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
--- !u!114 &2127674359
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2127674355}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: b7936430f01cc8343a1e62fc2052a12b, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
gameEscapeId: 0
|
|
||||||
carrySeconds: 0
|
|
||||||
--- !u!114 &2127674360
|
--- !u!114 &2127674360
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -10523,6 +10509,20 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
token:
|
token:
|
||||||
escapeId: -1
|
escapeId: -1
|
||||||
|
--- !u!114 &2127674361
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2127674355}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: e861ed692e9579d44968fc5f4e3a7b37, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
gameEscapeId: 0
|
||||||
|
carrySeconds: 0
|
||||||
--- !u!1 &2135586305
|
--- !u!1 &2135586305
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -22,7 +22,7 @@ public class HegemonTime : MonoBehaviour
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
Debug.Log("carrySeconds:" + InfoObject.GetComponent<selectGameEscape512>().carrySeconds);
|
// Debug.Log("carrySeconds:" + InfoObject.GetComponent<selectLatest511>().carrySeconds);
|
||||||
|
|
||||||
}
|
}
|
||||||
public IEnumerator StartGame()
|
public IEnumerator StartGame()
|
||||||
|
@ -56,7 +56,7 @@ public class Test : MonoBehaviour
|
|||||||
{ "Authorization", Authorization }, // 设置授权头
|
{ "Authorization", Authorization }, // 设置授权头
|
||||||
};
|
};
|
||||||
|
|
||||||
string response51 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", head51);
|
string response51 = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryLatest", "POST", "{}", head51);
|
||||||
Debug.Log("5.1查询最近一场大屠杀(独立)" + response51); // 查询最近一场大逃亡游戏详情:
|
Debug.Log("5.1查询最近一场大屠杀(独立)" + response51); // 查询最近一场大逃亡游戏详情:
|
||||||
|
|
||||||
// 解析JSON数据
|
// 解析JSON数据
|
||||||
|
@ -1,262 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
/*public class QueryEscapeRoom : MonoBehaviour
|
|
||||||
{
|
|
||||||
public string token = null; // 保存最新的 token,初始为 null
|
|
||||||
public int escapeId = -1; // 保存最新的 escapeId,初始为 -1 表示未设置
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
// 注册监听事件,当收到 token 时,触发 HandleTokenReceived
|
|
||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
|
||||||
public void HandleTokenReceived(string receivedToken)
|
|
||||||
{
|
|
||||||
token = receivedToken; // 保存最新的 token
|
|
||||||
// 首次调用加载初始数据
|
|
||||||
LoadInitialData();
|
|
||||||
//LoadGameEscapeData();
|
|
||||||
//Debug.Log("接收到新的 token: " + token);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当游戏逃亡 ID 更新时触发此方法,仅保存最新的 escapeId
|
|
||||||
public async void HandleGameEscapeIdUpdated(int newGameEscapeId)
|
|
||||||
{
|
|
||||||
escapeId = newGameEscapeId; // 保存最新的 escapeId
|
|
||||||
await QueryEscapeRoomDetails();//=====================================================================放在这里仅因为懒得写触发条件,可以放在任何地方,比如input.GetKeyDown.....必须改掉,吃服务器
|
|
||||||
//Debug.Log("接收到新的 GameEscapeId: " + escapeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 加载初始数据,使用最新的 token
|
|
||||||
public async void LoadInitialData()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法加载初始数据,token 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await QueryEscapeRoomDetails();//=====================================================================放在此处只为解除一个黄色报错,看着闹心。但可以不要
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载游戏逃亡数据,使用最新的 escapeId 和 token
|
|
||||||
public async void selectQueryKill1()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法加载游戏逃亡数据,token 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapeId == -1)
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法加载游戏逃亡数据,escapeId 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await QueryEscapeRoomDetails();//==========================================================================================================================================================================
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//===============================================================================================================================================================================================================================
|
|
||||||
// 查询逃亡房间详情
|
|
||||||
public async Task QueryEscapeRoomDetails()
|
|
||||||
{
|
|
||||||
var headers = CreateHeaders();
|
|
||||||
string body = $@"
|
|
||||||
{{
|
|
||||||
""userId"": 106,
|
|
||||||
""escapeId"": {escapeId}
|
|
||||||
}}";
|
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
|
|
||||||
Debug.Log("逃亡房间详情响应: " + response);
|
|
||||||
}
|
|
||||||
//===============================================================================================================================================================================================================================
|
|
||||||
|
|
||||||
// 创建请求头,使用最新的 token
|
|
||||||
public Dictionary<string, string> CreateHeaders()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
|
||||||
return new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "Authorization", token }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
|
||||||
{
|
|
||||||
// 注销监听事件,避免内存泄漏
|
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class QueryEscapeRoom : MonoBehaviour
|
|
||||||
{
|
|
||||||
public string token = null; // 保存最新的 token,初始为 null
|
|
||||||
public int escapeId = -1; // 保存最新的 escapeId,初始为 -1 表示未设置
|
|
||||||
private string lastEscapeRoomResponse = null; // 保存最新的逃亡房间查询响应
|
|
||||||
|
|
||||||
// 假设有一个手动查询逃亡房间详情的按钮===================================================================================
|
|
||||||
public Button queryEscapeRoomButton;
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
// 注册监听事件,当收到 token 时,触发 HandleTokenReceived
|
|
||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
|
||||||
|
|
||||||
// 假设按钮被点击时调用 OnQueryEscapeRoomButtonClicked================================================================
|
|
||||||
if (queryEscapeRoomButton != null)
|
|
||||||
{
|
|
||||||
queryEscapeRoomButton.onClick.AddListener(OnQueryEscapeRoomButtonClicked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
|
||||||
public void HandleTokenReceived(string receivedToken)
|
|
||||||
{
|
|
||||||
token = receivedToken; // 保存最新的 token
|
|
||||||
Debug.Log("接收到新的 token: " + token);
|
|
||||||
|
|
||||||
// 首次调用加载初始数据
|
|
||||||
LoadInitialData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当游戏逃亡 ID 更新时触发此方法,仅保存最新的 escapeId
|
|
||||||
public async void HandleGameEscapeIdUpdated(int newGameEscapeId)
|
|
||||||
{
|
|
||||||
escapeId = newGameEscapeId; // 保存最新的 escapeId
|
|
||||||
Debug.Log("接收到新的 GameEscapeId: " + escapeId);
|
|
||||||
|
|
||||||
// 在接收到 escapeId 更新时自动调用查询逃亡房间详情
|
|
||||||
lastEscapeRoomResponse = await QueryEscapeRoomDetails();
|
|
||||||
Debug.Log("HandleGameEscapeIdUpdated 处理的查询逃亡房间响应: " + lastEscapeRoomResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载初始数据,使用最新的 token
|
|
||||||
public async void LoadInitialData()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法加载初始数据,token 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 调用查询逃亡房间详情方法
|
|
||||||
lastEscapeRoomResponse = await QueryEscapeRoomDetails();
|
|
||||||
Debug.Log("初始加载的查询逃亡房间详情响应: " + lastEscapeRoomResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 按钮点击后触发逃亡房间详情查询操作
|
|
||||||
public async void OnQueryEscapeRoomButtonClicked()
|
|
||||||
{
|
|
||||||
// 检查 token 和 escapeId 是否已正确设置
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法查询逃亡房间详情,token 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapeId == -1)
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法查询逃亡房间详情,escapeId 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 调用查询逃亡房间详情方法
|
|
||||||
lastEscapeRoomResponse = await QueryEscapeRoomDetails();
|
|
||||||
Debug.Log("用户按钮触发的查询逃亡房间详情响应: " + lastEscapeRoomResponse);
|
|
||||||
|
|
||||||
// 根据响应做进一步的处理
|
|
||||||
HandleEscapeRoomResponse(lastEscapeRoomResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询逃亡房间详情
|
|
||||||
public async Task<string> QueryEscapeRoomDetails()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法查询逃亡房间详情,token 未设置。");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapeId == -1)
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法查询逃亡房间详情,escapeId 未设置。");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var headers = CreateHeaders();
|
|
||||||
string body = $@"
|
|
||||||
{{
|
|
||||||
""userId"": 106,
|
|
||||||
""escapeId"": {escapeId}
|
|
||||||
}}";
|
|
||||||
|
|
||||||
Debug.Log("正在查询逃亡房间详情...");
|
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
|
|
||||||
Debug.Log("查询逃亡房间详情响应: " + response);
|
|
||||||
return response; // 返回响应
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建请求头,使用最新的 token
|
|
||||||
public Dictionary<string, string> CreateHeaders()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
|
||||||
return new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "Authorization", token }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理 QueryEscapeRoomDetails 方法的响应
|
|
||||||
private void HandleEscapeRoomResponse(string response)
|
|
||||||
{
|
|
||||||
if (response.Contains("success"))
|
|
||||||
{
|
|
||||||
Debug.Log("查询逃亡房间详情成功!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogWarning("查询逃亡房间详情失败,服务器响应: " + response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
|
||||||
{
|
|
||||||
// 注销监听事件,避免内存泄漏
|
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
|
||||||
|
|
||||||
// 取消按钮的点击监听================================================================================================
|
|
||||||
if (queryEscapeRoomButton != null)
|
|
||||||
{
|
|
||||||
queryEscapeRoomButton.onClick.RemoveListener(OnQueryEscapeRoomButtonClicked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b27d2d49f51751e42b31653d0b0b8d2d
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -18,7 +18,7 @@ using UnityEngine.UI;
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
// 当接收到 token 时触发此方法,仅保存 token
|
||||||
@ -107,7 +107,7 @@ using UnityEngine.UI;
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public class UpdateUserInfo : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 假设按钮被点击时调用 OnUpdateUserInfoButtonClicked==================================================================
|
// 假设按钮被点击时调用 OnUpdateUserInfoButtonClicked==================================================================
|
||||||
if (updateUserInfoButton != null)
|
if (updateUserInfoButton != null)
|
||||||
@ -245,7 +245,7 @@ public class UpdateUserInfo : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 取消按钮的点击监听===============================================================================================
|
// 取消按钮的点击监听===============================================================================================
|
||||||
if (updateUserInfoButton != null)
|
if (updateUserInfoButton != null)
|
||||||
|
@ -16,7 +16,7 @@ using UnityEngine.UI;
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
// 当接收到 token 时触发此方法,仅保存 token
|
||||||
@ -78,7 +78,7 @@ using UnityEngine.UI;
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryUserBetResult", "POST", body, headers);
|
||||||
Debug.Log("查询用户下注结果响应: " + response);
|
Debug.Log("查询用户下注结果响应: " + response);
|
||||||
}
|
}
|
||||||
//===============================================================================================================================================================================================================================
|
//===============================================================================================================================================================================================================================
|
||||||
@ -102,7 +102,7 @@ using UnityEngine.UI;
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public class UserBetResult : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
//// 假设按钮被点击时调用 OnQueryUserBetButtonClicked=====================================================================
|
//// 假设按钮被点击时调用 OnQueryUserBetButtonClicked=====================================================================
|
||||||
//if (queryUserBetButton != null)
|
//if (queryUserBetButton != null)
|
||||||
@ -214,7 +214,7 @@ public class UserBetResult : MonoBehaviour
|
|||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
|
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryUserBetResult", "POST", body, headers);
|
||||||
Debug.Log("查询用户下注结果响应: " + response);
|
Debug.Log("查询用户下注结果响应: " + response);
|
||||||
return response; // 返回响应
|
return response; // 返回响应
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ public class UserBetResult : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
//// 取消按钮的点击监听================================================================================================
|
//// 取消按钮的点击监听================================================================================================
|
||||||
//if (queryUserBetButton != null)
|
//if (queryUserBetButton != null)
|
||||||
|
@ -16,7 +16,7 @@ using UnityEngine.UI;
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
// 当接收到 token 时触发此方法,仅保存 token
|
||||||
@ -80,7 +80,7 @@ using UnityEngine.UI;
|
|||||||
""bet"": 100,
|
""bet"": 100,
|
||||||
""roomNo"": 1
|
""roomNo"": 1
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/userBet", "POST", body, headers);
|
||||||
Debug.Log("用户下注响应: " + response);
|
Debug.Log("用户下注响应: " + response);
|
||||||
}
|
}
|
||||||
//===============================================================================================================================================================================================================================
|
//===============================================================================================================================================================================================================================
|
||||||
@ -104,7 +104,7 @@ using UnityEngine.UI;
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public class Gamber : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 假设下注按钮被点击时调用 OnUserBetButtonClicked===================================================================
|
// 假设下注按钮被点击时调用 OnUserBetButtonClicked===================================================================
|
||||||
if (userBetButton != null)
|
if (userBetButton != null)
|
||||||
@ -201,7 +201,7 @@ public class Gamber : MonoBehaviour
|
|||||||
""roomNo"": 1
|
""roomNo"": 1
|
||||||
}}";
|
}}";
|
||||||
|
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/userBet", "POST", body, headers);
|
||||||
Debug.Log("用户下注响应: " + response);
|
Debug.Log("用户下注响应: " + response);
|
||||||
return response; // 返回响应
|
return response; // 返回响应
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ public class Gamber : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 取消按钮的点击监听================================================================================================
|
// 取消按钮的点击监听================================================================================================
|
||||||
if (userBetButton != null)
|
if (userBetButton != null)
|
||||||
|
@ -16,7 +16,7 @@ using UnityEngine.UI;
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
// 当接收到 token 时触发此方法,仅保存 token
|
||||||
@ -139,7 +139,7 @@ using UnityEngine.UI;
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ public class LoadMall : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 假设按钮被点击时调用 OnLoadMallButtonClicked========================================================================
|
// 假设按钮被点击时调用 OnLoadMallButtonClicked========================================================================
|
||||||
if (loadMallButton != null)
|
if (loadMallButton != null)
|
||||||
@ -316,7 +316,7 @@ public class LoadMall : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 取消按钮的点击监听==============================================================================================
|
// 取消按钮的点击监听==============================================================================================
|
||||||
if (loadMallButton != null)
|
if (loadMallButton != null)
|
||||||
|
@ -1,265 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
/*public class selectQueryKill : MonoBehaviour
|
|
||||||
{
|
|
||||||
public string token = null; // 保存最新的 token,初始为 null
|
|
||||||
public int escapeId = -1; // 保存最新的 escapeId,初始为 -1 表示未设置
|
|
||||||
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
// 注册监听事件,当收到 token 时,触发 HandleTokenReceived
|
|
||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
|
||||||
public void HandleTokenReceived(string receivedToken)
|
|
||||||
{
|
|
||||||
token = receivedToken; // 保存最新的 token
|
|
||||||
// 首次调用加载初始数据
|
|
||||||
LoadInitialData();
|
|
||||||
//LoadGameEscapeData();
|
|
||||||
//Debug.Log("接收到新的 token: " + token);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当游戏逃亡 ID 更新时触发此方法,仅保存最新的 escapeId
|
|
||||||
public async void HandleGameEscapeIdUpdated(int newGameEscapeId)
|
|
||||||
{
|
|
||||||
escapeId = newGameEscapeId; // 保存最新的 escapeId
|
|
||||||
await QueryKill();//==================================================================================放在这里仅因为懒得写触发条件,可以放在任何地方,比如input.GetKeyDown.....必须改
|
|
||||||
// Debug.Log("接收到新的 GameEscapeId: " + escapeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 加载初始数据,使用最新的 token
|
|
||||||
public async void LoadInitialData()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法加载初始数据,token 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await QueryKill();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载游戏逃亡数据,使用最新的 escapeId 和 token
|
|
||||||
public async void selectQueryKill1()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法加载游戏逃亡数据,token 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapeId == -1)
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法加载游戏逃亡数据,escapeId 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 查询击杀数据
|
|
||||||
await QueryKill();//=================================================================================================================================
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//===============================================================================================================================================================================================================================
|
|
||||||
// 查询击杀信息
|
|
||||||
public async Task QueryKill()
|
|
||||||
{
|
|
||||||
var headers = CreateHeaders();
|
|
||||||
string body = $@"
|
|
||||||
{{
|
|
||||||
""userId"": 106,
|
|
||||||
""escapeId"": {escapeId}
|
|
||||||
}}";
|
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
|
|
||||||
Debug.Log("查询击杀信息响应: " + response);
|
|
||||||
}
|
|
||||||
//===============================================================================================================================================================================================================================
|
|
||||||
|
|
||||||
// 创建请求头,使用最新的 token
|
|
||||||
public Dictionary<string, string> CreateHeaders()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
|
||||||
return new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "Authorization", token }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
|
||||||
{
|
|
||||||
// 注销监听事件,避免内存泄漏
|
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class SelectQueryKill : MonoBehaviour
|
|
||||||
{
|
|
||||||
public string token = null; // 保存最新的 token,初始为 null
|
|
||||||
public int escapeId = -1; // 保存最新的 escapeId,初始为 -1 表示未设置
|
|
||||||
private string lastQueryKillResponse = null; // 保存最新的击杀信息查询响应
|
|
||||||
|
|
||||||
// 假设有一个手动查询击杀信息的按钮=======================================================================================
|
|
||||||
public Button queryKillButton;
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
// 注册监听事件,当收到 token 时,触发 HandleTokenReceived
|
|
||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
|
||||||
|
|
||||||
// 假设按钮被点击时调用 OnQueryKillButtonClicked======================================================================
|
|
||||||
if (queryKillButton != null)
|
|
||||||
{
|
|
||||||
queryKillButton.onClick.AddListener(OnQueryKillButtonClicked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
|
||||||
public void HandleTokenReceived(string receivedToken)
|
|
||||||
{
|
|
||||||
token = receivedToken; // 保存最新的 token
|
|
||||||
Debug.Log("接收到新的 token: " + token);
|
|
||||||
|
|
||||||
// 首次调用加载初始数据
|
|
||||||
LoadInitialData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当游戏逃亡 ID 更新时触发此方法,仅保存最新的 escapeId
|
|
||||||
public async void HandleGameEscapeIdUpdated(int newGameEscapeId)
|
|
||||||
{
|
|
||||||
escapeId = newGameEscapeId; // 保存最新的 escapeId
|
|
||||||
Debug.Log("接收到新的 GameEscapeId: " + escapeId);
|
|
||||||
|
|
||||||
// 在接收到 escapeId 更新时自动调用查询击杀信息
|
|
||||||
lastQueryKillResponse = await QueryKill();
|
|
||||||
Debug.Log("HandleGameEscapeIdUpdated 处理的查询击杀信息响应: " + lastQueryKillResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载初始数据,使用最新的 token
|
|
||||||
public async void LoadInitialData()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法加载初始数据,token 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 调用查询击杀信息方法
|
|
||||||
lastQueryKillResponse = await QueryKill();
|
|
||||||
Debug.Log("初始加载的查询击杀信息响应: " + lastQueryKillResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 按钮点击后触发击杀信息查询操作
|
|
||||||
public async void OnQueryKillButtonClicked()
|
|
||||||
{
|
|
||||||
// 检查 token 和 escapeId 是否已正确设置
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法查询击杀信息,token 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapeId == -1)
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法查询击杀信息,escapeId 未设置。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 调用查询击杀信息方法
|
|
||||||
lastQueryKillResponse = await QueryKill();
|
|
||||||
Debug.Log("用户按钮触发的查询击杀信息响应: " + lastQueryKillResponse);
|
|
||||||
|
|
||||||
// 根据响应做进一步的处理
|
|
||||||
HandleQueryKillResponse(lastQueryKillResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询击杀信息
|
|
||||||
public async Task<string> QueryKill()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法查询击杀信息,token 未设置。");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapeId == -1)
|
|
||||||
{
|
|
||||||
Debug.LogWarning("无法查询击杀信息,escapeId 未设置。");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var headers = CreateHeaders();
|
|
||||||
string body = $@"
|
|
||||||
{{
|
|
||||||
""userId"": 106,
|
|
||||||
""escapeId"": {escapeId}
|
|
||||||
}}";
|
|
||||||
|
|
||||||
Debug.Log("正在查询击杀信息...");
|
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
|
|
||||||
Debug.Log("查询击杀信息响应: " + response);
|
|
||||||
return response; // 返回响应
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建请求头,使用最新的 token
|
|
||||||
public Dictionary<string, string> CreateHeaders()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(token))
|
|
||||||
{
|
|
||||||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
|
||||||
return new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "Authorization", token }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理 QueryKill 方法的响应
|
|
||||||
private void HandleQueryKillResponse(string response)
|
|
||||||
{
|
|
||||||
if (response.Contains("success"))
|
|
||||||
{
|
|
||||||
Debug.Log("查询击杀信息成功!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogWarning("查询击杀信息失败,服务器响应: " + response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
|
||||||
{
|
|
||||||
// 注销监听事件,避免内存泄漏
|
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
|
||||||
|
|
||||||
// 取消按钮的点击监听=================================================================================================
|
|
||||||
if (queryKillButton != null)
|
|
||||||
{
|
|
||||||
queryKillButton.onClick.RemoveListener(OnQueryKillButtonClicked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c230883956c0b3546a885c300ad34498
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -17,7 +17,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
// 当接收到 token 时触发此方法,仅保存 token
|
||||||
@ -101,7 +101,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 假设按钮被点击时调用 OnSelectUserInfoButtonClicked
|
// 假设按钮被点击时调用 OnSelectUserInfoButtonClicked
|
||||||
if (selectUserInfoButton != null)
|
if (selectUserInfoButton != null)
|
||||||
@ -233,7 +233,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 取消按钮的点击监听
|
// 取消按钮的点击监听
|
||||||
if (selectUserInfoButton != null)
|
if (selectUserInfoButton != null)
|
||||||
@ -260,7 +260,7 @@ public class SelectUserInfo : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 假设按钮被点击时调用 OnSelectUserInfoButtonClicked===================================================================
|
// 假设按钮被点击时调用 OnSelectUserInfoButtonClicked===================================================================
|
||||||
if (selectUserInfoButton != null)
|
if (selectUserInfoButton != null)
|
||||||
@ -410,7 +410,7 @@ public class SelectUserInfo : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
|
|
||||||
// 取消按钮的点击监听-==============================================================================================
|
// 取消按钮的点击监听-==============================================================================================
|
||||||
if (selectUserInfoButton != null)
|
if (selectUserInfoButton != null)
|
||||||
|
@ -28,6 +28,7 @@ public class LoginAndGetToken : MonoBehaviour
|
|||||||
string loginResponse = await web.SendRequest("http://121.40.42.41:8080/snail/user/login", "POST", JsonUtility.ToJson(body));
|
string loginResponse = await web.SendRequest("http://121.40.42.41:8080/snail/user/login", "POST", JsonUtility.ToJson(body));
|
||||||
//Debug.Log("LoginAndGetToken되쩌:"+loginResponse);
|
//Debug.Log("LoginAndGetToken되쩌:"+loginResponse);
|
||||||
string token = getToken(loginResponse);
|
string token = getToken(loginResponse);
|
||||||
|
int userId = getUserId(loginResponse);
|
||||||
OnTokenReceived?.Invoke(token);
|
OnTokenReceived?.Invoke(token);
|
||||||
//되쩌헝헹//綠繫법
|
//되쩌헝헹//綠繫법
|
||||||
}
|
}
|
||||||
@ -51,6 +52,36 @@ public class LoginAndGetToken : MonoBehaviour
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//获取userId
|
||||||
|
public static int getUserId(string json)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 解析 JSON 字符串为 JObject
|
||||||
|
JObject parsedJson = JObject.Parse(json);
|
||||||
|
|
||||||
|
// 从 JObject 中提取 userId 字段的值
|
||||||
|
string userIdString = parsedJson["data"]?["userId"]?.ToString();
|
||||||
|
|
||||||
|
// 尝试将 userId 转换为 int
|
||||||
|
if (int.TryParse(userIdString, out int userId))
|
||||||
|
{
|
||||||
|
return userId; // 返回解析后的 userId
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to parse userId as an integer.");
|
||||||
|
return -1; // 返回 -1 表示解析失败
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// 处理解析过程中可能出现的异常
|
||||||
|
Console.WriteLine("An error occurred while parsing the JSON: " + ex.Message);
|
||||||
|
return -1; // 返回 -1 表示解析失败
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class loginbody//되쩌뵨鬧꿍痰
|
public class loginbody//되쩌뵨鬧꿍痰
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 订阅事件,当 gameEscapeId 更新时调用 HandleGameEscapeIdUpdated
|
// 订阅事件,当 gameEscapeId 更新时调用 HandleGameEscapeIdUpdated
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleTokenReceived(string receivedToken)
|
void HandleTokenReceived(string receivedToken)
|
||||||
@ -167,7 +167,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
{ "Authorization", Authorization }, // 设置授权头
|
{ "Authorization", Authorization }, // 设置授权头
|
||||||
};
|
};
|
||||||
// 使用最新的 escapeId 在请求体中
|
// 使用最新的 escapeId 在请求体中
|
||||||
string response51 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", head51);
|
string response51 = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryLatest", "POST", "{}", head51);
|
||||||
Debug.Log("5.1查询最近一场大屠杀: " + response51);
|
Debug.Log("5.1查询最近一场大屠杀: " + response51);
|
||||||
//// ====================================================================================================================
|
//// ====================================================================================================================
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response512 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", queryEscapeRoomListBody, head512);
|
string response512 = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryEscapeRoomList", "POST", queryEscapeRoomListBody, head512);
|
||||||
Debug.Log("5.1.2查询各大逃亡房间最新详情(高性能版): " + response512);
|
Debug.Log("5.1.2查询各大逃亡房间最新详情(高性能版): " + response512);
|
||||||
|
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""bet"": 100,
|
""bet"": 100,
|
||||||
""roomNo"":1
|
""roomNo"":1
|
||||||
}}";
|
}}";
|
||||||
string response513 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", userBetBody, head513);
|
string response513 = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/userBet", "POST", userBetBody, head513);
|
||||||
Debug.Log("5.1.3,用户下注:" + response513);
|
Debug.Log("5.1.3,用户下注:" + response513);
|
||||||
|
|
||||||
//5.1.4,查询击杀
|
//5.1.4,查询击杀
|
||||||
@ -214,7 +214,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response514 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", selectKill, head514);
|
string response514 = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryKill", "POST", selectKill, head514);
|
||||||
Debug.Log("5.1.4,查询击杀:" + response514);
|
Debug.Log("5.1.4,查询击杀:" + response514);
|
||||||
|
|
||||||
////5.1.5,查询结算
|
////5.1.5,查询结算
|
||||||
@ -227,7 +227,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response515 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", queryUserBetResult, head515);
|
string response515 = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryUserBetResult", "POST", queryUserBetResult, head515);
|
||||||
Debug.Log("5.1.5,查询结算:" + response515);
|
Debug.Log("5.1.5,查询结算:" + response515);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 取消监听,避免内存泄漏
|
// 取消监听,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@ -322,7 +322,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 订阅事件,当 gameEscapeId 更新时调用 HandleGameEscapeIdUpdated
|
// 订阅事件,当 gameEscapeId 更新时调用 HandleGameEscapeIdUpdated
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法
|
// 当接收到 token 时触发此方法
|
||||||
@ -446,7 +446,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
private async Task QueryLatestMassacre(string token)
|
private async Task QueryLatestMassacre(string token)
|
||||||
{
|
{
|
||||||
var headers = CreateHeaders(token);
|
var headers = CreateHeaders(token);
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryLatest", "POST", "{}", headers);
|
||||||
Debug.Log("查询最近大屠杀响应: " + response);
|
Debug.Log("查询最近大屠杀响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryEscapeRoomList", "POST", body, headers);
|
||||||
Debug.Log("逃亡房间详情响应: " + response);
|
Debug.Log("逃亡房间详情响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""bet"": 100,
|
""bet"": 100,
|
||||||
""roomNo"": 1
|
""roomNo"": 1
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/userBet", "POST", body, headers);
|
||||||
Debug.Log("用户下注响应: " + response);
|
Debug.Log("用户下注响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +487,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryKill", "POST", body, headers);
|
||||||
Debug.Log("查询击杀信息响应: " + response);
|
Debug.Log("查询击杀信息响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryUserBetResult", "POST", body, headers);
|
||||||
Debug.Log("查询用户下注结果响应: " + response);
|
Debug.Log("查询用户下注结果响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update 方法保留,但当前没有需要的功能
|
// Update 方法保留,但当前没有需要的功能
|
||||||
@ -545,7 +545,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法
|
// 当接收到 token 时触发此方法
|
||||||
@ -677,7 +677,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
private async Task QueryLatestMassacre(string token)
|
private async Task QueryLatestMassacre(string token)
|
||||||
{
|
{
|
||||||
var headers = CreateHeaders(token);
|
var headers = CreateHeaders(token);
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryLatest", "POST", "{}", headers);
|
||||||
Debug.Log("查询最近大屠杀响应: " + response);
|
Debug.Log("查询最近大屠杀响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,7 +690,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryEscapeRoomList", "POST", body, headers);
|
||||||
Debug.Log("逃亡房间详情响应: " + response);
|
Debug.Log("逃亡房间详情响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,7 +705,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""bet"": 100,
|
""bet"": 100,
|
||||||
""roomNo"": 1
|
""roomNo"": 1
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/userBet", "POST", body, headers);
|
||||||
Debug.Log("用户下注响应: " + response);
|
Debug.Log("用户下注响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -718,7 +718,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryKill", "POST", body, headers);
|
||||||
Debug.Log("查询击杀信息响应: " + response);
|
Debug.Log("查询击杀信息响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,7 +731,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryUserBetResult", "POST", body, headers);
|
||||||
Debug.Log("查询用户下注结果响应: " + response);
|
Debug.Log("查询用户下注结果响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,7 +748,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
/*using System;
|
/*using System;
|
||||||
@ -771,7 +771,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法
|
// 当接收到 token 时触发此方法
|
||||||
@ -900,7 +900,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
//private async Task QueryLatestMassacre()
|
//private async Task QueryLatestMassacre()
|
||||||
//{
|
//{
|
||||||
// var headers = CreateHeaders();
|
// var headers = CreateHeaders();
|
||||||
// string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", headers);
|
// string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryLatest", "POST", "{}", headers);
|
||||||
// Debug.Log("查询最近大屠杀响应: " + response);
|
// Debug.Log("查询最近大屠杀响应: " + response);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
@ -913,7 +913,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryEscapeRoomList", "POST", body, headers);
|
||||||
Debug.Log("逃亡房间详情响应: " + response);
|
Debug.Log("逃亡房间详情响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,7 +928,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""bet"": 100,
|
""bet"": 100,
|
||||||
""roomNo"": 1
|
""roomNo"": 1
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/userBet", "POST", body, headers);
|
||||||
Debug.Log("用户下注响应: " + response);
|
Debug.Log("用户下注响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -941,7 +941,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryKill", "POST", body, headers);
|
||||||
Debug.Log("查询击杀信息响应: " + response);
|
Debug.Log("查询击杀信息响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -954,7 +954,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryUserBetResult", "POST", body, headers);
|
||||||
Debug.Log("查询用户下注结果响应: " + response);
|
Debug.Log("查询用户下注结果响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,7 +971,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
using System;
|
using System;
|
||||||
@ -991,7 +991,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
||||||
|
|
||||||
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
// 注册监听,当 escapeId 更新时调用 HandleGameEscapeIdUpdated,但不执行其他方法
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当接收到 token 时触发此方法,仅保存 token
|
// 当接收到 token 时触发此方法,仅保存 token
|
||||||
@ -1132,13 +1132,13 @@ public class WebConnact : MonoBehaviour
|
|||||||
Debug.Log("购买商品响应: " + response);
|
Debug.Log("购买商品响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
//// 查询最近的大屠杀
|
// 查询最近的大屠杀
|
||||||
//public async Task QueryLatestMassacre()
|
public async Task QueryLatestMassacre()
|
||||||
//{
|
{
|
||||||
// var headers = CreateHeaders();
|
var headers = CreateHeaders();
|
||||||
// string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryLatest", "POST", "{}", headers);
|
||||||
// Debug.Log("查询最近大屠杀响应: " + response);
|
Debug.Log("查询最近大屠杀响应====================================================================================: " + response);
|
||||||
//}
|
}
|
||||||
|
|
||||||
// 查询逃亡房间详情
|
// 查询逃亡房间详情
|
||||||
public async Task QueryEscapeRoomDetails()
|
public async Task QueryEscapeRoomDetails()
|
||||||
@ -1149,7 +1149,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryEscapeRoomList", "POST", body, headers);
|
||||||
Debug.Log("逃亡房间详情响应: " + response);
|
Debug.Log("逃亡房间详情响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1164,7 +1164,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""bet"": 100,
|
""bet"": 100,
|
||||||
""roomNo"": 1
|
""roomNo"": 1
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/userBet", "POST", body, headers);
|
||||||
Debug.Log("用户下注响应: " + response);
|
Debug.Log("用户下注响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1177,7 +1177,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryKill", "POST", body, headers);
|
||||||
Debug.Log("查询击杀信息响应: " + response);
|
Debug.Log("查询击杀信息响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1190,7 +1190,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
""userId"": 106,
|
""userId"": 106,
|
||||||
""escapeId"": {escapeId}
|
""escapeId"": {escapeId}
|
||||||
}}";
|
}}";
|
||||||
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
|
string response = await web.SendRequest("http://121.40.42.41:8080/snail/LatestGame511/queryUserBetResult", "POST", body, headers);
|
||||||
Debug.Log("查询用户下注结果响应: " + response);
|
Debug.Log("查询用户下注结果响应: " + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1213,7 +1213,7 @@ public class WebConnact : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// 注销监听事件,避免内存泄漏
|
// 注销监听事件,避免内存泄漏
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
selectLatest511.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,285 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
/*public class selectGameEscape512 : MonoBehaviour
|
|
||||||
{
|
|
||||||
public static selectGameEscape512 instance;
|
|
||||||
public int gameEscapeId;
|
|
||||||
public int carrySeconds;
|
|
||||||
// 定义一个事件,当 gameEscapeId 被更新时触发
|
|
||||||
public static event Action<int> OnGameEscapeIdUpdated;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
instance=this;
|
|
||||||
|
|
||||||
// 由于除登录注册外的其他方法,都需要登录后返回的token
|
|
||||||
// 因此登录不在此发送请求(同时)
|
|
||||||
// 采用监听和事件回调的方法,只有监听到登录和token返回时,才运行其他方法
|
|
||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
|
||||||
// 订阅事件,当 gameEscapeId 更新时调用 HandleGameEscapeIdUpdated
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string token; // 用于保存收到的 token
|
|
||||||
|
|
||||||
void HandleTokenReceived(string token)
|
|
||||||
{
|
|
||||||
// 使用 token
|
|
||||||
this.token = token;
|
|
||||||
Debug.Log("HandleTokenReceived监听:" + token);
|
|
||||||
StartCoroutine(GameEscapeRoutine(token)); // 启动协程,每2秒调用一次gameEscape
|
|
||||||
}
|
|
||||||
void HandleGameEscapeIdUpdated(int newGameEscapeId)
|
|
||||||
{
|
|
||||||
Debug.Log("GameEscapeId 已更新为: " + newGameEscapeId);
|
|
||||||
// 在这里添加你想要执行的逻辑
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个IEnumerator的协程
|
|
||||||
IEnumerator GameEscapeRoutine(string token)
|
|
||||||
{
|
|
||||||
while (true) // 无限循环来实现每2秒发送一次请求
|
|
||||||
{
|
|
||||||
yield return new WaitForSeconds(2f); // 每2秒暂停一次
|
|
||||||
yield return gameEscape(token); // 调用gameEscape方法
|
|
||||||
}
|
|
||||||
yield return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task gameEscape(string token)
|
|
||||||
{
|
|
||||||
// 用来给请求头赋值
|
|
||||||
string Authorization = token;
|
|
||||||
//Debug.Log("Loding(Authorization)请求头赋值" + Authorization);
|
|
||||||
|
|
||||||
// 5.1查询最近一场大屠杀
|
|
||||||
Dictionary<string, string> head51 = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "Authorization", Authorization }, // 设置授权头
|
|
||||||
};
|
|
||||||
|
|
||||||
string response51 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", head51);
|
|
||||||
Debug.Log("5.1查询最近一场大屠杀(独立)" + response51); // 查询最近一场大逃亡游戏详情:
|
|
||||||
|
|
||||||
// 解析JSON数据
|
|
||||||
string json = response51;
|
|
||||||
Response response = JsonConvert.DeserializeObject<Response>(json);
|
|
||||||
|
|
||||||
if (response != null && response.code == 200 && response.data != null)
|
|
||||||
{
|
|
||||||
gameEscapeId = response.data.gameEscapeModel.id;
|
|
||||||
//Debug.Log("解析成功,id为: " + gameEscapeId);
|
|
||||||
carrySeconds= response.data.carrySeconds;
|
|
||||||
// 触发事件,通知所有订阅者
|
|
||||||
OnGameEscapeIdUpdated?.Invoke(gameEscapeId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError("解析失败或响应错误");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
|
||||||
{
|
|
||||||
// 取消监听,避免内存泄漏
|
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class GameEscapeModel
|
|
||||||
{
|
|
||||||
public int id; // 解析游戏ID
|
|
||||||
public string gameNo; // 包括游戏编号
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class GameEscapeRoomResponseVo
|
|
||||||
{
|
|
||||||
public int escapeId; // 逃脱游戏的ID
|
|
||||||
public int roomNo; // 房间号
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class Data
|
|
||||||
{
|
|
||||||
public int carrySeconds; // 持续秒数
|
|
||||||
public GameEscapeModel gameEscapeModel; // 嵌套的GameEscapeModel对象
|
|
||||||
public List<GameEscapeRoomResponseVo> gameEscapeRoomResponseVoList; // 房间信息列表
|
|
||||||
public object gameEscapeUserModel; // 用户模型,可以保持为空或根据需要进行定义
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class Response
|
|
||||||
{
|
|
||||||
public int code; // 状态码
|
|
||||||
public string message; // 返回信息
|
|
||||||
public Data data; // 数据对象
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class selectGameEscape512 : MonoBehaviour
|
|
||||||
{
|
|
||||||
|
|
||||||
public int gameEscapeId;
|
|
||||||
public int carrySeconds;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 定义一个事件,当 gameEscapeId 被更新时触发
|
|
||||||
public static event Action<int> OnGameEscapeIdUpdated;
|
|
||||||
|
|
||||||
private string token; // 用于保存收到的 token
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
// 监听登录获取 token
|
|
||||||
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
|
|
||||||
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleTokenReceived(string token)
|
|
||||||
{
|
|
||||||
this.token = token;
|
|
||||||
Debug.Log("HandleTokenReceived监听:" + token);
|
|
||||||
StartCoroutine(GameEscapeRoutine(token)); // 启动协程,每2秒调用一次gameEscape
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleGameEscapeIdUpdated(int newGameEscapeId)
|
|
||||||
{
|
|
||||||
Debug.Log("GameEscapeId 已更新为: " + newGameEscapeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator GameEscapeRoutine(string token)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
yield return new WaitForSeconds(2f); // 每2秒暂停一次
|
|
||||||
yield return gameEscape(token); // 调用gameEscape方法
|
|
||||||
}
|
|
||||||
yield return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task gameEscape(string token)
|
|
||||||
{
|
|
||||||
// 用来给请求头赋值
|
|
||||||
string Authorization = token;
|
|
||||||
|
|
||||||
// 设置请求头
|
|
||||||
Dictionary<string, string> head51 = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "Authorization", Authorization }
|
|
||||||
};
|
|
||||||
|
|
||||||
// 发送请求并接收响应
|
|
||||||
string response51 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", head51);
|
|
||||||
Debug.Log("5.1查询最近一场大屠杀(独立)" + response51);
|
|
||||||
|
|
||||||
// 解析JSON数据为 Response 对象
|
|
||||||
Response response = JsonConvert.DeserializeObject<Response>(response51);
|
|
||||||
|
|
||||||
if (response != null && response.code == 200 && response.data != null)
|
|
||||||
{
|
|
||||||
// 保存解析后的字段
|
|
||||||
gameEscapeId = response.data.gameEscapeModel.id;
|
|
||||||
carrySeconds = response.data.carrySeconds;
|
|
||||||
|
|
||||||
// 使用其他字段
|
|
||||||
string gameNo = response.data.gameEscapeModel.gameNo;
|
|
||||||
float beansCoinAll = response.data.gameEscapeModel.beansCoinAll;
|
|
||||||
|
|
||||||
Debug.Log($"Game Escape ID: {gameEscapeId}");
|
|
||||||
Debug.Log($"Carry Seconds: {carrySeconds}");
|
|
||||||
Debug.Log($"Game No: {gameNo}");
|
|
||||||
Debug.Log($"Beans Coin All: {beansCoinAll}");
|
|
||||||
|
|
||||||
// 如果你想要处理房间列表
|
|
||||||
foreach (var room in response.data.gameEscapeRoomResponseVoList)
|
|
||||||
{
|
|
||||||
int roomNo = room.roomNo;
|
|
||||||
float roomBeansCoin = room.roomBeansCoin;
|
|
||||||
|
|
||||||
Debug.Log($"Room No: {roomNo}, Room Beans Coin: {roomBeansCoin}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 触发事件,通知所有订阅者
|
|
||||||
OnGameEscapeIdUpdated?.Invoke(gameEscapeId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError("解析失败或响应错误");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
|
||||||
{
|
|
||||||
// 取消监听,避免内存泄漏
|
|
||||||
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 数据类
|
|
||||||
[Serializable]
|
|
||||||
public class GameEscapeModel
|
|
||||||
{
|
|
||||||
public int id; // 游戏 ID
|
|
||||||
public string gameNo; // 游戏编号
|
|
||||||
public int demonMode;
|
|
||||||
public string startTime;
|
|
||||||
public string betTime;
|
|
||||||
public string countTime;
|
|
||||||
public string settleTime;
|
|
||||||
public int status;
|
|
||||||
public string roomNoKill;
|
|
||||||
public string roomNoRemain;
|
|
||||||
public float beansCoinAll;
|
|
||||||
public float beansCoinKill;
|
|
||||||
public float beansCoinRemain;
|
|
||||||
public float beansCoinFee;
|
|
||||||
public float beansCoinRank;
|
|
||||||
public float beansCoinDivide;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class GameEscapeRoomResponseVo
|
|
||||||
{
|
|
||||||
public int escapeId; // 逃脱游戏的ID
|
|
||||||
public int roomNo; // 房间号
|
|
||||||
public float roomBeansCoin; // 房间中豆币数量
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class Data
|
|
||||||
{
|
|
||||||
public int carrySeconds; // 持续秒数
|
|
||||||
public GameEscapeModel gameEscapeModel; // 嵌套的GameEscapeModel对象
|
|
||||||
public List<GameEscapeRoomResponseVo> gameEscapeRoomResponseVoList; // 房间信息列表
|
|
||||||
public object gameEscapeUserModel; // 用户模型,可以保持为空或根据需要进行定义
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class Response
|
|
||||||
{
|
|
||||||
public int code; // 状态码
|
|
||||||
public string message; // 返回信息
|
|
||||||
public Data data; // 数据对象
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b7936430f01cc8343a1e62fc2052a12b
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
Loading…
Reference in New Issue
Block a user