2024-11-27 22:24:11 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Unity.VisualScripting;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
public class BetBtn : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static BetBtn instance;
|
2024-11-27 23:40:28 +08:00
|
|
|
|
public int BetHorseId;//Ͷע<CDB6><D7A2>ƥid
|
2024-11-27 22:24:11 +08:00
|
|
|
|
public GameObject BetList;
|
|
|
|
|
public Button NumBtn;
|
|
|
|
|
public Text BetText;
|
|
|
|
|
public float BetValue;//Ͷע<CDB6><D7A2>ֵ
|
|
|
|
|
public float AllBetValue;//Ͷע<CDB6><D7A2>ֵ
|
|
|
|
|
|
|
|
|
|
public Button BetButton;//Ͷע<CDB6>İ<EFBFBD>ť
|
2024-11-28 04:40:30 +08:00
|
|
|
|
public SnailKnightBet523 snailKnightBet523 = new SnailKnightBet523();
|
2024-11-27 22:24:11 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
instance = this;
|
|
|
|
|
BetList.SetActive(false);
|
|
|
|
|
NumBtn.onClick.AddListener(OnClickNumBtn);
|
2024-11-28 04:40:30 +08:00
|
|
|
|
BetButton.onClick.AddListener(BetOnClick);
|
2024-11-27 22:24:11 +08:00
|
|
|
|
BetValue = 50;//Ĭ<><C4AC>50
|
|
|
|
|
SetBet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-28 04:40:30 +08:00
|
|
|
|
async void BetOnClick()//<2F><><EFBFBD><EFBFBD>Ͷע
|
2024-11-28 03:35:20 +08:00
|
|
|
|
{
|
2024-11-28 04:40:30 +08:00
|
|
|
|
bool flag= await snailKnightBet523.SnailKnightBet(AllManeger.instance.id, BetValue, BetHorseId);
|
|
|
|
|
if (flag)
|
2024-11-28 03:35:20 +08:00
|
|
|
|
{
|
2024-11-28 04:40:30 +08:00
|
|
|
|
foreach (HorseInfo horse in AllManeger.instance.horseInfos)
|
|
|
|
|
{
|
|
|
|
|
if (BetHorseId == horse.HorseNo)
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(Tools.AnimateText(horse.BetCoins, horse.BetCoins + BetValue, 0.5f, horse.betText));
|
|
|
|
|
horse.BetCoins += BetValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-28 07:16:11 +08:00
|
|
|
|
AllManeger.instance.GetSelfInfo();
|
2024-11-28 04:40:30 +08:00
|
|
|
|
AllManeger.instance.Fuck522();
|
2024-11-28 03:35:20 +08:00
|
|
|
|
}
|
2024-11-28 04:40:30 +08:00
|
|
|
|
|
2024-11-28 03:35:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-27 22:24:11 +08:00
|
|
|
|
void OnClickNumBtn()
|
|
|
|
|
{
|
2024-11-30 17:28:53 +08:00
|
|
|
|
if (BetList.activeInHierarchy)
|
|
|
|
|
{
|
|
|
|
|
BetList.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BetList.SetActive(true);
|
|
|
|
|
}
|
2024-11-27 22:24:11 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void SetBet()
|
|
|
|
|
{
|
|
|
|
|
// <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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|