mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Update
Update
This commit is contained in:
101
Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/NetWorkDemoUI.cs
Normal file
101
Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/NetWorkDemoUI.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using GameLogic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TEngine;
|
||||
|
||||
[Window(UILayer.UI)]
|
||||
class NetWorkDemoUI : UIWindow
|
||||
{
|
||||
#region 脚本工具生成的代码
|
||||
|
||||
private GameObject m_goScrollView;
|
||||
private Transform m_tfContent;
|
||||
private GameObject m_itemNetLog;
|
||||
private GameObject m_goConnect;
|
||||
private Button m_btnConnect;
|
||||
private GameObject m_goLogin;
|
||||
private InputField m_inputPassWord;
|
||||
private InputField m_inputName;
|
||||
private Button m_btnLogin;
|
||||
private Button m_btnRegister;
|
||||
|
||||
public override void ScriptGenerator()
|
||||
{
|
||||
m_goScrollView = FindChild("Panel/m_goScrollView").gameObject;
|
||||
m_tfContent = FindChild("Panel/m_goScrollView/Viewport/m_tfContent");
|
||||
m_itemNetLog = FindChild("Panel/m_goScrollView/Viewport/m_tfContent/m_itemNetLog").gameObject;
|
||||
m_goConnect = FindChild("Panel/m_goConnect").gameObject;
|
||||
m_btnConnect = FindChildComponent<Button>("Panel/m_goConnect/m_btnConnect");
|
||||
m_goLogin = FindChild("Panel/m_goLogin").gameObject;
|
||||
m_inputPassWord = FindChildComponent<InputField>("Panel/m_goLogin/m_inputPassWord");
|
||||
m_inputName = FindChildComponent<InputField>("Panel/m_goLogin/m_inputName");
|
||||
m_btnLogin = FindChildComponent<Button>("Panel/m_goLogin/m_btnLogin");
|
||||
m_btnRegister = FindChildComponent<Button>("Panel/m_goLogin/m_btnRegister");
|
||||
m_btnConnect.onClick.AddListener(OnClickConnectBtn);
|
||||
m_btnLogin.onClick.AddListener(OnClickLoginBtn);
|
||||
m_btnRegister.onClick.AddListener(OnClickRegisterBtn);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
|
||||
private void OnClickConnectBtn()
|
||||
{
|
||||
GameClient.Instance.Connect("127.0.0.1:20000");
|
||||
}
|
||||
|
||||
private void OnClickLoginBtn()
|
||||
{
|
||||
if (GameClient.Instance.Status == GameClientStatus.StatusInit)
|
||||
{
|
||||
Log.Info("没有连接到服务器、请先点击连接到服务器按钮在进行此操作");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(m_inputName.text) || string.IsNullOrEmpty(m_inputPassWord.text))
|
||||
{
|
||||
Log.Info("请输入账号和密码");
|
||||
return;
|
||||
}
|
||||
|
||||
GameClient.Instance.Send(new H_C2G_LoginRequest()
|
||||
{
|
||||
UserName = m_inputName.text,
|
||||
Password = m_inputPassWord.text
|
||||
});
|
||||
}
|
||||
|
||||
private void OnClickRegisterBtn()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void RefreshLog()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
[Window(UILayer.UI)]
|
||||
class NetWorkDemoLog : UIWindow
|
||||
{
|
||||
#region 脚本工具生成的代码
|
||||
|
||||
private Text m_textInfo;
|
||||
|
||||
public override void ScriptGenerator()
|
||||
{
|
||||
m_textInfo = FindChildComponent<Text>("m_textInfo");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetText(string value)
|
||||
{
|
||||
m_textInfo.text = value;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8079c660ac3636e45a2de14f5dbcc940
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using TEngine;
|
||||
using TEngine.Core;
|
||||
using TEngine.Core.Network;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家信息网络模块。
|
||||
/// </summary>
|
||||
public class PlayerNetSys:DataCenterModule<PlayerNetSys>
|
||||
{
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public class H_C2G_LoginRequestHandler : MessageRPC<H_C2G_LoginRequest,H_G2C_LoginResponse>
|
||||
{
|
||||
protected override async FTask Run(Session session, H_C2G_LoginRequest request, H_G2C_LoginResponse response, Action reply)
|
||||
{
|
||||
Log.Debug($"收到请求登录的消息 request:{request.ToJson()}");
|
||||
response.Text = "登录成功";
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a16f1c71dea04c5a890b75eda47df16a
|
||||
timeCreated: 1689248961
|
Reference in New Issue
Block a user