312 lines
8.6 KiB
C#
312 lines
8.6 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
|
||
//11/18/10:22
|
||
// 全局类,继承自 MonoBehaviour,用于管理全局数据
|
||
public class Global : MonoBehaviour
|
||
{
|
||
public logoPanel.ServerResponse serverResponse; // 服务器响应,包含登录时或初始请求时的服务器返回数据
|
||
public ServerResponse response; // 服务器的普通响应
|
||
public static Global global; // 全局单例,方便其他地方直接访问
|
||
|
||
// Start 是 Unity 的生命周期方法,在游戏对象创建时调用
|
||
void Start()
|
||
{
|
||
global = this; // 将当前对象赋值给静态变量,实现单例模式
|
||
DontDestroyOnLoad(this); // 确保该对象在加载新场景时不会被销毁
|
||
}
|
||
|
||
// 创建请求头,使用最新的 token
|
||
public Dictionary<string, string> CreateHeaders()
|
||
{
|
||
// 如果 token 为空或未设置,输出警告信息
|
||
if (string.IsNullOrEmpty(Global.global.serverResponse.data.token))
|
||
{
|
||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||
return new Dictionary<string, string>();
|
||
}
|
||
|
||
// 返回包含授权信息的请求头字典
|
||
return new Dictionary<string, string>
|
||
{
|
||
{ "Authorization", Global.global.serverResponse.data.token }
|
||
};
|
||
}
|
||
}
|
||
//玩家信息
|
||
[Serializable]
|
||
public class UserInfomation14
|
||
{
|
||
public UserInfomation14Data data;
|
||
}
|
||
[Serializable]
|
||
public class UserInfomation14Data
|
||
{
|
||
public int userId;//id
|
||
public int userName;//用户名(电话)
|
||
public string token;
|
||
public string nickName;//昵称
|
||
public string headImg;//头像
|
||
public int gender;//性别,1男2女
|
||
public string birthday;//出生,"yyyy-MM-dd HH:mm:ss"
|
||
public float voluteCoin;//蜗壳
|
||
public float beansCoin;//蜗蛋
|
||
public float ichorCoin;//灵液
|
||
public string idCard;//=========================
|
||
public string inviteCodeMy;//=============
|
||
public string inviteCodeBind;//==========
|
||
public string bindTime;//===========
|
||
public int station;//=========
|
||
public string cuteNo;//靓号
|
||
public string menberTime;//===============
|
||
public bool isMember;
|
||
//public int cuteNo;//靓号
|
||
}
|
||
// 游戏逃亡房间响应的数据类,用于存储房间的具体信息
|
||
[Serializable]
|
||
public class GameEscapeRoomResponseVo
|
||
{
|
||
public int escapeId; // 游戏的ID
|
||
public int roomNo; // 房间编号
|
||
public float roomBeansCoin; // 房间下注欢乐豆
|
||
}
|
||
|
||
// 用户 ID 和 游戏 ID 数据类,通常用于请求体封装
|
||
[Serializable]
|
||
public class userIDgameId
|
||
{
|
||
public int userId; // 用户ID
|
||
public int escapeId; // 游戏ID
|
||
}
|
||
|
||
// 存储游戏详细数据的类
|
||
[Serializable]
|
||
public class Data
|
||
{
|
||
public int carrySeconds; // 携带时间秒数,用于计时
|
||
public List<GameEscapeRoomResponseVo> gameEscapeRoomResponseVoList; // 房间列表,存储多个房间的具体数据
|
||
public GameEscapeModel gameEscapeModel; // 游戏逃亡模型 (未完全处理)
|
||
public object gameEscapeUserModel; // 游戏逃亡用户模型 (未完全处理)
|
||
}
|
||
|
||
// 存储查询逃亡游戏信息响应的数据类
|
||
[Serializable]
|
||
public class Data514
|
||
{
|
||
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 Data515
|
||
{
|
||
public float bet; // 当前用户的下注量
|
||
public int roomNo; // 当前用户下注的房间号
|
||
public int outcome; // 游戏结果,0:没有结果,1:胜利,2:失败
|
||
public float win; // 获胜后赢得的欢乐豆
|
||
public float beansCoin; // 本局最终获得的欢乐豆
|
||
public float ichorCoin; // 本局最终获得的灵液
|
||
}
|
||
|
||
// 封装服务器响应的数据类,用于 Data515 类型的响应
|
||
[Serializable]
|
||
public class ServerResponse515 : Response
|
||
{
|
||
public Data515 data; // 响应中的具体数据
|
||
}
|
||
|
||
// 封装服务器响应的数据类,用于通用数据
|
||
[Serializable]
|
||
public class ServerResponse : Response
|
||
{
|
||
public Data data; // 响应中的具体数据
|
||
}
|
||
|
||
// 封装服务器响应的数据类,用于 Data514 类型的响应
|
||
[Serializable]
|
||
public class ServerResponse514 : Response
|
||
{
|
||
public Data514 data; // 响应中的具体数据
|
||
}
|
||
|
||
// 基本响应数据类,包含通用的响应码和提示信息
|
||
public class Response
|
||
{
|
||
public int code; // 响应状态码
|
||
public string message; // 提示信息
|
||
}
|
||
|
||
// 存储游戏逃亡模型的数据类
|
||
[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; // 分成豆币
|
||
}
|
||
//原
|
||
/*public class Global : MonoBehaviour
|
||
{
|
||
|
||
public logoPanel.ServerResponse serverResponse;
|
||
public ServerResponse response;
|
||
public static Global global ;
|
||
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
global = this;
|
||
DontDestroyOnLoad(this);
|
||
}
|
||
|
||
// 创建请求头,使用最新的 token
|
||
public Dictionary<string, string> CreateHeaders()
|
||
{
|
||
|
||
|
||
if (string.IsNullOrEmpty(Global.global.serverResponse.data.token))
|
||
{
|
||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||
return new Dictionary<string, string>();
|
||
}
|
||
|
||
return new Dictionary<string, string>
|
||
{
|
||
{ "Authorization", Global.global.serverResponse.data.token }
|
||
};
|
||
}
|
||
}
|
||
[Serializable]
|
||
public class GameEscapeRoomResponseVo
|
||
{
|
||
public int escapeId; // 游戏的ID
|
||
public int roomNo; // 房间编号
|
||
public float roomBeansCoin; // 房间下注欢乐豆
|
||
}
|
||
[Serializable]
|
||
public class userIDgameId
|
||
{
|
||
public int userId; // 用户id
|
||
public int escapeId; // 游戏id
|
||
}
|
||
|
||
|
||
[Serializable]
|
||
public class Data
|
||
{
|
||
public int carrySeconds; // 携带时间秒数
|
||
public List<GameEscapeRoomResponseVo> gameEscapeRoomResponseVoList; // 房间列表
|
||
public GameEscapeModel gameEscapeModel; // 游戏逃亡模型 (目前未处理)
|
||
public object gameEscapeUserModel; // 游戏逃亡用户模型 (目前未处理)
|
||
}
|
||
|
||
|
||
[Serializable]
|
||
public class Data514
|
||
{
|
||
public int 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 Data515
|
||
{
|
||
public float bet;//当前用户的下注
|
||
public int roomNo;//当前用户下注的房间号
|
||
public int outcome;//默认0还没结果,1胜利,2失败
|
||
public float win;//获胜后赢得多少欢乐豆
|
||
public float beansCoin;//本局最终获得多少欢乐豆
|
||
public float ichorCoin;//本局最终获得的灵液
|
||
|
||
}
|
||
|
||
[Serializable]
|
||
public class ServerResponse515 : Response
|
||
{
|
||
public Data515 data; // 数据对象
|
||
}
|
||
|
||
|
||
[Serializable]
|
||
public class ServerResponse: Response
|
||
{
|
||
public Data data; // 数据对象
|
||
}
|
||
[Serializable]
|
||
public class ServerResponse514: Response
|
||
{
|
||
public Data514 data; // 数据对象
|
||
}
|
||
|
||
public class Response
|
||
{
|
||
public int code; // 响应状态码
|
||
public string message; // 提示语
|
||
}
|
||
// 数据类
|
||
[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; // 分成豆币
|
||
}*/
|