88 lines
2.6 KiB
C#
88 lines
2.6 KiB
C#
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=1;
|
|
// 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);
|
|
if (args != null)
|
|
{
|
|
var v = (ChineseChessGameClassList.ChessGameRoom)args;
|
|
btn_CreateRoom.onClick.RemoveAllListeners();
|
|
|
|
btn_CreateRoom.onClick.AddListener(() =>
|
|
{
|
|
if (tMPInput_Password.text.Length==6)
|
|
{
|
|
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.id
|
|
});
|
|
}
|
|
else
|
|
{
|
|
UIManager.Instance.ShowBoardError("密码格式不正确");
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|