AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppLogin.cs

90 lines
2.7 KiB
C#
Raw Normal View History

2024-06-28 18:08:25 +08:00
using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.Common;
2024-12-13 17:28:02 +08:00
using AxibugEmuOnline.Client.Event;
2024-06-28 18:08:25 +08:00
using AxibugEmuOnline.Client.Network;
using AxibugProtobuf;
using System;
using UnityEngine;
2024-06-28 18:08:25 +08:00
namespace AxibugEmuOnline.Client.Manager
{
public class AppLogin
{
static string LastLoginGuid = "";
2024-09-13 10:07:24 +08:00
2024-06-28 18:08:25 +08:00
public AppLogin()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdLogin, RecvLoginMsg);
}
public void Login()
{
2024-09-11 18:31:25 +08:00
App.log.Debug("-->Login");
2024-08-16 10:20:00 +08:00
if (string.IsNullOrEmpty(LastLoginGuid))
2024-06-28 18:08:25 +08:00
LastLoginGuid = Guid.NewGuid().ToString();
2024-09-11 18:31:25 +08:00
App.user.userdata.Account = LastLoginGuid;
AxibugProtobuf.DeviceType devType;
if (Application.platform == RuntimePlatform.PSP2)
devType = AxibugProtobuf.DeviceType.Psv;
else if (Application.platform == RuntimePlatform.Android)
devType = AxibugProtobuf.DeviceType.Android;
else if (Application.platform == RuntimePlatform.IPhonePlayer)
devType = AxibugProtobuf.DeviceType.Ios;
else
devType = AxibugProtobuf.DeviceType.Pc;
2024-06-28 18:08:25 +08:00
Protobuf_Login msg = new Protobuf_Login()
{
LoginType = LoginType.UseDevice,
DeviceStr = Initer.dev_UUID,
DeviceType = devType,
2024-06-28 18:08:25 +08:00
};
App.network.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
2024-06-28 18:08:25 +08:00
}
public void RecvLoginMsg(byte[] reqData)
{
Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Login_RESP>(reqData);
if (msg.Status == LoginResultStatus.Ok)
{
2024-09-11 18:31:25 +08:00
App.log.Info("登录成功");
App.user.InitMainUserData(App.user.userdata.Account, msg.UID);
2024-12-13 17:28:02 +08:00
OverlayManager.PopTip("登录成功");
2024-09-14 17:43:08 +08:00
2024-09-18 15:53:58 +08:00
App.log.Info("获取Room列表");
2024-09-14 17:43:08 +08:00
App.roomMgr.SendGetRoomList();
App.log.Info("获取在线玩家列表");
App.user.Send_GetUserList();
2024-12-13 17:28:02 +08:00
Eventer.Instance.PostEvent(EEvent.OnLoginSucceed);
2024-06-28 18:08:25 +08:00
}
else
{
2024-12-13 17:28:02 +08:00
App.log.Info("登录失败");
OverlayManager.PopTip("登录失败");
Eventer.Instance.PostEvent(EEvent.OnLoginFailed);
2024-06-28 18:08:25 +08:00
}
2024-09-13 18:07:27 +08:00
#if UNITY_EDITOR
//TestCreate();
#endif
2024-06-28 18:08:25 +08:00
}
2024-09-13 10:07:24 +08:00
2024-09-13 18:07:27 +08:00
#region
void TestCreate()
{
App.roomMgr.SendCreateRoom(1, 0, string.Empty);
}
long TestFrameID = 0;
void TestEmuUpdate()
{
2024-12-04 23:15:05 +08:00
2024-09-13 18:07:27 +08:00
}
#endregion
2024-06-28 18:08:25 +08:00
}
}