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; public class BettingBtn : MonoBehaviour { public static BettingBtn instance; public GameObject BetList; public Button NumBtn; public Text BetText; public float BetValue;//投注的值 public float AllBetValue;//投注总值 public Button BetButton;//投注的按钮 public GameObject text1; public GameObject text2; public GameObject text3; public GameObject text4; public GameObject text5; public GameObject text6; public List list=new List(); public TextMeshProUGUI SelfWoniuText; // Start is called before the first frame update void Start() { instance = this; BetList.SetActive(false); NumBtn.onClick.AddListener(OnClickNumBtn); BetValue = 50;//默认50 SetBet(); } void OnClickNumBtn() { BetList.SetActive(true); } [System.Serializable] public class RequestData { public int userId; public int escapeId; public float bet; public int roomNo; } public GameObject bg; public async void OnClickBetBtnAsync() { PlayerInfo.instance.HaveBet = true; RequestData body = new RequestData(); body.escapeId = bg.GetComponentInChildren().escapeId; body.bet = BetValue; body.roomNo = bg.GetComponentInChildren().roomNo; body.userId = Global.global.serverResponse.data.userId; bg.GetComponentInChildren().house.text.GetComponent().AddText(BetValue); PlayerInfo.instance.AllBetCoins += BetValue; StartCoroutine(Tools.AnimateTextMashPro(PlayerInfo.instance.AllBetCoins, PlayerInfo.instance.AllBetCoins + BetValue, 0.5f, SelfWoniuText));//修改蜗牛头上文本 string response = await web.SendRequest(web.URL + "/snail/gameEscape/userBet", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders()); Debug.Log("用户下注响应: " + response); bg.GetComponentInChildren().battleRoyaleGameDetails(); } void SetBet() { // 获取所有的Button组件 Button[] buttons = BetList.GetComponentsInChildren