diff --git a/Project/AncientheroLuckyBox/AncientheroLuckyBox.nut b/Project/AncientheroLuckyBox/AncientheroLuckyBox.nut new file mode 100644 index 0000000..8cbf016 --- /dev/null +++ b/Project/AncientheroLuckyBox/AncientheroLuckyBox.nut @@ -0,0 +1,240 @@ +/* +文件名:AncientheroLuckyBox.nut +路径:Project/AncientheroLuckyBox/AncientheroLuckyBox.nut +创建日期:2025-07-08 18:44 +文件用途:圣者遗物箱 +*/ +class AncientheroLuckyBoxC extends LenheartNewUI_Windows { + //调试模式 + // DeBugMode = true; + + //不是窗口 + // NoWindow = true; + + //是否可见 + // Visible = false; + + Img = null; + + //遗物箱ID + BoxId = 15; + //盒子数量 + BoxCount = 0; + + //打开状态 0未打开 1单抽 10十连抽 + OpenFlag = 0; + + //抽奖模式按钮集合 + OpenBtns = null; + + //动画队列 + AniQueue = null; + + constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { + Childrens = []; + AniQueue = QuestQueue();; + //注册控件 + RegisterWidget(); + + LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); + + Img = {}; + Img["main"] <- Rindro_Image("interface2/event/chn_event_2020/201029_ancientheroluckybox/ancientbox.img"); + Img["yosin"] <- Rindro_Image("yosin/db_newani.img"); + + + + //配置回包 + RegisterPack(20094002, function(Chunk) { + local Jso = Json.Decode(Chunk); + // BoxId = Jso["boxId"]; + + }.bindenv(this)); + + } + + function RegisterWidget() { + //关闭按钮 + local CloseButton = LenheartNewUI_BaseButton(763, 0, 11, 12, "interface/lenheartwindowcommon.img", 276); + CloseButton.OnClick = function() { + this.Visible = false; + }.bindenv(this); + Childrens.append(CloseButton); + + OpenBtns = []; + //单抽复选框 + local OneOpenBtn = LenheartNewUI_SwitchButtonText(196, 425, " 开启1个"); + OneOpenBtn.ImgIndex = 358; + OneOpenBtn.SetTextPos(12, 2); + OneOpenBtn.Width = 130; + OneOpenBtn.Height = 16; + OneOpenBtn.OnClickEx = function(Btn) { + CallOpenAnimation(OpenFlag == 0); + OpenFlag = 1; + OpenBtns[1].State = 0; + Btn.State = 1; + }.bindenv(this); + AddChild(OneOpenBtn); + OpenBtns.append(OneOpenBtn); + + //单抽复选框 + local TenOpenBtn = LenheartNewUI_SwitchButtonText(458, 425, " 开启10个"); + TenOpenBtn.ImgIndex = 358; + TenOpenBtn.SetTextPos(12, 2); + TenOpenBtn.Width = 130; + TenOpenBtn.Height = 16; + TenOpenBtn.OnClickEx = function(Btn) { + CallOpenAnimation(OpenFlag == 0); + OpenFlag = 10; + OpenBtns[0].State = 0; + Btn.State = 1; + }.bindenv(this); + AddChild(TenOpenBtn); + OpenBtns.append(TenOpenBtn); + + + } + + + //调用打开界面动画 + function CallOpenAnimation(Flag) { + R_Utils.PlaySound("ANCIENTBOX_WHEEL"); + //Flag 为true时是第一次进入 盖着盖子的状态 false 需要先盖上再打开 + AniQueue.AddQuest("打开界面动画", function(Name, Time, Flag) { + if (Flag) { + local Ani = DrawAniEx(X + 5, Y + 25, "common/ancientheroluckybox/animation/intro.ani"); + if (sq_IsEnd(Ani)) { + sq_Rewind(Ani); + AniQueue.RemoveQuest(Name); + } + } else { + local Ani = DrawAniEx(X + 5, Y + 25, "common/ancientheroluckybox/animation/outro.ani"); + if (sq_IsEnd(Ani)) { + sq_Rewind(Ani); + AniQueue.RemoveQuest(Name); + CallOpenAnimation(true); + } + } + }.bindenv(this), Flag); + } + + //绘制主界面 + function DrawMain(obj) { + //绘制背景 + Img["yosin"].DrawPng(0, X, Y); + //未打开状态 + if (OpenFlag == 0) Img["main"].DrawPng(1, X + 5, Y + 25); + + //绘制圣者遗物箱图标 + DrawItemBase(X + 377, Y + 394, BoxId, 1); + //绘制圣者遗物箱数量 + + } + + + function Show(obj) { + DrawMain(obj); + AniQueue.Run(); + LenheartNewUI_Windows.Show(obj); + } + + //逻辑入口 + function Proc(obj) { + LenheartNewUI_Windows.SyncPos(X, Y); + } + + //重置 + function ResetData() { + if (OpenBtns) { + OpenBtns[0].State = 0; + OpenBtns[1].State = 0; + } + OpenFlag = 0; + } +} + +function Lenheart_AncientheroLuckyBox_Fun(obj) { + local RootTab = getroottable(); + if (!RootTab.rawin("AncientheroLuckyBox_Obj")) { + RootTab.rawset("AncientheroLuckyBox_Obj", true); + LenheartNewUI_CreateWindow(AncientheroLuckyBoxC, "圣者遗物箱窗口", ((getroottable().Rindro_Scr_Width - 782) / 2).tointeger(), 30, 782, 600, 28); + } +} + +getroottable()["LenheartFuncTab"].rawset("AncientheroLuckyBoxFuncN", Lenheart_AncientheroLuckyBox_Fun); + + + + + + + +L_Windows_List <- []; +getroottable().rawdelete("LenheartPluginsInitFlag"); +getroottable().rawdelete("EventList_Obj") +getroottable().rawdelete("AncientheroLuckyBox_Obj"); + + +//任务队列 +class QuestQueue { + //队列 + Queue = null; + + constructor() { + Queue = {}; + } + + //添加任务 + function AddQuest(QuestName, QuestLogic, ...) { + local args = null; + if (vargc > 0) { + args = []; + for (local i = 0; i< vargc; i++) { + args.append(vargv[i]); + } + } + Queue[QuestName] <- { + Logic = QuestLogic, + InseartTime = Clock(), + arg = args + }; + } + + //移除任务 + function RemoveQuest(QuestName) { + if (Queue) { + Queue.rawdelete(QuestName); + } + } + + //执行任务 + function Run() { + if (Queue) { + local NowTime = Clock(); + foreach(QuestName, QuestInfo in Queue) { + if (QuestInfo.arg && QuestInfo.arg.len() > 0) { + local Arr = []; + Arr.append(getroottable()); + Arr.append(QuestName); + Arr.append(NowTime); + foreach(value in QuestInfo.arg) { + Arr.append(value); + } + QuestInfo.Logic.acall(Arr); + // QuestInfo.Logic(QuestName, NowTime - QuestInfo.InseartTime, QuestInfo.arg); + } else QuestInfo.Logic(QuestName, NowTime - QuestInfo.InseartTime); + } + } + } + + + //示例 + + /* + Obj.AddQuest("测试任务",function (Name,Time) + { + print(Time); + if(Time >= 2000)Obj.RemoveQuest(Name); + }.bindenv(this)); + */ +} \ No newline at end of file