新增 包ID的枚举表 并修改发包调用

This commit is contained in:
Lenheart 2024-12-18 18:51:30 +08:00
parent f9a88932f4
commit 18acd45a4a
3 changed files with 40 additions and 4 deletions

View File

@ -43,7 +43,7 @@ class _Login_Window extends Yosin_Window {
//登录成功
if (Jso.state) {
NoticeBox = _Yosin_MessageBox("登录成功,正在进入游戏...");
MySocket.Send(9, null);
MySocket.Send(PACKET_ID.QUERY_CHARACTER_LIST, null);
} else {
NoticeBox = _Yosin_MessageBox("登录失败");
}
@ -95,7 +95,7 @@ class _Login_Window extends Yosin_Window {
local LoginButton = Yosin_BaseButton(770, 410, 77, 24 "sprite/interface/lenheartwindowcommon.img", 90);
//点击事件回调
LoginButton.OnClick = function(Button) {
MySocket.Send(1, {
MySocket.Send(PACKET_ID.LOGIN, {
account = AccountInputBox.str,
password = PasswordInputBox.str
})
@ -113,7 +113,7 @@ class _Login_Window extends Yosin_Window {
local RegisterButton = Yosin_BaseButton(865, 410, 77, 24 "sprite/interface/lenheartwindowcommon.img", 90);
//点击事件回调
RegisterButton.OnClick = function(Button) {
MySocket.Send(3, {
MySocket.Send(PACKET_ID.REGISTER, {
account = AccountInputBox.str,
password = PasswordInputBox.str
})

View File

@ -208,6 +208,7 @@ class _Select_Character_Chr extends Yosin_CommonUi {
}
function RegisterCharac() {
if (!Info) return;
local Charc = GameObject.CreateCharacter(Info.job, Info.equip);
Charc.SetAnimation("RestAni");
Charc.SetPosition(64, 156, 0);
@ -256,6 +257,7 @@ class _Select_Character_Chr extends Yosin_CommonUi {
//设置自身选中状态
SelectMask.SetVisible(true);
SelectFlag = true;
Parent.CurrentSelectCharacterIdx = Idx;
}
}
@ -296,6 +298,8 @@ class _Select_Character_Chr extends Yosin_CommonUi {
SetIdxPosition(Button.Idx);
//设置对方的位置
Button.SetIdxPosition(OldIdx);
//发送替换位置包
SendReplaceCharacterPos(OldIdx, Button.Idx);
}
}
M_Move_Xpos = M_Move_Ypos = 0;
@ -303,6 +307,13 @@ class _Select_Character_Chr extends Yosin_CommonUi {
}
}
function SendReplaceCharacterPos(OldIdx, NewIdx) {
MySocket.Send(PACKET_ID.CHANGE_CHARACTER_POSITION, {
oldidx = OldIdx,
newidx = NewIdx
})
}
}
class _Select_Character_Window extends Yosin_Window {
@ -327,6 +338,8 @@ class _Select_Character_Window extends Yosin_Window {
//上排角色对象
UpCharacterList = null;
//当前选中角色Idx
CurrentSelectCharacterIdx = 0;
//信息
Info = null;
@ -383,6 +396,7 @@ class _Select_Character_Window extends Yosin_Window {
local Buf = _Select_Character_Chr(184 + (i * 142), ((i % 2) ? 13 : 0) + 93, 132, 208);
if (i< Info.charac.len()) Buf.Init(Info.charac[i], i);
else Buf.Init(null, i);
UpCharacterList.push(Buf);
AddUIChild(Buf);
}
@ -417,6 +431,9 @@ class _Select_Character_Window extends Yosin_Window {
local CreateTextActor = FontAssetManager.GenerateNormal("创建角色", false, {
color = sq_RGBA(186, 147, 97, 255)
});
CreateButton.OnClick = function(Button) {
Sq_CreateWindow(_CreateCharacter, "创建角色界面窗口", 0, 0, 1066, 600, 0);
}.bindenv(this);
AddUIChild(CreateButton);
CreateTextActor.SetPosition(6, 5);
CreateTextActor.SetZOrder(100000);
@ -471,7 +488,7 @@ class _Select_Character_Window extends Yosin_Window {
local StartButton = Yosin_BaseButton(475, 546, 118, 47 "sprite/interface2/selectcharacter/selectcharacter.img", 7);
//点击事件回调
StartButton.OnClick = function(Button) {
print(123123123);
print(CurrentSelectCharacterIdx);
}.bindenv(this);
AddUIChild(StartButton);
}

View File

@ -0,0 +1,19 @@
/*
文件名:enum_packet.nut
路径:User/_ENUM/enum_packet.nut
创建日期:2024-12-18 18:44
文件用途:包ID枚举
*/
enum PACKET_ID {
// 登录
LOGIN = 1
//注册
REGISTER = 3
//修改密码
CHANGE_PASSWORD = 5
//查询账号中的角色列表
QUERY_CHARACTER_LIST = 9
//更换角色位置
CHANGE_CHARACTER_POSITION = 13
}