224 lines
5.9 KiB
C#
224 lines
5.9 KiB
C#
using Gameplay.Net;
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Button = UnityEngine.UI.Button;
|
|
using Image = UnityEngine.UI.Image;
|
|
using Framework;
|
|
using System.Collections;
|
|
|
|
public class UI_LogInController : UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
public Image Image_BG;
|
|
public Button Button_Play;
|
|
public TMP_Text Text_Play;
|
|
public Button Button_PlayerCentre;
|
|
public TMP_Text Text_PlayerCentre;
|
|
public Button Button_Notice;
|
|
public TMP_Text Text_Notice;
|
|
public TMP_Text Text_ManagerInfo;
|
|
public Image Image_logBG;
|
|
public Button Button_Close;
|
|
public Button Button_AccountLog;
|
|
public TMP_Text Text_AccountLog;
|
|
public TMP_InputField InputField_AL;
|
|
public TMP_InputField InputField_Pass;
|
|
public TMP_Text Text_Info;
|
|
public Button Button_AL;
|
|
public TMP_Text Text_AL;
|
|
public Button Button_PhoneLog;
|
|
public TMP_Text Text_PhoneLog;
|
|
public TMP_InputField InputField_PL;
|
|
public TMP_InputField InputField_Code;
|
|
public Button Button_GetCode;
|
|
public TMP_Text Text_GetCode;
|
|
public Button Button_PL;
|
|
public TMP_Text Text_PL;
|
|
public Button Button_Log;
|
|
public TMP_Text Text_Log;
|
|
|
|
private TMPro.TMP_InputField _Input;
|
|
private TMP_Dropdown dropdown;
|
|
bool isAgree;
|
|
private Toggle agreenToggle;
|
|
Button TapTapBtn;
|
|
public Material mBgMaterial;
|
|
public float speed = 1f;
|
|
GameObject TipsObj;
|
|
private TMP_Text IdText;
|
|
private TMP_Text versionText;
|
|
|
|
///Auto Gen End///
|
|
|
|
// Use this for initialization
|
|
public override void OnAwake()
|
|
{
|
|
//bind UI GameObj
|
|
UI_LogInBinder.GetComponents(this);
|
|
TapTapBtn = GetComponent<Button>("Image_BG/TapTapBtn");
|
|
|
|
agreenToggle = GetComponent<Toggle>("Image_BG/Image_logBG/UI_AL/Button_AccountLog/Toggle_AL");
|
|
|
|
dropdown = GameObject.Find("Image_BG/Image_logBG/UI_AL/Button_AccountLog/ALDropdown").GetComponent<TMP_Dropdown>();
|
|
dropdown.onValueChanged.AddListener(onValueChanged);
|
|
IdText = GetComponent<TMP_Text>("Image_BG/ID");
|
|
versionText = GetComponent<TMP_Text>("Image_BG/vesion");
|
|
|
|
string account = PlayerPrefs.GetString("LoginAccount", "");
|
|
InputField_Pass.text = account;
|
|
BindButton(Button_Log, OnButtonLogin);
|
|
BindButton(TapTapBtn, OnTapTapBtnOnClick);
|
|
UpadteDropdownSeverName();
|
|
|
|
BindButton("Image_BG/Button_Play", OnButtonLogin);
|
|
BindButton(Button_PL, OnButtonPhoneLogin);
|
|
BindButton("Image_BG/Image_logBG/UI_AL/Button_AccountLog/Toggle_AL/AgreeBtn", OnAgreenBtnClick);
|
|
BindButton(Button_Notice, OnNoticeClick);
|
|
RefreshAgreenToggle();
|
|
mBgMaterial = Image_BG.material;
|
|
TipsObj = FindObj("Tip");
|
|
|
|
}
|
|
|
|
private async void OnNoticeClick()
|
|
{
|
|
await UIManager.Instance.OpenWindow(UINameConst.UI_Notice);
|
|
|
|
}
|
|
|
|
private void OnTapTapBtnOnClick()
|
|
{
|
|
Actor.Instance.Login.StartLogin(NLDPB.LoginType.TapTap);
|
|
|
|
}
|
|
private void RegisterEvent()
|
|
{
|
|
EventManager.Instance.Register(EventManager.EventName.EN_UINewLoginTips, (Action<string>)OnRecvNewLoginTips);
|
|
}
|
|
private void OnRecvNewLoginTips(string obj)
|
|
{
|
|
TipsObj.SetActive(true);
|
|
Utils.CommonUtils.GetComponent<TMP_Text>(TipsObj, "label").text = obj;
|
|
|
|
IEnumerator coroutine = waitTime();
|
|
StartCoroutine(coroutine);
|
|
}
|
|
private IEnumerator waitTime()
|
|
{
|
|
yield return new WaitForSeconds(2f);
|
|
TipsObj.SetActive(false);
|
|
|
|
}
|
|
|
|
private void RefreshTapTapBtn()
|
|
{
|
|
#if SDK_TAPTAP
|
|
FindObj("taptap").SetActive(true);
|
|
#else
|
|
FindObj("taptap").SetActive(false);
|
|
#endif
|
|
|
|
}
|
|
private void Update()
|
|
{
|
|
// mBgMaterial.mainTextureOffset += new Vector2( Time.deltaTime * speed,0);
|
|
|
|
}
|
|
|
|
private void OnAgreenBtnClick()
|
|
{
|
|
isAgree = !isAgree;
|
|
RefreshAgreenToggle();
|
|
}
|
|
|
|
private void RefreshAgreenToggle()
|
|
{
|
|
agreenToggle.isOn = isAgree;
|
|
}
|
|
|
|
private async void OnButtonPhoneLogin()
|
|
{
|
|
OnRecvNewLoginTips("功能暂未开放,敬请期待");
|
|
}
|
|
|
|
public void onValueChanged(int value)
|
|
{
|
|
|
|
AppConfig.Instance.Select(value);
|
|
PlayerPrefs.SetInt("ServerIndex", value);
|
|
|
|
return;
|
|
}
|
|
private void UpadteDropdownSeverName()
|
|
{
|
|
dropdown.options.Clear();
|
|
var serverInfo = AppConfig.Instance.GetServerInfo();
|
|
if (serverInfo.Count <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
foreach (var item in serverInfo)
|
|
{
|
|
dropdown.options.Add(new TMP_Dropdown.OptionData() { text = item.name });
|
|
}
|
|
var index = PlayerPrefs.GetInt("ServerIndex", 0);
|
|
|
|
if (index >= 0 && index <= serverInfo.Count)
|
|
{
|
|
dropdown.captionText.text = serverInfo[index].name;
|
|
dropdown.value = index;
|
|
}
|
|
else
|
|
{
|
|
dropdown.captionText.text = serverInfo[0].name;
|
|
dropdown.value = 0;
|
|
}
|
|
|
|
AppConfig.Instance.Select(index);
|
|
|
|
}
|
|
private async void OnButtonLogin()
|
|
{
|
|
if(!isAgree)
|
|
{
|
|
await UIManager.Instance.OpenWindow(UINameConst.UI_LoginTips, InputField_Pass.text);
|
|
return;
|
|
}
|
|
|
|
PlayerPrefs.SetString("LoginAccount", InputField_Pass.text);
|
|
Gameplay.Net.Actor.Instance.StartLogin(NLDPB.LoginType.Phxh, InputField_Pass.text);
|
|
CloseWindow();
|
|
}
|
|
//invoke when open window
|
|
protected override void OnOpenWindow(object data = null)
|
|
{
|
|
RegisterEvent();
|
|
agreenToggle.isOn = true;
|
|
isAgree = false;
|
|
IdText.text = "uid: " + PlayerPrefs.GetString("LoginAccount", "");
|
|
RefreshTapTapBtn();
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
protected override void OnCloseWindow()
|
|
{
|
|
UnRegisterEvent();
|
|
}
|
|
private void UnRegisterEvent()
|
|
{
|
|
EventManager.Instance.Unregister(EventManager.EventName.EN_UINewLoginTips, (Action<string>)OnRecvNewLoginTips);
|
|
|
|
}
|
|
|
|
|
|
//invoke when close window
|
|
|
|
} |