_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Battle_Royale/BettingBtn.cs

111 lines
3.0 KiB
C#
Raw Normal View History

2024-11-12 14:06:34 +08:00
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;//Ͷע<CDB6><D7A2>ֵ
2024-11-13 18:01:18 +08:00
public Button BetButton;//Ͷע<CDB6>İ<EFBFBD>ť
public GameObject text1;
public GameObject text2;
public GameObject text3;
public GameObject text4;
public GameObject text5;
public GameObject text6;
2024-11-12 14:06:34 +08:00
// Start is called before the first frame update
void Start()
{
BetList.SetActive(false);
NumBtn.onClick.AddListener(OnClickNumBtn);
2024-11-13 18:01:18 +08:00
BetButton.onClick.AddListener(OnClickBetBtn);
2024-11-12 14:06:34 +08:00
BetValue = 50;//Ĭ<><C4AC>50
SetBet();
}
void OnClickNumBtn()
{
BetList.SetActive(true);
}
2024-11-13 18:01:18 +08:00
void OnClickBetBtn()
{
if (HegemonTime.instance.timeNum>20)
{
switch (PlayerMovePos.instance.HouseId)
{
case 1:
if (PlayerInfo.instance.SetMoney(-BetValue))
{
text1.GetComponent<TextBox>().SetText(BetValue);
}
break;
case 2:
if (PlayerInfo.instance.SetMoney(-BetValue))
{
text2.GetComponent<TextBox>().SetText(BetValue);
}
break;
case 3:
if (PlayerInfo.instance.SetMoney(-BetValue))
{
text3.GetComponent<TextBox>().SetText(BetValue);
}
break;
case 4:
if (PlayerInfo.instance.SetMoney(-BetValue))
{
text4.GetComponent<TextBox>().SetText(BetValue);
}
break;
case 5:
if (PlayerInfo.instance.SetMoney(-BetValue))
{
text5.GetComponent<TextBox>().SetText(BetValue);
}
break;
case 6:
if (PlayerInfo.instance.SetMoney(-BetValue))
{
text6.GetComponent<TextBox>().SetText(BetValue);
}
break;
default:
Debug.Log("<22><>ѡ<EFBFBD>񷿼<EFBFBD>");
break;
}
}
else
{
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>Ͷע");
}
}
void SetBet()
2024-11-12 14:06:34 +08:00
{
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>е<EFBFBD>Button<6F><6E><EFBFBD><EFBFBD>
Button[] buttons = BetList.GetComponentsInChildren<Button>();
// <20><><EFBFBD><EFBFBD>ÿһ<C3BF><D2BB>Button<6F><6E><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>¼<EFBFBD>
foreach (Button button in buttons)
{
button.onClick.AddListener(() => {
BetText.text = button.transform.GetComponentInChildren<Text>().text;
BetValue = float.Parse(BetText.text);
BetList.SetActive(false);
});
}
}
}