2025-01-02 19:19:36 +08:00
|
|
|
/*
|
|
|
|
|
文件名:NpcObjectClass.nut
|
|
|
|
|
路径:User/Object/ActiveObject/NpcObjectClass.nut
|
|
|
|
|
创建日期:2024-12-28 11:11
|
|
|
|
|
文件用途:NPC类
|
|
|
|
|
*/
|
|
|
|
|
class GameObject.NPC extends GameObject.BaseClass {
|
|
|
|
|
|
|
|
|
|
//ID
|
|
|
|
|
Id = 0;
|
|
|
|
|
//信息
|
|
|
|
|
Info = null;
|
|
|
|
|
//Ani动画
|
|
|
|
|
Ani = null;
|
|
|
|
|
//名字
|
|
|
|
|
Name = null;
|
|
|
|
|
|
|
|
|
|
//识别高度
|
|
|
|
|
IdentifyHeight = 0;
|
|
|
|
|
//识别宽度
|
|
|
|
|
IdentifyWidth = 0;
|
|
|
|
|
|
|
|
|
|
//是否悬停
|
|
|
|
|
IsHover = false;
|
|
|
|
|
|
2025-02-20 13:53:36 +08:00
|
|
|
_Mouse_Click_Flag = false;
|
|
|
|
|
|
2025-01-02 19:19:36 +08:00
|
|
|
function _typeof() {
|
|
|
|
|
return "npc";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//初始化装配
|
|
|
|
|
function InitAssembly(IndexKey, SetKey, Func) {
|
|
|
|
|
if (Info.rawin(IndexKey)) {
|
|
|
|
|
this[SetKey] = Func(Info[IndexKey]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constructor(Id) {
|
|
|
|
|
this.Id = Id;
|
|
|
|
|
base.constructor();
|
|
|
|
|
Info = AssetManager.GetNpc(Id);
|
|
|
|
|
if (Info) {
|
|
|
|
|
//构造Ani
|
|
|
|
|
InitAssembly("field_animation", "Ani", function(Data) {
|
|
|
|
|
local Ani = Animation(Data);
|
|
|
|
|
Addchild(Ani);
|
|
|
|
|
local Size = Ani.GetSize();
|
|
|
|
|
IdentifyHeight = Size.h;
|
|
|
|
|
IdentifyWidth = Size.w;
|
|
|
|
|
return Ani;
|
|
|
|
|
});
|
|
|
|
|
//构造名字
|
|
|
|
|
InitAssembly("name", "Name", function(Data) {
|
|
|
|
|
//创建名字对象
|
|
|
|
|
local NameObj = FontAssetManager.GenerateNormal(Data, true, {
|
|
|
|
|
color = sq_RGBA(242, 209, 175, 255),
|
|
|
|
|
});
|
|
|
|
|
local Height = Ani ? Ani.GetSize().h : 0;
|
|
|
|
|
NameObj.SetPosition(0 - (NameObj.GetSize().w / 2), -Height - 25);
|
|
|
|
|
NameObj.SetZOrder(80000);
|
|
|
|
|
Addchild(NameObj);
|
|
|
|
|
return NameObj;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-20 13:53:36 +08:00
|
|
|
function OnMouseLogic(MouseState, Wheel, MousePos_X, MousePos_Y, WindowInteractiveFlag) {
|
2025-01-02 19:19:36 +08:00
|
|
|
//悬停事件
|
2025-02-20 13:53:36 +08:00
|
|
|
if (!IsHover && !WindowInteractiveFlag) {
|
2025-01-02 19:19:36 +08:00
|
|
|
IsHover = true;
|
|
|
|
|
//设置Ani描边
|
|
|
|
|
Ani.SetOutline(true, sq_RGBA(155, 255, 0, 250));
|
|
|
|
|
//设置鼠标
|
2025-01-09 22:23:33 +08:00
|
|
|
IMouse.ChangeActive(120, 4);
|
2025-01-02 19:19:36 +08:00
|
|
|
}
|
2025-02-20 13:53:36 +08:00
|
|
|
|
|
|
|
|
if (WindowInteractiveFlag) {
|
|
|
|
|
if (IsHover) {
|
|
|
|
|
IsHover = false;
|
|
|
|
|
Ani.SetOutline(false);
|
|
|
|
|
//设置鼠标
|
|
|
|
|
IMouse.Change(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断点击 在没有悬停在任何窗口的情况下
|
|
|
|
|
if (MouseState == 0x201 && !WindowInteractiveFlag) {
|
|
|
|
|
_NameSpace_FunctionInteractive._FunctionInteractive.Generator(Id, MousePos_X + 16, MousePos_Y + 16);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-01-02 19:19:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function OutMouseLogic() {
|
|
|
|
|
//悬停事件
|
|
|
|
|
if (IsHover) {
|
|
|
|
|
IsHover = false;
|
|
|
|
|
Ani.SetOutline(false);
|
|
|
|
|
//设置鼠标
|
2025-01-09 22:23:33 +08:00
|
|
|
IMouse.Change(0);
|
2025-01-02 19:19:36 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-20 13:53:36 +08:00
|
|
|
function OnUpdate(Dt) {
|
|
|
|
|
// //悬停事件
|
|
|
|
|
// if (IsHover) {
|
|
|
|
|
// IsHover = false;
|
|
|
|
|
// Ani.SetOutline(false);
|
|
|
|
|
// //设置鼠标
|
|
|
|
|
// IMouse.Change(0);
|
|
|
|
|
// }
|
|
|
|
|
}
|
2025-01-03 19:49:49 +08:00
|
|
|
|
2025-01-02 19:19:36 +08:00
|
|
|
}
|