using Assets.MyGame.Scripts.Net.WebResponses.ChineseChess; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class UIChineseChessCreateRoom : SubUIBase { public Button btn_CreateRoom; public Button btn_CopyPassword; public Toggle toggle_Red; public Toggle toggle_Black; public TMP_InputField tMPInput_Password; int gameType=2; // Start is called before the first frame update public override void Awake() { base.Awake(); //btn_CreateRoom.onClick.AddListener(() => //{ // WebSocketSendList.CreateRoomChineseChess(new Assets.MyGame.Scripts.Net.WebResponses.ChineseChess.ChineseChessGameClassList.CreateRoomParam // { // gameType=1, // }); //}); btn_CopyPassword.onClick.AddListener(() => { ClipboardUtility.SetText(tMPInput_Password.text); }); toggle_Black.onValueChanged.AddListener((a) => { gameType = 1; }); toggle_Red.onValueChanged.AddListener((a) => { gameType = 2; }); tMPInput_Password.onValueChanged.AddListener((a) => { if (a[a.Length-1]>57|| a[a.Length - 1]<48) { tMPInput_Password.text = a.Substring(0,a.Length - 1); } if (a.Length>6) { tMPInput_Password.text=a.Substring(0,6); } }); } protected override void OnShow(object args = null) { base.OnShow(args); tMPInput_Password.text=""; if (args != null) { var v = (ChineseChessGameClassList.ChessGameRoom)args; btn_CreateRoom.onClick.RemoveAllListeners(); btn_CreateRoom.onClick.AddListener(() => { if (tMPInput_Password.text.Length != 6) { UIManager.Instance.ShowBoardError("密码格式不正确"); return; } // 4.4 重新进入该房间:解除"已退出房间"的推送过滤 (uIManager.parentUIBase as ChineseChessMainPanel)?.MarkJoiningRoom(v.roomId); WebSocketSendList.CreateRoomChineseChess(new Assets.MyGame.Scripts.Net.WebResponses.ChineseChess.ChineseChessGameClassList.CreateRoomParam { gameType = gameType, gold = 1000, password = tMPInput_Password.text, roomId = v.roomId, userId = GameManager.Instance.user.BaseInfo.number }); //UIManager.Instance.ShowTiShi($"确定要创建房间吗?\n阵营:{(gameType == 2 ? "红方" : "黑方")}", () => //{ //}); }); } TiShi.SetActive(false); } public GameObject TiShi; public Button btn_VIP; public void ShowTiShi() { TiShi.SetActive(true); btn_VIP.onClick.AddListener(() =>{ uIManager.Get(UIPanel.HomeMainPanel)?.uIManager.ShowAsync(UIPanel.ShopPanel, () => { uIManager.Close(UIPanel.MainGamePanelZGXQ); }); }); } }