using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class BettingBtn : MonoBehaviour { public GameObject BetList; public Button NumBtn; public Text BetText; public float BetValue;//投注的值 public Button BetButton;//投注的按钮 public GameObject text1; public GameObject text2; public GameObject text3; public GameObject text4; public GameObject text5; public GameObject text6; // Start is called before the first frame update void Start() { BetList.SetActive(false); NumBtn.onClick.AddListener(OnClickNumBtn); BetButton.onClick.AddListener(OnClickBetBtn); BetValue = 50;//默认50 SetBet(); } void OnClickNumBtn() { BetList.SetActive(true); } void OnClickBetBtn() { if (HegemonTime.instance.timeNum>20) { switch (PlayerMovePos.instance.HouseId) { case 1: if (PlayerInfo.instance.SetMoney(-BetValue)) { text1.GetComponent().SetText(BetValue); } break; case 2: if (PlayerInfo.instance.SetMoney(-BetValue)) { text2.GetComponent().SetText(BetValue); } break; case 3: if (PlayerInfo.instance.SetMoney(-BetValue)) { text3.GetComponent().SetText(BetValue); } break; case 4: if (PlayerInfo.instance.SetMoney(-BetValue)) { text4.GetComponent().SetText(BetValue); } break; case 5: if (PlayerInfo.instance.SetMoney(-BetValue)) { text5.GetComponent().SetText(BetValue); } break; case 6: if (PlayerInfo.instance.SetMoney(-BetValue)) { text6.GetComponent().SetText(BetValue); } break; default: Debug.Log("请选择房间"); break; } } else { Debug.Log("现在无法投注"); } } void SetBet() { // 获取所有的Button组件 Button[] buttons = BetList.GetComponentsInChildren