-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
387c280
commit 6b0abce
Showing
11 changed files
with
267 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
210 changes: 105 additions & 105 deletions
210
Assets/Hotfix/UI/Logic/UILogin/UILogin.cs → .../Hotfix/UI/Logic/UILogin/UILogin.Logic.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,106 @@ | ||
using System.Net; | ||
using GameFrameX; | ||
using GameFrameX.Event.Runtime; | ||
#if ENABLE_UI_FAIRYGUI | ||
using GameFrameX.UI.FairyGUI.Runtime; | ||
#endif | ||
using GameFrameX.Network.Runtime; | ||
using GameFrameX.Runtime; | ||
using GameFrameX.UI.Runtime; | ||
#if ENABLE_UI_UGUI | ||
using GameFrameX.UI.UGUI.Runtime; | ||
#endif | ||
using Hotfix.Config.item; | ||
using Hotfix.Network; | ||
using Hotfix.Proto; | ||
using UnityEngine; | ||
|
||
namespace Hotfix.UI | ||
{ | ||
public partial class UILogin | ||
{ | ||
private static INetworkChannel networkChannel; | ||
public static string serverIp = "127.0.0.1"; | ||
public static int serverPort = 29100; | ||
|
||
public override void OnOpen(object userData) | ||
{ | ||
m_enter.onClick.Set(OnLoginClick); | ||
base.OnOpen(userData); | ||
} | ||
|
||
private void OnLoginClick() | ||
{ | ||
if (networkChannel != null && networkChannel.Connected) | ||
{ | ||
Login(); | ||
return; | ||
} | ||
|
||
if (networkChannel != null && GameApp.Network.HasNetworkChannel("network") && !networkChannel.Connected) | ||
{ | ||
GameApp.Network.DestroyNetworkChannel("network"); | ||
} | ||
|
||
networkChannel = GameApp.Network.CreateNetworkChannel("network", new DefaultNetworkChannelHelper()); | ||
// 注册心跳消息 | ||
DefaultPacketHeartBeatHandler packetSendHeaderHandler = new DefaultPacketHeartBeatHandler(); | ||
networkChannel.RegisterHeartBeatHandler(packetSendHeaderHandler); | ||
networkChannel.Connect(IPAddress.Parse(serverIp), serverPort); | ||
GameApp.Event.CheckSubscribe(NetworkConnectedEventArgs.EventId, OnNetworkConnected); | ||
GameApp.Event.CheckSubscribe(NetworkClosedEventArgs.EventId, OnNetworkClosed); | ||
} | ||
|
||
private async void Login() | ||
{ | ||
var item = GameApp.Config.GetConfig<TbItem>().Get(1); | ||
Log.Info(item); | ||
if (m_UserName.text.IsNullOrWhiteSpace() || m_Password.text.IsNullOrWhiteSpace()) | ||
{ | ||
m_ErrorText.text = "用户名或密码不能为空"; | ||
return; | ||
} | ||
|
||
|
||
var req = new ReqLogin | ||
{ | ||
SdkType = 0, | ||
SdkToken = "", | ||
UserName = m_UserName.text, | ||
Password = m_Password.text, | ||
Device = SystemInfo.deviceUniqueIdentifier | ||
}; | ||
req.Platform = PathHelper.GetPlatformName; | ||
|
||
RespLogin respLogin = await networkChannel.Call<RespLogin>(req); | ||
Log.Info(respLogin); | ||
ReqPlayerList reqPlayerList = new ReqPlayerList(); | ||
|
||
reqPlayerList.Id = respLogin.Id; | ||
|
||
var respPlayerList = await networkChannel.Call<RespPlayerList>(reqPlayerList); | ||
if (respPlayerList.PlayerList.Count > 0) | ||
{ | ||
await GameApp.UI.OpenUIFormAsync<UIPlayerList>(Utility.Asset.Path.GetUIPath(nameof(UILogin)), UIGroupConstants.Floor.Name, respLogin, true); | ||
} | ||
else | ||
{ | ||
await GameApp.UI.OpenUIFormAsync<UIPlayerCreate>(Utility.Asset.Path.GetUIPath(nameof(UILogin)), UIGroupConstants.Floor.Name, respLogin, true); | ||
} | ||
|
||
// await GameApp.UI.OpenUIFormAsync<UIMain>(Utility.Asset.Path.GetUIPath(nameof(UIMain)), UIGroupConstants.Floor.Name); | ||
GameApp.UI.CloseUIForm(this); | ||
} | ||
|
||
private static void OnNetworkClosed(object sender, GameEventArgs e) | ||
{ | ||
Log.Info(nameof(OnNetworkClosed)); | ||
} | ||
|
||
private void OnNetworkConnected(object sender, GameEventArgs e) | ||
{ | ||
Login(); | ||
Log.Info(nameof(OnNetworkConnected)); | ||
} | ||
} | ||
using System.Net; | ||
using GameFrameX; | ||
using GameFrameX.Event.Runtime; | ||
#if ENABLE_UI_FAIRYGUI | ||
using GameFrameX.UI.FairyGUI.Runtime; | ||
#endif | ||
using GameFrameX.Network.Runtime; | ||
using GameFrameX.Runtime; | ||
using GameFrameX.UI.Runtime; | ||
#if ENABLE_UI_UGUI | ||
using GameFrameX.UI.UGUI.Runtime; | ||
#endif | ||
using Hotfix.Config.item; | ||
using Hotfix.Network; | ||
using Hotfix.Proto; | ||
using UnityEngine; | ||
|
||
namespace Hotfix.UI | ||
{ | ||
public partial class UILogin | ||
{ | ||
private static INetworkChannel networkChannel; | ||
public static string serverIp = "127.0.0.1"; | ||
public static int serverPort = 29100; | ||
|
||
public override void OnOpen(object userData) | ||
{ | ||
m_enter.onClick.Set(OnLoginClick); | ||
base.OnOpen(userData); | ||
} | ||
|
||
private void OnLoginClick() | ||
{ | ||
if (networkChannel != null && networkChannel.Connected) | ||
{ | ||
Login(); | ||
return; | ||
} | ||
|
||
if (networkChannel != null && GameApp.Network.HasNetworkChannel("network") && !networkChannel.Connected) | ||
{ | ||
GameApp.Network.DestroyNetworkChannel("network"); | ||
} | ||
|
||
networkChannel = GameApp.Network.CreateNetworkChannel("network", new DefaultNetworkChannelHelper()); | ||
// 注册心跳消息 | ||
DefaultPacketHeartBeatHandler packetSendHeaderHandler = new DefaultPacketHeartBeatHandler(); | ||
networkChannel.RegisterHeartBeatHandler(packetSendHeaderHandler); | ||
networkChannel.Connect(IPAddress.Parse(serverIp), serverPort); | ||
GameApp.Event.CheckSubscribe(NetworkConnectedEventArgs.EventId, OnNetworkConnected); | ||
GameApp.Event.CheckSubscribe(NetworkClosedEventArgs.EventId, OnNetworkClosed); | ||
} | ||
|
||
private async void Login() | ||
{ | ||
var item = GameApp.Config.GetConfig<TbItem>().Get(1); | ||
Log.Info(item); | ||
if (m_UserName.text.IsNullOrWhiteSpace() || m_Password.text.IsNullOrWhiteSpace()) | ||
{ | ||
m_ErrorText.text = "用户名或密码不能为空"; | ||
return; | ||
} | ||
|
||
|
||
var req = new ReqLogin | ||
{ | ||
SdkType = 0, | ||
SdkToken = "", | ||
UserName = m_UserName.text, | ||
Password = m_Password.text, | ||
Device = SystemInfo.deviceUniqueIdentifier | ||
}; | ||
req.Platform = PathHelper.GetPlatformName; | ||
|
||
RespLogin respLogin = await networkChannel.Call<RespLogin>(req); | ||
Log.Info(respLogin); | ||
ReqPlayerList reqPlayerList = new ReqPlayerList(); | ||
|
||
reqPlayerList.Id = respLogin.Id; | ||
|
||
var respPlayerList = await networkChannel.Call<RespPlayerList>(reqPlayerList); | ||
if (respPlayerList.PlayerList.Count > 0) | ||
{ | ||
await GameApp.UI.OpenUIFormAsync<UIPlayerList>(Utility.Asset.Path.GetUIPath(nameof(UILogin)), UIGroupConstants.Floor.Name, respLogin, true); | ||
} | ||
else | ||
{ | ||
await GameApp.UI.OpenUIFormAsync<UIPlayerCreate>(Utility.Asset.Path.GetUIPath(nameof(UILogin)), UIGroupConstants.Floor.Name, respLogin, true); | ||
} | ||
|
||
// await GameApp.UI.OpenUIFormAsync<UIMain>(Utility.Asset.Path.GetUIPath(nameof(UIMain)), UIGroupConstants.Floor.Name); | ||
GameApp.UI.CloseUIForm(this); | ||
} | ||
|
||
private static void OnNetworkClosed(object sender, GameEventArgs e) | ||
{ | ||
Log.Info(nameof(OnNetworkClosed)); | ||
} | ||
|
||
private void OnNetworkConnected(object sender, GameEventArgs e) | ||
{ | ||
Login(); | ||
Log.Info(nameof(OnNetworkConnected)); | ||
} | ||
} | ||
} |
File renamed without changes.
92 changes: 46 additions & 46 deletions
92
...Hotfix/UI/Logic/UILogin/UIPlayerCreate.cs → .../UI/Logic/UILogin/UIPlayerCreate.Logic.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
using GameFrameX; | ||
#if ENABLE_UI_FAIRYGUI | ||
using GameFrameX.UI.FairyGUI.Runtime; | ||
#endif | ||
using GameFrameX.Runtime; | ||
using GameFrameX.UI.Runtime; | ||
#if ENABLE_UI_UGUI | ||
using GameFrameX.UI.UGUI.Runtime; | ||
#endif | ||
using Hotfix.Proto; | ||
|
||
namespace Hotfix.UI | ||
{ | ||
public partial class UIPlayerCreate | ||
{ | ||
ReqPlayerCreate req; | ||
|
||
public override void OnOpen(object userData) | ||
{ | ||
req = new ReqPlayerCreate(); | ||
base.OnOpen(userData); | ||
|
||
RespLogin respLogin = userData as RespLogin; | ||
this.m_enter.onClick.Set(OnCreateButtonClick); | ||
req.Id = respLogin.Id; | ||
} | ||
|
||
private async void OnCreateButtonClick() | ||
{ | ||
if (m_UserName.text.IsNullOrWhiteSpace()) | ||
{ | ||
m_ErrorText.text = "角色名不能为空"; | ||
return; | ||
} | ||
|
||
req.Name = m_UserName.text; | ||
var resp = await GameApp.Network.GetNetworkChannel("network").Call<RespPlayerCreate>(req); | ||
if (resp.PlayerInfo != null) | ||
{ | ||
Log.Info("创建角色成功"); | ||
} | ||
|
||
await GameApp.UI.OpenUIFormAsync<UIPlayerList>(Utility.Asset.Path.GetUIPackagePath(nameof(UILogin)), UIGroupConstants.Floor.Name, UserData, true); | ||
GameApp.UI.CloseUIForm(this); | ||
} | ||
} | ||
using GameFrameX; | ||
#if ENABLE_UI_FAIRYGUI | ||
using GameFrameX.UI.FairyGUI.Runtime; | ||
#endif | ||
using GameFrameX.Runtime; | ||
using GameFrameX.UI.Runtime; | ||
#if ENABLE_UI_UGUI | ||
using GameFrameX.UI.UGUI.Runtime; | ||
#endif | ||
using Hotfix.Proto; | ||
|
||
namespace Hotfix.UI | ||
{ | ||
public partial class UIPlayerCreate | ||
{ | ||
ReqPlayerCreate req; | ||
|
||
public override void OnOpen(object userData) | ||
{ | ||
req = new ReqPlayerCreate(); | ||
base.OnOpen(userData); | ||
|
||
RespLogin respLogin = userData as RespLogin; | ||
this.m_enter.onClick.Set(OnCreateButtonClick); | ||
req.Id = respLogin.Id; | ||
} | ||
|
||
private async void OnCreateButtonClick() | ||
{ | ||
if (m_UserName.text.IsNullOrWhiteSpace()) | ||
{ | ||
m_ErrorText.text = "角色名不能为空"; | ||
return; | ||
} | ||
|
||
req.Name = m_UserName.text; | ||
var resp = await GameApp.Network.GetNetworkChannel("network").Call<RespPlayerCreate>(req); | ||
if (resp.PlayerInfo != null) | ||
{ | ||
Log.Info("创建角色成功"); | ||
} | ||
|
||
await GameApp.UI.OpenUIFormAsync<UIPlayerList>(Utility.Asset.Path.GetUIPackagePath(nameof(UILogin)), UIGroupConstants.Floor.Name, UserData, true); | ||
GameApp.UI.CloseUIForm(this); | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.