左上角金币数值随下注和结算更新

This commit is contained in:
HuangZiBo 2024-11-18 18:02:42 +08:00
parent d95ce828ba
commit ae2026586a
12 changed files with 1302 additions and 2128 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3615,7 +3615,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 540, y: -1129.5}
m_AnchoredPosition: {x: 540, y: -1249.5}
m_SizeDelta: {x: 1018, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1071890038

View File

@ -6,10 +6,281 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Windows;
using static UnityEditor.Progress;
using static UnityEngine.UIElements.UxmlAttributeDescription;
//11/18/10:10
public class AllHouseContro : MonoBehaviour
{
public PlayerInfo settlementCoinUpdate;//结算后更新左上角玩家金币数字===================================================================
// 房间按钮列表,存储所有房间的按钮对象
public List<HouseBtn> HouseBtnList = new List<HouseBtn>();
public int roomNo = -1; // 当前选中的房间编号
public int escapeId = -1; // 逃亡房间ID
public GameObject text; // 用于显示时间或其他信息的文本对象
public GameObject detailsText; // 显示游戏详情的文本对象
public HouseBtn house; // 当前操作的房间对象
public List<GameObject> bossobj; // 存储Boss相关的游戏对象
// Boss房间对象
public HouseBtn BoosHouse; // Boos房间这个应该是指Boss的房间
public GameObject BazhuPanel; // 霸主(可能是某个游戏角色)面板
public WarnPanel warnPanel; // 警告面板,用于显示警告信息
public List<GameObject> wonnius = new List<GameObject>(); // 存储乌尼乌斯(猜测是游戏中的一些特殊对象)
// 游戏开始时调用
async void Start()
{
battleRoyaleGameDetails(); // 调用方法查询游戏房间详情
InvokeRepeating("checkOutAllTheEscapeRoomsAsync", 2, 2); // 每隔2秒重复调用查询逃亡房间详情的方法
}
// 当对象销毁时取消定时调用
void OnDestroy()
{
CancelInvoke("checkOutAllTheEscapeRoomsAsync");
}
// 查询游戏大屠杀的详情,异步方法
public async Task battleRoyaleGameDetails() // 5.1.1
{
foreach (HouseBtn item in HouseBtnList)
{
// 移除所有按钮监听器,然后添加点击事件
item.gameObject.GetComponentInChildren<Button>().onClick.RemoveAllListeners();
item.gameObject.GetComponentInChildren<Button>().onClick.AddListener(item.OnClickBtn);
}
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head511 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求获取最近一次大屠杀的数据
string response511 = await web.SendRequest(web.URL + "/snail/gameEscape/queryLatest", "POST", "{}", head511);
Debug.Log("5.1.1查询最近一场大屠杀" + response511);
// 解析服务器返回的数据
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response511);
escapeId = Global.global.response.data.gameEscapeModel.id;
int index = 0;
foreach (GameEscapeRoomResponseVo item in Global.global.response.data.gameEscapeRoomResponseVoList)
{
// 给每个房间分配对应的逃亡ID和房间编号
HouseBtnList[index].escapeId = item.escapeId;
HouseBtnList[index].roomNo = item.roomNo;
HouseBtnList[index].roomBeansCoin = item.roomBeansCoin;
HouseBtn a = HouseBtnList[index];
HouseBtnList[index].gameObject.GetComponentInChildren<Button>().onClick.AddListener(() => {
roomNo = item.roomNo;
Debug.Log(a.gameObject.name);
house = a;
Debug.Log("=====-----" + item.roomNo.ToString());
});
index++;
}
// 重置一些游戏状态变量
is_jisha_jiesuan = false;
is_jisha = false;
}
// 定义两个布尔变量用于管理游戏的状态
public bool is_jisha = false;
public bool is_jisha_jiesuan = false;
// 查询所有逃亡房间的详细信息,异步方法
public async void checkOutAllTheEscapeRoomsAsync() // 5.1.2
{
userIDgameId body = new userIDgameId();
body.userId = Global.global.serverResponse.data.userId;
body.escapeId = escapeId;
// 发送请求查询逃亡房间列表
string response = await web.SendRequest(web.URL + "/snail/gameEscape/queryEscapeRoomList", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
Debug.Log("5.1.2查询逃亡房间详情响应: " + response);
ServerResponse serverResponse = JsonConvert.DeserializeObject<ServerResponse>(response);
int index = 0;
// 更新每个房间显示的房间豆币
foreach (var item in serverResponse.data.gameEscapeRoomResponseVoList)
{
HouseBtnList[index].text.GetComponentInChildren<TextBox>().SetText(item.roomBeansCoin);
index++;
}
// 根据服务器返回的时间状态进行不同操作
if (serverResponse.data.carrySeconds == -1)
{
detailsText.GetComponentInChildren<Text>().text = "游戏结束了";
battleRoyaleGameDetails(); // 重新查询游戏大屠杀的详情
}
else if (serverResponse.data.carrySeconds < 45)
{
ControAllDoorOpen(); // 开启所有房间的门
text.GetComponentInChildren<Text>().text = (60 - serverResponse.data.carrySeconds).ToString();
detailsText.GetComponentInChildren<Text>().text = "秒后霸主出现";
await Task.Delay(1000);
text.GetComponentInChildren<Text>().text = (60 - serverResponse.data.carrySeconds - 1).ToString();
}
else if (serverResponse.data.carrySeconds > 45 && serverResponse.data.carrySeconds < 50)
{
ControAllDoorClose(); // 关闭所有门
OpenBoosDoor(BoosHouse); // 打开Boss房间的门
text.GetComponentInChildren<Text>().text = "";
detailsText.GetComponentInChildren<Text>().text = "霸主出现了";
if (!is_jisha)
{
is_jisha = true;
warnPanel.ShowPanel(); // 显示警告面板
await Task.Delay(2000);
warnPanel.HidePanel();
// 查询被杀信息
response = await web.SendRequest(web.URL + "/snail/gameEscape/queryKill", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
ServerResponse514 serverResponse_514 = JsonConvert.DeserializeObject<ServerResponse514>(response);
// 分割字符串处理被杀房间的逻辑
string[] parts = serverResponse_514.data.roomNoKill.Split(",");
int index_ = 0;
foreach (string part in parts)
{
if (parts.Length > index_)
{
int a = 0;
foreach (HouseBtn item in HouseBtnList)
{
if (a == int.Parse(parts[index_]))
{
bossobj[index_].GetComponent<BossContro>().BossMove(int.Parse(parts[index_]));
bossobj[index_].GetComponent<PlayerMove>().room_id = parts[index_];
}
a++;
}
index_++;
}
}
}
}
else if (serverResponse.data.carrySeconds > 50)
{
CloseBoosDoor(BoosHouse); // 关闭Boss的房间门
text.GetComponentInChildren<Text>().text = "";
detailsText.GetComponentInChildren<Text>().text = "结算";
if (!is_jisha_jiesuan)
{
is_jisha_jiesuan = true;
// 查询用户下注结果
response = await web.SendRequest(web.URL + "/snail/gameEscape/queryUserBetResult", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
ServerResponse515 serverResponse_515 = JsonConvert.DeserializeObject<ServerResponse515>(response);
if (serverResponse_515.data == null)
{
Debug.Log("5.1.5:结算数据为空");
}
else
{
switch (serverResponse_515.data.outcome)
{
case 0:
Debug.Log("没有结果");
break;
case 1:
SucceePanel.instance.ShowPanel(); // 显示成功面板
Debug.Log("胜利");
BoosReturn(); // 让Boss回到初始位置
break;
case 2:
FailPanel.instance.ShowPanel(); // 显示失败面板
Debug.Log("失败");
BoosReturn(); // 让Boss回到初始位置
break;
}
settlementCoinUpdate.QueryPlayerInfo();
Debug.Log("结算后更新左上角玩家蜗蛋数量:==============================================="+settlementCoinUpdate.Money);
}
}
}
}
// Boss返回到原位
public void BoosReturn()
{
foreach (GameObject item in bossobj)
{
item.GetComponent<BossContro>().ReturnParent();
}
}
// 控制所有门打开
public void ControAllDoorOpen()
{
for (int i = 0; i < HouseBtnList.Count; i++)
{
if (!HouseBtnList[i].DoorIsOpen)
{
Tools.MoveUpOrDwon(HouseBtnList[i].door, 270);
HouseBtnList[i].DoorIsOpen = true;
}
}
}
// 控制所有门关闭
public void ControAllDoorClose()
{
for (int i = 0; i < HouseBtnList.Count; i++)
{
if (HouseBtnList[i].DoorIsOpen)
{
Tools.MoveUpOrDwon(HouseBtnList[i].door, -270);
HouseBtnList[i].DoorIsOpen = false;
}
}
}
// 打开单个门使用指定id
public void ControOneDoorOpen(int id, System.Action onComplete = null)
{
Tools.MoveUpOrDwon(HouseBtnList[id - 1].door, 270, onComplete);
HouseBtnList[id - 1].DoorIsOpen = true;
}
// 关闭单个门使用指定id
public void ControOneDoorClose(int id, System.Action onComplete = null)
{
Tools.MoveUpOrDwon(HouseBtnList[id - 1].door, -270, onComplete);
HouseBtnList[id - 1].DoorIsOpen = false;
}
// 打开Boss房间的门
public void OpenBoosDoor(HouseBtn boosHouse)
{
if (!boosHouse.DoorIsOpen)
{
Tools.MoveUpOrDwon(boosHouse.door, 270);
boosHouse.DoorIsOpen = true;
}
}
// 关闭Boss房间的门
public void CloseBoosDoor(HouseBtn boosHouse)
{
if (boosHouse.DoorIsOpen)
{
Tools.MoveUpOrDwon(boosHouse.door, -270);
boosHouse.DoorIsOpen = false;
}
}
}
//原
/*public class AllHouseContro : MonoBehaviour
{
public List<HouseBtn> HouseBtnList=new List<HouseBtn>();
public int roomNo = -1;
@ -23,14 +294,10 @@ public class AllHouseContro : MonoBehaviour
public GameObject BazhuPanel;
public WarnPanel warnPanel;
public List<GameObject> wonnius = new List<GameObject>();
public Allother allother;//¿ØÖÆÆäËûÎÏÅ£
public bool HaveallotherMove;
// Start is called before the first frame update
async void Start()
{
battleRoyaleGameDetails();
InvokeRepeating("checkOutAllTheEscapeRoomsAsync", 2,2);
}
void OnDestroy()
@ -39,25 +306,22 @@ public class AllHouseContro : MonoBehaviour
}
public async Task battleRoyaleGameDetails()//5.1.1
{
foreach (HouseBtn item in HouseBtnList)
{
{
item.gameObject.GetComponentInChildren<Button>().onClick.RemoveAllListeners();
item.gameObject.GetComponentInChildren<Button>().onClick.AddListener(item.OnClickBtn);
//item.wn.GetComponent<wuniusj>().show();
// item.wn.GetComponent<wuniusj>().show();
}
Dictionary<string, string> head511 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
string response511 = await web.SendRequest(web.URL + "/snail/gameEscape/queryLatest", "POST", "{}", head511);
Debug.Log("5.1.1查询最近一场大屠杀" + response511);
// 解析服务器返回的数据
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response511);
escapeId = Global.global.response.data.gameEscapeModel.id;
int index = 0;
foreach (GameEscapeRoomResponseVo item in Global.global.response.data.gameEscapeRoomResponseVoList)
{
@ -104,19 +368,12 @@ public class AllHouseContro : MonoBehaviour
}
else if (serverResponse.data.carrySeconds < 45){
ControAllDoorOpen();
text.GetComponentInChildren<Text>().text = (45 - serverResponse.data.carrySeconds).ToString();
text.GetComponentInChildren<Text>().text = (60 - serverResponse.data.carrySeconds).ToString();
detailsText.GetComponentInChildren<Text>().text = "秒后霸主出现";
await Task.Delay(1000);
text.GetComponentInChildren<Text>().text = (45 - serverResponse.data.carrySeconds - 1).ToString();
text.GetComponentInChildren<Text>().text = (60 - serverResponse.data.carrySeconds - 1).ToString();
if (!HaveallotherMove)
{
StartCoroutine(allother.WoniuToMove());
HaveallotherMove = true;
//ÆäËûÎÏÅ£½øÁý×Ó
}
}
else if (serverResponse.data.carrySeconds > 45 && serverResponse.data.carrySeconds < 50)
{
@ -128,7 +385,7 @@ public class AllHouseContro : MonoBehaviour
is_jisha = true;
warnPanel.ShowPanel();
await Task.Delay(3000);
await Task.Delay(2000);
warnPanel.HidePanel();
response = await web.SendRequest(web.URL + "/snail/gameEscape/queryKill", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
@ -166,12 +423,7 @@ public class AllHouseContro : MonoBehaviour
text.GetComponentInChildren<Text>().text = "";
detailsText.GetComponentInChildren<Text>().text = "结算";
PlayerInfo.instance.AllBetCoins = 0;//Ͷע¹é0
PlayerInfo.instance.SelfWoniuText.text= PlayerInfo.instance.AllBetCoins.ToString();
PlayerInfo.instance.HaveBet=false;
HaveallotherMove=false;
if (!is_jisha_jiesuan)
{
is_jisha_jiesuan = true;
@ -274,4 +526,4 @@ public class AllHouseContro : MonoBehaviour
}
}
}*/

View File

@ -1,35 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class Allother : MonoBehaviour
{
public List<otherWoniu> otherWonius;
// Start is called before the first frame update
void Start()
{
//ControWoniuToMove();
//StartCoroutine(WoniuToMove());
}
public IEnumerator WoniuToMove()
{
foreach (otherWoniu item in otherWonius)
{
yield return new WaitForSeconds(1);
item.OtherWoniuMove();
}
}
public async void ControWoniuToMove()
{
foreach (otherWoniu item in otherWonius)
{
await Task.Delay(1000);
item.OtherWoniuMove();
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fafd91fc9fb41634bb76aef9127888d7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,15 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using TMPro;
using Unity.VisualScripting.Antlr3.Runtime;
using UnityEngine;
using UnityEngine.UI;
using static BettingBtn;
using static UnityEditor.PlayerSettings;
//using static UnityEditor.PlayerSettings;
public class BettingBtn : MonoBehaviour
{
public PlayerInfo playerCoinUpdate;//用于每次下注后更新左上角金币数
public static BettingBtn instance;
public GameObject BetList;
public Button NumBtn;
@ -29,7 +30,6 @@ public class BettingBtn : MonoBehaviour
public List<GameObject> list=new List<GameObject>();
public TextMeshProUGUI SelfWoniuText;
// Start is called before the first frame update
void Start()
{
@ -43,7 +43,8 @@ public class BettingBtn : MonoBehaviour
void OnClickNumBtn()
{
BetList.SetActive(true);
//playerCoinUpdate.QueryPlayerInfo();
//Debug.Log("点击了下注按钮================================================"+playerCoinUpdate.Money);
}
[System.Serializable]
public class RequestData
@ -56,33 +57,22 @@ public class BettingBtn : MonoBehaviour
public GameObject bg;
public async void OnClickBetBtnAsync()
{
PlayerInfo.instance.HaveBet = true;
RequestData body = new RequestData();
body.escapeId = bg.GetComponentInChildren<AllHouseContro>().escapeId;
body.bet = BetValue;
body.roomNo = bg.GetComponentInChildren<AllHouseContro>().roomNo;
body.userId = Global.global.serverResponse.data.userId;
bg.GetComponentInChildren<AllHouseContro>().house.text.GetComponent<TextBox>().AddText(BetValue);
PlayerInfo.instance.AllBetCoins += BetValue;
StartCoroutine(Tools.AnimateTextMashPro(PlayerInfo.instance.AllBetCoins, PlayerInfo.instance.AllBetCoins + BetValue, 0.5f, SelfWoniuText));//修改蜗牛头上文本
bg.GetComponentInChildren<AllHouseContro>().house.text.GetComponentInChildren< TextBox >().AddText(BetValue);
string response = await web.SendRequest(web.URL + "/snail/gameEscape/userBet", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
Debug.Log("Óû§ÏÂ×¢ÏìÓ¦: " + response);
bg.GetComponentInChildren<AllHouseContro>().battleRoyaleGameDetails();
//调用玩家信息,更新左上角蜗蛋数量
playerCoinUpdate.QueryPlayerInfo();
Debug.Log("点击了下注按钮================================================" + playerCoinUpdate.Money);
}
public async void BetAgain()
{
RequestData body = new RequestData();
body.escapeId = bg.GetComponentInChildren<AllHouseContro>().escapeId;
body.bet = PlayerInfo.instance.AllBetCoins;
body.roomNo = bg.GetComponentInChildren<AllHouseContro>().roomNo;
body.userId = Global.global.serverResponse.data.userId;
string response = await web.SendRequest(web.URL + "/snail/gameEscape/userBet", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
Debug.Log("用户下注响应: " + response);
bg.GetComponentInChildren<AllHouseContro>().battleRoyaleGameDetails();
}
void SetBet()
{
@ -113,7 +103,7 @@ public class BettingBtn : MonoBehaviour
//item.GetComponent<TextBox>().ParentHouse.GetComponent<HouseBtn>().wn.GetComponent<wuniusj>().yingchang();
item.GetComponent<TextBox>().PlayAni();
ControMoney(item);//分钱
ControMoney(item);
}
@ -141,32 +131,32 @@ public class BettingBtn : MonoBehaviour
}
}
//public void GiveMoneyToPlayer()
//{
// switch (PlayerMovePos.instance.HouseId)
// {
// case 1:
// PlayerInfo.instance.SetMoney(text1.GetComponent<TextBox>().ReturnText()/2);
public void GiveMoneyToPlayer()
{
switch (PlayerMovePos.instance.HouseId)
{
case 1:
PlayerInfo.instance.SetMoney(text1.GetComponent<TextBox>().ReturnText()/2);
// break;
// case 2:
// PlayerInfo.instance.SetMoney(text2.GetComponent<TextBox>().ReturnText()/2);
// break;
// case 3:
// PlayerInfo.instance.SetMoney(text3.GetComponent<TextBox>().ReturnText() / 2);
// break;
// case 4:
// PlayerInfo.instance.SetMoney(text4.GetComponent<TextBox>().ReturnText()/2);
// break;
// case 5:
// PlayerInfo.instance.SetMoney(text5.GetComponent<TextBox>().ReturnText() / 2);
// break;
// case 6:
// PlayerInfo.instance.SetMoney(text6.GetComponent<TextBox>().ReturnText() / 2);
// break;
// default:
// Debug.Log("未选择房间");
// break;
// }
//}
break;
case 2:
PlayerInfo.instance.SetMoney(text2.GetComponent<TextBox>().ReturnText()/2);
break;
case 3:
PlayerInfo.instance.SetMoney(text3.GetComponent<TextBox>().ReturnText() / 2);
break;
case 4:
PlayerInfo.instance.SetMoney(text4.GetComponent<TextBox>().ReturnText()/2);
break;
case 5:
PlayerInfo.instance.SetMoney(text5.GetComponent<TextBox>().ReturnText() / 2);
break;
case 6:
PlayerInfo.instance.SetMoney(text6.GetComponent<TextBox>().ReturnText() / 2);
break;
default:
Debug.Log("未选择房间");
break;
}
}
}

View File

@ -7,7 +7,7 @@ public class EggNum : MonoBehaviour
{
public Text eggNumText;
public static EggNum instance;
// Start is called before the first frame update
void Awake()
{
instance = this;

View File

@ -9,7 +9,6 @@ public class FailPanel : BasePanel
public GameObject moveObject;
public static FailPanel instance;
public GameObject bg;
public PlayerMovePos woniuMovePos;
public override void Start()
{
instance = this;
@ -27,7 +26,7 @@ public class FailPanel : BasePanel
public override void HidePanel()
{
base.HidePanel();
woniuMovePos.IsReturn = true;
PlayerMovePos.instance.IsReturn = true;
//BossContro.instance.ReturnParent();
MaskContro.instance.SetMask(false);
//都返回原来的位置

View File

@ -17,7 +17,6 @@ public class HouseBtn : MonoBehaviour
public GameObject wn;
//public selectLatest511.GameEscapeRoomResponseVo gameEscapeRoomResponseVo;
public bool DoorIsOpen;
public PlayerMovePos woniuMovePos;
// Start is called before the first frame update
void Start()
{
@ -36,13 +35,10 @@ public class HouseBtn : MonoBehaviour
{
Debug.Log("¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ªÑ¡Ôñ·¿¼ä¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª");
transform.GetComponent<PlayerMove>().StartMove();
woniuMovePos.HadChoise = true;
}
if (PlayerInfo.instance.HaveBet)
{
BettingBtn.instance.BetAgain();//再次投注,换房子
PlayerMovePos.instance.HadChoise = true;
}
}
}

View File

@ -1,16 +1,81 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using System;
public class PlayerInfo : MonoBehaviour
{
public static PlayerInfo instance;
public static UserInfomation14 userInfomation14;
public float Money;
public int AllBetCoins;//总共下注蛋
// Start is called before the first frame update
void Start()
{
instance = this;
EggNum.instance.eggNumText.text = Money.ToString();
QueryPlayerInfo();
}
public bool SetMoney(float add)
{
//Money = userInfomation14.data.beansCoin;
if (Money + add >= 0)
{
float start = Money;
Money += add;
EggNum.instance.SetEggNumText(start);
return true;
}
Debug.Log("钱不够");
return false;
}
// Update is called once per frame
void Update()
{
if (userInfomation14 != null)
{
Money = userInfomation14.data.beansCoin;
EggNum.instance.eggNumText.text = Money.ToString();
}
}
// 查询玩家信息
public async Task QueryPlayerInfo() // 5.1.1
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head14 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步查询玩家信息
string response14 = await web.SendRequest(web.URL + "/snail/user/queryUserInfo", "POST", "{}", head14);
Debug.Log("1.4查询玩家信息" + response14);
userInfomation14 = JsonConvert.DeserializeObject<UserInfomation14>(response14);
Debug.Log("玩家剩余蜗蛋:"+userInfomation14.data.beansCoin);
//Money = userInfomation14.beansCoin;
// 解析服务器返回的数据
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response14);
// 不需要返回值,只需表示异步操作完成
await Task.CompletedTask; // 或者直接返回,不使用 await
}
}
//原
/*public class PlayerInfo : MonoBehaviour
{
public static PlayerInfo instance;
public float Money = 1000;
public float AllBetCoins;//总共下注蛋
public TextMeshProUGUI SelfWoniuText;//蜗牛下注显示文本
public bool HaveBet;//是否已经下注过
public int AllBetCoins;//总共下注蛋
// Start is called before the first frame update
void Start()
{
@ -37,4 +102,4 @@ public class PlayerInfo : MonoBehaviour
{
}
}
}*/

View File

@ -3,7 +3,180 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//11/18/1022
// 全局类,继承自 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;
@ -135,5 +308,4 @@ public class GameEscapeModel
public float beansCoinFee; // 手续费
public float beansCoinRank; // 排名奖励豆币
public float beansCoinDivide; // 分成豆币
}
}*/

View File

@ -39,9 +39,6 @@ public class logoPanel : MonoBehaviour
public delegate void TokenReceivedDelegate(string token);
public static event TokenReceivedDelegate OnTokenReceived;
private bool isOpenYzm = true;
private bool isOpenPwd = false;
void Start()
{
yzmBtn.onClick.AddListener(OnClickYzmBtn);
@ -93,7 +90,7 @@ public class logoPanel : MonoBehaviour
};
//loginbody body = new loginbody
//{
// userName = "15151658596",
// userName = "541236987",
// password = "123456",
// verifyCode = 111111
//};
@ -123,30 +120,18 @@ public class logoPanel : MonoBehaviour
private void OnClickYzmBtn()
{
if(isOpenYzm)
{
return;
}
pwdBtn.transform.position -= new Vector3(0f, 26.4f, 0f);
yzmBtn.transform.position += new Vector3(0f, 26.4f, 0f);
yzm.gameObject.SetActive(true);
mm.gameObject.SetActive(false);
isOpenYzm = true;
isOpenPwd = false;
}
private void OnClickPwdBtn()
{
if (isOpenPwd)
{
return;
}
pwdBtn.transform.position += new Vector3(0f, 26.4f, 0f);
yzmBtn.transform.position -= new Vector3(0f, 26.4f, 0f);
yzm.gameObject.SetActive(false);
mm.gameObject.SetActive(true);
isOpenPwd = true;
isOpenYzm = false;
}
// ·þÎñÆ÷·µ»ØµÄÊý¾Ý½á¹¹