//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Saturday, September 02, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using TableConfig;
|
using System.Linq;
|
|
namespace Snxxz.UI
|
{
|
|
public class LoginWin : Window
|
{
|
private string m_ServerIP = "mobile.173on.com";
|
private int m_Port = 9090;
|
private int m_GamePort = 19006;
|
|
[SerializeField] Image m_Logo;
|
[SerializeField] UIAlphaTween m_AlphaTween;
|
[SerializeField] RectTransform m_WaitServerList;
|
[SerializeField] RectTransform m_ContainerEnterGame;
|
[SerializeField] RectTransform m_ContainerAccount;
|
[SerializeField] Image m_ServerState;
|
[SerializeField] Text m_ServerStateDescription;
|
[SerializeField] Text m_ServerName;
|
[SerializeField] protected InputField m_Account;
|
[SerializeField] Button m_EnterGame;
|
[SerializeField] Button m_ServerSelect;
|
[SerializeField] Button m_SwitchAccount;
|
[SerializeField] Button m_Notice;
|
[SerializeField] RectTransform m_BanHao;
|
|
LoginModel model { get { return ModelCenter.Instance.GetModel<LoginModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
|
}
|
|
protected override void AddListeners()
|
{
|
m_EnterGame.AddListener(EnterGame);
|
m_ServerSelect.AddListener(OpenServerListWin);
|
if (m_SwitchAccount != null)
|
{
|
m_SwitchAccount.AddListener(SwitchAccount);
|
}
|
|
m_Notice.AddListener(VeiwNotice);
|
}
|
|
protected override void OnPreOpen()
|
{
|
m_BanHao.gameObject.SetActive(Application.platform == RuntimePlatform.WindowsEditor || VersionUtility.Instance.IsMaoErGame());
|
var sprite = Resources.Load<Sprite>("UI/Sprites/TB_DL_Logo");
|
m_Logo.overrideSprite = sprite;
|
m_Logo.SetNativeSize();
|
m_Logo.rectTransform.anchoredPosition = VersionConfig.Get().logoPosition;
|
m_Notice.gameObject.SetActive(GameNotice.HasNotice());
|
|
m_AlphaTween.SetStartState();
|
if (m_SwitchAccount != null)
|
{
|
m_SwitchAccount.gameObject.SetActive(VersionConfig.Get().versionAuthority == VersionAuthority.Release && !VersionConfig.Get().isBanShu);
|
}
|
|
m_WaitServerList.gameObject.SetActive(!ServerListCenter.Instance.serverListGot);
|
m_ContainerEnterGame.gameObject.SetActive(ServerListCenter.Instance.serverListGot);
|
m_ContainerAccount.gameObject.SetActive(ServerListCenter.Instance.serverListGot
|
&& (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest || VersionConfig.Get().isBanShu));
|
|
if (ServerListCenter.Instance.serverListGot)
|
{
|
ChangeServerInfo(ServerListCenter.Instance.currentServer);
|
}
|
|
ChangeUserInfo(model.localSaveAccountName);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
ServerListCenter.Instance.serverSelectEvent += OnServerChange;
|
ServerListCenter.Instance.onServerListRefreshEvent += OnServerListRefresh;
|
}
|
|
protected override void OnPreClose()
|
{
|
|
}
|
|
protected override void OnAfterClose()
|
{
|
ServerListCenter.Instance.serverSelectEvent -= OnServerChange;
|
ServerListCenter.Instance.onServerListRefreshEvent -= OnServerListRefresh;
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
|
m_AlphaTween.Play();
|
}
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
windowInfo.raycastTarget = true;
|
}
|
#endregion
|
|
private void ChangeUserInfo(string user)
|
{
|
m_Account.text = user;
|
}
|
|
private void ChangeServerInfo(ServerData _serverData)
|
{
|
m_ServerName.text = _serverData.name;
|
m_ServerIP = _serverData.region_domain;
|
m_Port = _serverData.login_port;
|
m_GamePort = _serverData.game_port;
|
|
switch ((ServerState)_serverData.running_status)
|
{
|
case ServerState.Maintain:
|
case ServerState.Predicted:
|
m_ServerState.SetSprite("XT_FWQ_TB4");
|
m_ServerStateDescription.text = Language.GetFromLocal(29);
|
break;
|
case ServerState.Normal:
|
m_ServerState.SetSprite("XT_FWQ_TB2");
|
m_ServerStateDescription.text = Language.GetFromLocal(28);
|
break;
|
case ServerState.Busy:
|
m_ServerState.SetSprite("XT_FWQ_TB3");
|
m_ServerStateDescription.text = Language.GetFromLocal(27);
|
break;
|
case ServerState.Hot:
|
m_ServerState.SetSprite("XT_FWQ_TB1");
|
m_ServerStateDescription.text = Language.GetFromLocal(26);
|
break;
|
}
|
}
|
|
private void OnServerChange()
|
{
|
ChangeServerInfo(ServerListCenter.Instance.currentServer);
|
}
|
|
private void OnServerListRefresh()
|
{
|
m_WaitServerList.gameObject.SetActive(!ServerListCenter.Instance.serverListGot);
|
m_ContainerEnterGame.gameObject.SetActive(ServerListCenter.Instance.serverListGot);
|
m_ContainerAccount.gameObject.SetActive(ServerListCenter.Instance.serverListGot
|
&& (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest || VersionConfig.Get().isBanShu));
|
}
|
|
protected virtual void EnterGame()
|
{
|
if (!LaunchPostProcess.Instance.completed)
|
{
|
return;
|
}
|
|
Login();
|
}
|
|
protected void Login()
|
{
|
if (ServerListCenter.Instance.currentServer.start_date > DateTime.Now)
|
{
|
switch ((ServerState)ServerListCenter.Instance.currentServer.running_status)
|
{
|
case ServerState.Maintain:
|
SysNotifyMgr.Instance.ShowTip("ServerDown");
|
break;
|
case ServerState.Predicted:
|
SysNotifyMgr.Instance.ShowTip("ServerOpen", ServerListCenter.Instance.currentServer.start_date.ToString("MM-dd HH:mm"));
|
break;
|
}
|
}
|
else
|
{
|
if (GameNetSystem.Instance.netState == GameNetSystem.NetState.NerverConnect)
|
{
|
switch (VersionConfig.Get().versionAuthority)
|
{
|
case VersionAuthority.InterTest:
|
if (string.IsNullOrEmpty(m_Account.text))
|
{
|
MessageWin.Inst.ShowFixedTip(Language.Get("L1095"));
|
return;
|
}
|
|
model.AccountLogin(m_Account.text, m_ServerIP, m_Port, m_GamePort);
|
break;
|
case VersionAuthority.Release:
|
model.AccountLogin(m_ServerIP, m_Port, m_GamePort);
|
break;
|
}
|
|
OperationLogCollect.Instance.RecordLauchEvent(6);
|
OperationLogCollect.Instance.RecordEvent(7);
|
|
}
|
}
|
|
}
|
|
private void OpenServerListWin()
|
{
|
WindowCenter.Instance.Open<ServerListWin>();
|
}
|
|
private void SwitchAccount()
|
{
|
SDKUtility.Instance.FreePlatformLoginout();
|
}
|
|
private void VeiwNotice()
|
{
|
GameNotice.OpenGameNoticeForce();
|
}
|
|
|
}
|
|
}
|
|
|
|
|