2024-11-21 00:04:33 +08:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System;
|
2024-11-12 14:06:34 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2024-11-15 23:31:54 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2024-11-18 16:53:39 +08:00
|
|
|
|
using TMPro;
|
2024-11-15 23:31:54 +08:00
|
|
|
|
using Unity.VisualScripting.Antlr3.Runtime;
|
2024-11-12 14:06:34 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2024-11-20 10:24:18 +08:00
|
|
|
|
|
2024-11-12 14:06:34 +08:00
|
|
|
|
|
|
|
|
|
public class BettingBtn : MonoBehaviour
|
|
|
|
|
{
|
2024-11-18 18:52:31 +08:00
|
|
|
|
public PlayerInfo playerCoinUpdate;//<2F><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻǽ<CFBD><C7BD><EFBFBD><EFBFBD><EFBFBD>
|
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-18 16:53:39 +08:00
|
|
|
|
public TextMeshProUGUI SelfWoniuText;
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
|
|
|
|
public bool SuccessBet;//<2F>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD><C9B9><EFBFBD>ע
|
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);
|
|
|
|
|
BetValue = 50;//Ĭ<><C4AC>50
|
|
|
|
|
SetBet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnClickNumBtn()
|
|
|
|
|
{
|
|
|
|
|
BetList.SetActive(true);
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-15 23:31:54 +08:00
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class RequestData
|
|
|
|
|
{
|
|
|
|
|
public int userId;
|
|
|
|
|
public int escapeId;
|
|
|
|
|
public float bet;
|
|
|
|
|
public int roomNo;
|
|
|
|
|
}
|
|
|
|
|
public GameObject bg;
|
|
|
|
|
public async void OnClickBetBtnAsync()
|
2024-11-13 18:01:18 +08:00
|
|
|
|
{
|
2024-11-21 00:04:33 +08:00
|
|
|
|
// bg.GetComponentInChildren<AllHouseContro>().battleRoyaleGameDetails();
|
|
|
|
|
|
|
|
|
|
|
2024-11-15 23:31:54 +08:00
|
|
|
|
RequestData body = new RequestData();
|
|
|
|
|
body.escapeId = bg.GetComponentInChildren<AllHouseContro>().escapeId;
|
|
|
|
|
body.bet = BetValue;
|
|
|
|
|
body.roomNo = bg.GetComponentInChildren<AllHouseContro>().roomNo;
|
|
|
|
|
body.userId = Global.global.serverResponse.data.userId;
|
2024-11-21 00:04:33 +08:00
|
|
|
|
//Debug.Log(bg.GetComponentInChildren<AllHouseContro>().house);
|
|
|
|
|
//bg.GetComponentInChildren<AllHouseContro>().house.text.GetComponent<TextBox>().AddText(BetValue);
|
|
|
|
|
|
|
|
|
|
|
2024-11-15 23:31:54 +08:00
|
|
|
|
string response = await web.SendRequest(web.URL + "/snail/gameEscape/userBet", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
|
2024-11-21 00:04:33 +08:00
|
|
|
|
Debug.Log("<22>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2>Ӧ: " + response+"|||||"+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>escapeId"+ body.escapeId+" bet:"+ body.bet+ " roomNo:"+ body.roomNo+" userId:"+ body.userId);
|
|
|
|
|
ServerResponse513 serverResponse_513 = JsonConvert.DeserializeObject<ServerResponse513>(response);
|
|
|
|
|
if (serverResponse_513.code==200)
|
|
|
|
|
{
|
2024-11-21 17:27:26 +08:00
|
|
|
|
bg.GetComponentInChildren<AllHouseContro>().ReHouseText();//5.1.2
|
2024-11-21 00:04:33 +08:00
|
|
|
|
StartCoroutine(Tools.AnimateTextMashPro(PlayerInfo.instance.AllBetCoins, PlayerInfo.instance.AllBetCoins + BetValue, 0.5f, SelfWoniuText));//<2F><EFBFBD><DEB8><EFBFBD>ţͷ<C5A3><CDB7><EFBFBD>ı<EFBFBD>
|
|
|
|
|
PlayerInfo.instance.AllBetCoins += BetValue;
|
|
|
|
|
PlayerInfo.instance.HaveBet = true;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD><CFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
playerCoinUpdate.QueryPlayerInfo();
|
|
|
|
|
Debug.Log("-------Ͷע<CDB6>ɹ<EFBFBD>-------");
|
|
|
|
|
Promptmgr.Instance.PromptBubble(serverResponse_513.message);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Debug.Log("-------Ͷעʧ<D7A2><CAA7>-------");
|
|
|
|
|
Promptmgr.Instance.PromptBubble(serverResponse_513.message);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-18 18:52:31 +08:00
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ť================================================" + playerCoinUpdate.Money);
|
2024-11-19 17:55:35 +08:00
|
|
|
|
|
2024-11-13 18:01:18 +08:00
|
|
|
|
}
|
2024-11-15 23:31:54 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
public async void BetAgain(Action onComplete=null)
|
2024-11-18 17:42:44 +08:00
|
|
|
|
{
|
2024-11-21 00:04:33 +08:00
|
|
|
|
//bg.GetComponentInChildren<AllHouseContro>().battleRoyaleGameDetails();
|
|
|
|
|
|
|
|
|
|
|
2024-11-18 17:42:44 +08:00
|
|
|
|
RequestData body = new RequestData();
|
|
|
|
|
body.escapeId = bg.GetComponentInChildren<AllHouseContro>().escapeId;
|
2024-11-21 00:04:33 +08:00
|
|
|
|
//body.bet = PlayerInfo.instance.AllBetCoins;
|
|
|
|
|
body.bet = 0;
|
2024-11-18 17:42:44 +08:00
|
|
|
|
body.roomNo = bg.GetComponentInChildren<AllHouseContro>().roomNo;
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-18 17:42:44 +08:00
|
|
|
|
body.userId = Global.global.serverResponse.data.userId;
|
2024-11-13 18:01:18 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-18 17:42:44 +08:00
|
|
|
|
string response = await web.SendRequest(web.URL + "/snail/gameEscape/userBet", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
|
2024-11-21 00:04:33 +08:00
|
|
|
|
Debug.Log("<22>û<EFBFBD><C3BB>л<EFBFBD><D0BB><EFBFBD>ע<EFBFBD><D7A2>Ӧ: " + response + "|||||" + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>escapeId" + body.escapeId + " bet:" + body.bet + " roomNo:" + body.roomNo + " userId:" + body.userId);
|
|
|
|
|
ServerResponse513 serverResponse_513 = JsonConvert.DeserializeObject<ServerResponse513>(response);
|
|
|
|
|
if (serverResponse_513.code == 200)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Debug.Log("-------<2D>л<EFBFBD>Ͷע<CDB6>ɹ<EFBFBD>-------");
|
|
|
|
|
Promptmgr.Instance.PromptBubble(serverResponse_513.message);
|
|
|
|
|
onComplete?.Invoke();
|
2024-11-21 17:27:26 +08:00
|
|
|
|
bg.GetComponentInChildren<AllHouseContro>().ReHouseText();//5.1.2
|
2024-11-21 00:04:33 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Promptmgr.Instance.PromptBubble(serverResponse_513.message);
|
|
|
|
|
Debug.Log("-------<2D>л<EFBFBD>Ͷעʧ<D7A2><CAA7>-------");
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-18 17:42:44 +08:00
|
|
|
|
}
|
2024-11-13 18:01:18 +08:00
|
|
|
|
|
|
|
|
|
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-16 02:05:07 +08:00
|
|
|
|
public void GiveMoney(string room_id)
|
2024-11-13 21:45:48 +08:00
|
|
|
|
{
|
2024-11-19 17:55:35 +08:00
|
|
|
|
//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();
|
2024-11-13 21:45:48 +08:00
|
|
|
|
|
|
|
|
|
|
2024-11-16 02:05:07 +08:00
|
|
|
|
foreach (GameObject item in list)
|
2024-11-13 21:45:48 +08:00
|
|
|
|
{
|
2024-11-16 02:05:07 +08:00
|
|
|
|
if (item.GetComponent<TextBox>().ParentHouse.GetComponent<HouseBtn>().roomNo == int.Parse(room_id))
|
|
|
|
|
{
|
2024-11-16 05:56:57 +08:00
|
|
|
|
|
2024-11-16 16:01:27 +08:00
|
|
|
|
//item.GetComponent<TextBox>().ParentHouse.GetComponent<HouseBtn>().wn.GetComponent<wuniusj>().yingchang();
|
2024-11-16 02:05:07 +08:00
|
|
|
|
item.GetComponent<TextBox>().PlayAni();
|
2024-11-19 17:55:35 +08:00
|
|
|
|
//ControMoney(item);//<2F><>Ǯ
|
2024-11-16 02:05:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-13 21:45:48 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-18 16:53:39 +08:00
|
|
|
|
//public void GiveMoneyToPlayer()
|
|
|
|
|
//{
|
|
|
|
|
// switch (PlayerMovePos.instance.HouseId)
|
|
|
|
|
// {
|
|
|
|
|
// case 1:
|
|
|
|
|
// PlayerInfo.instance.SetMoney(text1.GetComponent<TextBox>().ReturnText()/2);
|
2024-11-13 21:45:48 +08:00
|
|
|
|
|
2024-11-18 16:53:39 +08:00
|
|
|
|
// 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
|
|
|
|
}
|