DOF/sqr/User/UI/Window/8_SkillTree/8_SkillTree.nut

322 lines
9.7 KiB
Plaintext

/*
文件名:8_SkillTree.nut
路径:User/UI/Window/8_SkillTree/8_SkillTree.nut
创建日期:2025-02-17 10:03
文件用途:技能树
*/
//个人信息命名空间
if (!getroottable().rawin("UISpace_SkillTree")) UISpace_SkillTree <- {};
//技能对象
class UISpace_SkillTree.Skill extends Yosin_CommonUi {
//技能
Skill = 0;
//鼠标悬浮效果
HoverEffect = null;
constructor(x, y, width, height, gSkill) {
this.Skill = gSkill;
base.constructor(x, y, width, height);
// OpenDeBug();
Init();
HoverEffect = CL_SpriteObject("sprite/interface2/ui/newskillshop/newskillshop.img", 35);
HoverEffect.SetPosition(-1, -1);
HoverEffect.SetVisible(false);
Addchild(HoverEffect);
}
function Init() {
//背景
local Background = CL_SpriteObject("sprite/interface2/ui/newskillshop/newskillshop.img", 34);
Addchild(Background);
//技能图标
local SkillIcon = Skill.GetIconSprite();
SkillIcon.SetPosition(4, 4);
Addchild(SkillIcon);
}
//override
//鼠标事件回调
function OnMouseProc(MousePos_X, MousePos_Y, WindowInteractiveFlag) {
if (!Visible) return;
base.OnMouseProc(MousePos_X, MousePos_Y, WindowInteractiveFlag);
if (isInRect && !IMouse.DragObj && !WindowInteractiveFlag) {
//设置透明度
HoverEffect.SetOpacity(0.4);
// if (!ItemInfoShowFlag) {
// //显示详细信息
// ShowInfo(MousePos_X - 50, MousePos_Y - ((ItemInfo.RealCanvasHeight + 10) / 2));
// }
//设置悬停槽
HoverEffect.SetVisible(true);
} else {
HoverEffect.SetVisible(false);
// //关闭所有详细信息显示
// if (ItemInfoShowFlag) {
// CloseInfo();
// }
}
}
}
//技能树窗口
class UISpace_SkillTree.Tree extends Yosin_Window {
//是否为独立窗口
IsIndependent = false;
//是否可见
Visible = false;
//是否为图层窗口
IsLayer = true;
//技能树信息
TreeInfo = null;
//技能List
SkillList = null;
//滚动条
ScrollObject = null;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
SkillList = [];
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
SetClipRect(0, 0, gWidth, gHeight);
// OpenDeBug();
// 背景
local Background = CL_SpriteObject("sprite/interface2/ui/newskillshop/newskillshop.img", 0);
Background.SetPosition(1, 0);
Addchild(Background);
//滚动条
ScrollObject = Yosin_ScrollBar(gWidth - 10, 1, 400, 20);
ScrollObject.SetScrollBarState(false);
ScrollObject.SetChangeCallBack(function(Value) {
MsgTextWindow.SetScrollPos(Value);
}.bindenv(this));
AddUIChild(ScrollObject);
}
//通过技能树Config构造
function Init(Config) {
TreeInfo = Config;
foreach(SkillIndex, Info in Config) {
local SkillBuffer = GameItem.Skill(Parent.Job, SkillIndex);
local SkillSlotBuffer = UISpace_SkillTree.Skill(35 + Info.IconPos.x, 10 + Info.IconPos.y, 36, 48, SkillBuffer);
SkillList.push(SkillSlotBuffer);
AddUIChild(SkillSlotBuffer);
}
}
}
//主类
class UISpace_SkillTree._SkillTree extends Yosin_Window {
//背景画布
BackGroundCanvas = null;
//技能树窗口
SkillTreeWindow = null;
//技能树信息
TreeInfo = null;
//技能点
SkillPoint = 11451;
//职业
Job = 0;
//转职职业
GrowType = 0;
//是否可见
Visible = false;
function _typeof() {
return "Game_Window";
}
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
local title = Yosin_TopTitle(gWidth, gHeight, "技能栏(K)");
AddUIChild(title);
RegisterBackGround();
RegisterButton();
// 标题按钮
local titlesBtn = Yosin_RowMoreTitleBtn(5, 30, Width - 10, ["技能类型I"], "sprite/interface/lenheartwindowcommon.img", 160);
AddUIChild(titlesBtn);
//注册按键回调事件
Input.RegisterGameKeyCode(CONTROLLER.OPTION_HOTKEY_SKILL_WINDOW, function(Flag) {
//按下的时候
if (Flag == 1) {
//如果窗口已经打开
if (this.Visible) {
//关闭窗口
CloseWindow();
} else {
//打开窗口
ResetFocus();
}
}
}.bindenv(this));
}
function RegisterBackGround() {
BackGroundCanvas = CL_CanvasObject();
// 重设大小并清空
BackGroundCanvas.ResizeAndClear(Width, Height);
BackGroundCanvas.SetFillBrush(sq_RGBA(59, 56, 57, 250));
BackGroundCanvas.SetStrokeBrush(sq_RGBA(59, 56, 57, 250));
// 开始绘制
BackGroundCanvas.BeginDraw();
//背景框-左
local LeftBox = Yosin_NineBoxStretch(Width - 230, 438, "sprite/interface/lenheartwindowcommon.img", 97);
LeftBox.SetPosition(5, 52);
BackGroundCanvas.DrawActor(LeftBox);
//技能点背景槽
local SkillPointBackgroundSlot = Yosin_NineBoxStretch(Width - 230, 35, "sprite/interface/lenheartwindowcommon.img", 97);
SkillPointBackgroundSlot.SetPosition(5, 52);
BackGroundCanvas.DrawActor(SkillPointBackgroundSlot);
//技能点文字
local SkillPointText = FontAssetManager.GenerateNormal(format("技能点 %d", SkillPoint), true, {
color = sq_RGBA(105, 212, 238, 250)
});
BackGroundCanvas.DrawActor(SkillPointText, 15, 60);
//背景框-右
local RightBox = Yosin_NineBoxStretch(223, 470, "sprite/interface/lenheartwindowcommon.img", 97);
RightBox.SetPosition(Width - 228, 52);
BackGroundCanvas.DrawActor(RightBox);
//右侧文字使用指南背景
// local BoxHelpTextBg = CL_SpriteFrameObject("sprite/interface2/ui/newskillshop/newskillshop.img", 10);
// BackGroundCanvas.DrawSpriteFrame(BoxHelpTextBg, Width - BoxHelpTextBg.GetSize().w - 5, 52);
//右侧文字使用指南
local BoxHelpText = FontAssetManager.GenerateNormal("技能窗口使用指南", true, {
color = sq_RGBA(192, 163, 54, 250)
});
BackGroundCanvas.DrawActor(BoxHelpText, 580, 52);
// 结束绘制
BackGroundCanvas.EndDraw();
Addchild(BackGroundCanvas);
}
function RegisterButton() {
//初始化按钮
local InitButton = Yosin_SplicingButton(444, 58, 59, 24 "sprite/interface/lenheartwindowcommon.img", 172, true, false);
//创建角色按钮文本
local CreateTextActor = FontAssetManager.GenerateNormal("初始化", false, {
color = sq_RGBA(186, 147, 97, 255)
});
InitButton.OnClick = function(Button) {
}.bindenv(this);
AddUIChild(InitButton);
CreateTextActor.SetPosition(11, 3);
CreateTextActor.SetZOrder(1);
CreateTextActor.SetUpdateFunc(function(Text, Dt) {
if (Text.Parent.State == 1 || Text.Parent.State == 2) {
Text.SetFillColor(sq_RGBA(18, 71, 130, 255));
} else if (Text.Parent.State == 0) {
Text.SetFillColor(sq_RGBA(186, 147, 97, 255));
}
})
InitButton.Addchild(CreateTextActor);
//自动加点按钮
local AutoAddPointButton = Yosin_SplicingButton(506, 58, 59, 24 "sprite/interface/lenheartwindowcommon.img", 172, true, false);
//创建角色按钮文本
local CreateTextActor = FontAssetManager.GenerateNormal("自动加点", false, {
color = sq_RGBA(186, 147, 97, 255)
});
AutoAddPointButton.OnClick = function(Button) {
}.bindenv(this);
AddUIChild(AutoAddPointButton);
CreateTextActor.SetPosition(6, 3);
CreateTextActor.SetZOrder(1);
CreateTextActor.SetUpdateFunc(function(Text, Dt) {
if (Text.Parent.State == 1 || Text.Parent.State == 2) {
Text.SetFillColor(sq_RGBA(18, 71, 130, 255));
} else if (Text.Parent.State == 0) {
Text.SetFillColor(sq_RGBA(186, 147, 97, 255));
}
})
AutoAddPointButton.Addchild(CreateTextActor);
}
//初始化技能树
function Init(Job, GrowType) {
this.Job = Job;
this.GrowType = GrowType;
TreeInfo = AssetManager.GetSkillTreeByJob(Job, GrowType);
print(TreeInfo);
SkillTreeWindow = UISpace_SkillTree.Tree("技能树" + Job + "-" + GrowType, 7, 85, 560, 400, 0);
AddUIChild(SkillTreeWindow);
SkillTreeWindow.Init(TreeInfo);
}
//逻辑入口
function Proc(Dt) {
SyncPos(X, Y);
base.Proc(Dt);
}
//刷新个人信息
function RefreshPersonalInfo() {
PageList[0].Refresh();
PageList[0].CharactersObject.InitCharacter();
}
//在Esc按下时
function OnEsc() {
CloseWindow();
}
}
// if (!getroottable().rawin("chongzaiflag")) {
// getroottable()["chongzaiflag"] <- true;
// } else {
// local BufferList = [];
// //遍历窗口队列 如果可见则调用Show
// for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) {
// local Window = _SYS_WINDOW_LIST_[i];
// Window.Visible = false;
// _UiObject_.Removechild(Window);
// }
// _SYS_WINDOW_LIST_ = [];
// _SYS_WINDOW_LIST_.extend(BufferList);
// //初始化鼠标
// _IMouse_();
// TestStage();
// }