2024-11-12 14:06:34 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class BettingBtn : MonoBehaviour
|
|
|
|
|
{
|
2024-11-13 21:45:48 +08:00
|
|
|
|
public static BettingBtn instance;
|
2024-11-12 14:06:34 +08:00
|
|
|
|
public GameObject BetList;
|
|
|
|
|
public Button NumBtn;
|
|
|
|
|
public Text BetText;
|
|
|
|
|
public float BetValue;//Ͷע<CDB6><D7A2>ֵ
|
2024-11-13 21:45:48 +08:00
|
|
|
|
public float AllBetValue;//Ͷע<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-13 21:45:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<GameObject> list=new List<GameObject>();
|
2024-11-12 14:06:34 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2024-11-13 21:45:48 +08:00
|
|
|
|
instance = this;
|
2024-11-12 14:06:34 +08:00
|
|
|
|
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);
|
2024-11-13 21:45:48 +08:00
|
|
|
|
AllBetValue += BetValue;
|
|
|
|
|
|
2024-11-13 18:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (PlayerInfo.instance.SetMoney(-BetValue))
|
|
|
|
|
{
|
|
|
|
|
text2.GetComponent<TextBox>().SetText(BetValue);
|
2024-11-13 21:45:48 +08:00
|
|
|
|
AllBetValue += BetValue;
|
2024-11-13 18:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (PlayerInfo.instance.SetMoney(-BetValue))
|
|
|
|
|
{
|
|
|
|
|
text3.GetComponent<TextBox>().SetText(BetValue);
|
2024-11-13 21:45:48 +08:00
|
|
|
|
AllBetValue += BetValue;
|
2024-11-13 18:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if (PlayerInfo.instance.SetMoney(-BetValue))
|
|
|
|
|
{
|
|
|
|
|
text4.GetComponent<TextBox>().SetText(BetValue);
|
2024-11-13 21:45:48 +08:00
|
|
|
|
AllBetValue += BetValue;
|
2024-11-13 18:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
if (PlayerInfo.instance.SetMoney(-BetValue))
|
|
|
|
|
{
|
|
|
|
|
text5.GetComponent<TextBox>().SetText(BetValue);
|
2024-11-13 21:45:48 +08:00
|
|
|
|
AllBetValue += BetValue;
|
2024-11-13 18:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
if (PlayerInfo.instance.SetMoney(-BetValue))
|
|
|
|
|
{
|
|
|
|
|
text6.GetComponent<TextBox>().SetText(BetValue);
|
2024-11-13 21:45:48 +08:00
|
|
|
|
AllBetValue += BetValue;
|
2024-11-13 18:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-13 21:45:48 +08:00
|
|
|
|
public void GiveMoney()
|
|
|
|
|
{
|
|
|
|
|
float AllMoney = text1.GetComponent<TextBox>().ReturnText() + text2.GetComponent<TextBox>().ReturnText() + text3.GetComponent<TextBox>().ReturnText()
|
|
|
|
|
+ text4.GetComponent<TextBox>().ReturnText() + text5.GetComponent<TextBox>().ReturnText() + text6.GetComponent<TextBox>().ReturnText();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (BossContro.instance.HouseId)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
text1.GetComponent<TextBox>().PlayAni();
|
|
|
|
|
ControMoney(text1);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
text2.GetComponent<TextBox>().PlayAni();
|
|
|
|
|
ControMoney(text2);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
text3.GetComponent<TextBox>().PlayAni();
|
|
|
|
|
ControMoney(text3);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
text4.GetComponent<TextBox>().PlayAni();
|
|
|
|
|
ControMoney(text4);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
text5.GetComponent<TextBox>().PlayAni();
|
|
|
|
|
ControMoney(text5);
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
text6.GetComponent<TextBox>().PlayAni();
|
|
|
|
|
ControMoney(text6);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ControMoney(GameObject text)
|
|
|
|
|
{
|
|
|
|
|
float giveMoney= text.GetComponent<TextBox>().ReturnText();
|
|
|
|
|
text.GetComponent<TextBox>().SetText(-giveMoney);
|
|
|
|
|
|
|
|
|
|
float AllMoney = text1.GetComponent<TextBox>().ReturnText() + text2.GetComponent<TextBox>().ReturnText() + text3.GetComponent<TextBox>().ReturnText()
|
|
|
|
|
+ text4.GetComponent<TextBox>().ReturnText() + text5.GetComponent<TextBox>().ReturnText() + text6.GetComponent<TextBox>().ReturnText();
|
|
|
|
|
|
|
|
|
|
for (int i=0;i<list.Count;i++)
|
|
|
|
|
{
|
|
|
|
|
if (list[i]==text)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
list[i].GetComponent<TextBox>().SetText(giveMoney*(list[i].GetComponent<TextBox>().ReturnText()/AllMoney));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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("δѡ<CEB4><EFBFBD>");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-12 14:06:34 +08:00
|
|
|
|
}
|