/* 文件名:Steal.nut 路径:Project/Steal/Steal.nut 创建日期:2026-04-07 05:19 文件用途: */ class StealC_Password_Box extends LenheartNewUI_CommonUi { NumberSeq = null; ScrollPixelOffset = 0; ScrollBaseIndex = 0; InitBaseIndex = 0; ScrollStartTimeMs = 0; RowDurationMs = 500; RowHeight = 24; ColumnYOffset = 0; CorrectIndex = 0; IsStopped = false; IsLockedCorrect = false; constructor(X, Y, ...) { LenheartNewUI_CommonUi.constructor(X, Y, 30, 120); local PhaseIndex = 0; if (vargc > 0) { PhaseIndex = vargv[0]; } ColumnYOffset = -(PhaseIndex * 8); NumberSeq = []; for (local i = 0; i < 10; i++) { local Info = { num = sq_getRandom(0, 9), CorrectFlag = false, } NumberSeq.append(Info); } CorrectIndex = sq_getRandom(0, 9); NumberSeq[CorrectIndex].CorrectFlag = true; local SeqLen = NumberSeq.len(); if (SeqLen > 0) { local Phase = PhaseIndex % SeqLen; if (Phase < 0) { Phase += SeqLen; } ScrollBaseIndex = Phase; InitBaseIndex = Phase; } ScrollStartTimeMs = Clock(); } function GetLoopIndex(Index) { local SeqLen = NumberSeq.len(); if (SeqLen <= 0) { return 0; } local Value = Index % SeqLen; if (Value < 0) { Value += SeqLen; } return Value; } function UpdateScrollByClock() { if (RowDurationMs <= 0) { RowDurationMs = 1; } local RunTimeMs = Clock() - ScrollStartTimeMs; if (RunTimeMs < 0) { RunTimeMs = 0; } local PassedRows = (RunTimeMs / RowDurationMs).tointeger(); local CycleMs = RunTimeMs % RowDurationMs; ScrollPixelOffset = sq_GetUniformVelocity(0, RowHeight - 1, CycleMs, RowDurationMs).tointeger(); ScrollBaseIndex = GetLoopIndex(InitBaseIndex - PassedRows); } function GetCorrectCenterY(RefY) { local SeqLen = NumberSeq.len(); if (SeqLen <= 0) { return Y; } local Delta = GetLoopIndex(CorrectIndex - ScrollBaseIndex); local TextY = Y + 10; local BaseY = TextY + Delta * RowHeight + ScrollPixelOffset + ColumnYOffset + 8; local CycleHeight = SeqLen * RowHeight; local BestY = BaseY; local BestDist = abs(BestY - RefY); for (local k = -2; k <= 2; k++) { local CY = BaseY + (k * CycleHeight); local Dist = abs(CY - RefY); if (Dist < BestDist) { BestY = CY; BestDist = Dist; } } return BestY; } function TryLockByLine(LockCenterY, TolerancePx) { if (IsStopped) { return false; } if (!IsStopped) { UpdateScrollByClock(); } local Dist = abs(GetCorrectCenterY(LockCenterY) - LockCenterY); if (Dist <= TolerancePx) { IsStopped = true; IsLockedCorrect = true; return true; } return false; } function Show(obj) { Parent.Img.DrawExPng(10, X, Y, 0, sq_RGBA(255, 255, 255, 90), 1.0, 1.0); local SeqLen = NumberSeq.len(); if (SeqLen <= 0) { return; } if (!IsStopped) { UpdateScrollByClock(); } local DrawCount = (Height / RowHeight).tointeger() + 4; local TextY = Y + 10; for (local i = -2; i < DrawCount - 2; i++) { local Info = NumberSeq[GetLoopIndex(ScrollBaseIndex + i)]; local NumStr = Info.num.tostring(); local Color = Info.CorrectFlag ? sq_RGBA(157, 245, 10, 255) : sq_RGBA(150, 150, 150, 255); local DrawY = TextY + i * RowHeight + ScrollPixelOffset + ColumnYOffset; L_sq_DrawCode(NumStr, X + 15 - LenheartTextClass.GetStringLength(NumStr) / 2, DrawY, Color, 0, 1); } } } class StealC extends LenheartNewUI_Windows { //调试模式 // DeBugMode = true; //不是窗口 // NoWindow = true; //是否可见 // Visible = false; Img = Rindro_Image("steal/widget.img"); //解锁完成度 UnlockComplete = 0.57; CorrectLockedCount = 0; LockTolerancePx = 8; constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { Childrens = []; //注册控件 RegisterWidget(); LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); } function RegisterWidget() { // //关闭按钮 // local CloseButton = LenheartNewUI_BaseButton(278, 0, 11, 12, "interface/lenheartwindowcommon.img", 276); // CloseButton.OnClick = function() { // this.Visible = false; // }.bindenv(this); // Childrens.append(CloseButton); for (local i = 0; i< 8; i++) { local PasswordBox = StealC_Password_Box(280 + i * 30, 268, i); AddChild(PasswordBox); } } //绘制主界面 function GetLockCenterY() { return Y + 268 + 60; } function GetFocusPasswordBox() { foreach(Child in Childrens) { if ((Child instanceof StealC_Password_Box) && !Child.IsStopped) { return Child; } } return null; } function CheckSpaceLock() { if (!Visible) { return; } if (!KeyPressNB.isKeyPress(7, "StealC")) { return; } local FocusBox = GetFocusPasswordBox(); if (!FocusBox) { return; } if (FocusBox.TryLockByLine(GetLockCenterY(), LockTolerancePx)) { CorrectLockedCount += 1; } } function DrawMain(obj) { //灰色背景 DrawNineBoxAlpha(X, Y, 800, 600, "interface2/common/mypopup/popup.img", 0, 150); //宝箱动画 local Ani = DrawAniEx(X + 425, Y + 230, "npc/animation/storagediamond.ani"); Ani.setImageRateFromOriginal(2.0, 2.0); //完成度文字 local StealCompleteStr = "解锁完成度: " + UnlockComplete * 100.0 + "%"; L_sq_DrawCode(StealCompleteStr, X + 410 - LenheartTextClass.GetStringLength(StealCompleteStr) / 2, Y + 406, sq_RGBA(255, 255, 255, 255), 0, 1); //完成度进度条 Img.DrawPng(2, X + 162, Y + 425); setClip(X + 168, Y + 429, X + 168 + (463 * UnlockComplete).tointeger(), Y + 429 + 6); Img.DrawPng(3, X + 168, Y + 429); releaseClip(); //裁切结束 //解锁界面 Img.DrawPng(9, X + 269, Y + 260); //解锁锁定条 Img.DrawPng(11, X + 269 + 8, Y + 260 + 60); } function Show(obj) { DrawMain(obj); //裁切遮罩密码框 setClip(X + 280, Y + 268, X + 280 + 8 * 30, Y + 268 + 120); LenheartNewUI_Windows.Show(obj); releaseClip(); //裁切结束 } //逻辑入口 function Proc(obj) { LenheartNewUI_Windows.SyncPos(X, Y); CheckSpaceLock(); } } L_Windows_List <- []; getroottable().rawdelete("LenheartPluginsInitFlag"); getroottable().rawdelete("EventList_Obj") getroottable().rawdelete("Steal_Obj"); getroottable().rawdelete("L_Each_Obj"); function Lenheart_Steal_Fun(obj) { local RootTab = getroottable(); if (!RootTab.rawin("Steal_Obj")) { RootTab.rawset("Steal_Obj", true); LenheartNewUI_CreateWindow(StealC, "偷窃系统窗口", 0, 0, 800, 600, 0); } } getroottable()["LenheartFuncTab"].rawset("StealFuncN", Lenheart_Steal_Fun);