62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using Assets.Scripts;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
class GameRoomPassword : MonoBehaviour
|
|
{
|
|
public GameObject enterBtn;
|
|
public GameObject backBtn;
|
|
public InputField passwordInput;
|
|
|
|
public GameRoomListController manager;
|
|
|
|
public string Password { get; set; }
|
|
|
|
private void Start()
|
|
{
|
|
passwordInput.onValueChanged.AddListener((e) =>
|
|
{
|
|
Password = e;
|
|
});
|
|
UIManager.AddEvent(enterBtn, EventTriggerType.PointerClick, ConfirmClick); //确定
|
|
UIManager.AddEvent(backBtn, EventTriggerType.PointerClick, CancelClick); //取消
|
|
}
|
|
|
|
private void Refresh()
|
|
{
|
|
passwordInput.text = "";
|
|
}
|
|
|
|
private void ConfirmClick(BaseEventData baseEventData)
|
|
{
|
|
if (string.IsNullOrEmpty(Password))
|
|
{
|
|
Utils.showToast(gameObject, App.GetLocalString("room password can not be empty"));
|
|
return;
|
|
}
|
|
var room = manager.GetCurrentRoom();
|
|
if (room != null && !room.Password.Equals(Password))
|
|
{
|
|
Utils.showToast(gameObject, App.GetLocalString("Wrong password"));
|
|
return;
|
|
}
|
|
//var RoomId = manager.GetRoomId();
|
|
//var result = await ConfigHelper.GameRoomApi.ConfirmRoomPwd(RoomId, Password);
|
|
//if (!result.result)
|
|
//{
|
|
// Utils.showToast(gameObject, result.errMsg);
|
|
// return;
|
|
//}
|
|
Refresh();
|
|
gameObject.SetActive(false);
|
|
manager.ShowDownLoadConfirm();
|
|
}
|
|
private void CancelClick(BaseEventData baseEventData)
|
|
{
|
|
Refresh();
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|