This commit is contained in:
GL 2024-11-18 18:52:31 +08:00
parent d95ce828ba
commit fa51151185
5 changed files with 71 additions and 4 deletions

View File

@ -1777,6 +1777,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 06037c1fbc8038e4eb2bf05d1c29291e, type: 3}
m_Name:
m_EditorClassIdentifier:
settlementCoinUpdate: {fileID: 177818109}
HouseBtnList:
- {fileID: 898215879}
- {fileID: 2143530050}
@ -8678,6 +8679,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4fb563e68ba8d9747a0dc8bd431d8495, type: 3}
m_Name:
m_EditorClassIdentifier:
playerCoinUpdate: {fileID: 177818109}
BetList: {fileID: 1737087529}
NumBtn: {fileID: 1954526986}
BetText: {fileID: 251123273}

View File

@ -11,6 +11,7 @@ using static UnityEngine.UIElements.UxmlAttributeDescription;
public class AllHouseContro : MonoBehaviour
{
public PlayerInfo settlementCoinUpdate;//结算后更新左上角玩家金币数字===================================================================
public List<HouseBtn> HouseBtnList=new List<HouseBtn>();
public int roomNo = -1;
public int escapeId = -1;
@ -202,7 +203,8 @@ public class AllHouseContro : MonoBehaviour
BoosReturn();
break;
}
settlementCoinUpdate.QueryPlayerInfo();
Debug.Log("结算后更新左上角玩家蜗蛋数量:===============================================" + settlementCoinUpdate.Money);
}
}
}

View File

@ -10,6 +10,7 @@ using static UnityEditor.PlayerSettings;
public class BettingBtn : MonoBehaviour
{
public PlayerInfo playerCoinUpdate;//用于每次下注后更新左上角金币数
public static BettingBtn instance;
public GameObject BetList;
public Button NumBtn;
@ -68,6 +69,10 @@ public class BettingBtn : MonoBehaviour
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()

View File

@ -1,12 +1,13 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using System.Threading.Tasks;
public class PlayerInfo : MonoBehaviour
{
public static PlayerInfo instance;
public static UserInfomation14 userInfomation14;
public float Money = 1000;
public float AllBetCoins;//总共下注蛋
public TextMeshProUGUI SelfWoniuText;//蜗牛下注显示文本
@ -16,6 +17,7 @@ public class PlayerInfo : MonoBehaviour
{
instance = this;
EggNum.instance.eggNumText.text=Money.ToString();
QueryPlayerInfo();
}
public bool SetMoney(float add)
@ -35,6 +37,33 @@ public class PlayerInfo : MonoBehaviour
// 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
}
}

View File

@ -137,3 +137,32 @@ public class GameEscapeModel
public float beansCoinDivide; // 分成豆币
}
//玩家信息
[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;//靓号
}