From 8c9c9d718a4a1e79d213a80dd5f176c1d2505fb6 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Thu, 9 Apr 2026 05:40:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(Steal):=20=E6=89=A9=E5=B1=95=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E6=A1=86=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E9=94=81=E5=AE=9A=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加密码字符集支持字母和数字 - 将线性锁定检测改为矩形区域检测 - 添加停止位置偏移量以优化视觉效果 - 实现解锁进度自动计算功能 - 调整默认参数和初始化逻辑 --- Project/Steal/Steal.nut | 49 +++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/Project/Steal/Steal.nut b/Project/Steal/Steal.nut index 9decee4..3a2436c 100644 --- a/Project/Steal/Steal.nut +++ b/Project/Steal/Steal.nut @@ -18,7 +18,9 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi { CorrectIndex = 0; IsStopped = false; IsLockedCorrect = false; + StopSnapOffsetY = 0; + PassStr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; constructor(X, Y, ...) { LenheartNewUI_CommonUi.constructor(X, Y, 30, 120); @@ -31,7 +33,7 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi { NumberSeq = []; for (local i = 0; i < 10; i++) { local Info = { - num = sq_getRandom(0, 9), + num = PassStr[sq_getRandom(0, PassStr.len() - 1)], CorrectFlag = false, } NumberSeq.append(Info); @@ -100,15 +102,15 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi { return BestY; } - function TryLockByLine(LockCenterY, TolerancePx) { + function TryLockByRect(LockTopY, LockHeight, SnapExtraOffsetY) { if (IsStopped) { return false; } - if (!IsStopped) { - UpdateScrollByClock(); - } - local Dist = abs(GetCorrectCenterY(LockCenterY) - LockCenterY); - if (Dist <= TolerancePx) { + UpdateScrollByClock(); + local LockCenterY = LockTopY + (LockHeight / 2).tointeger(); + local CorrectCenterY = GetCorrectCenterY(LockCenterY); + if (CorrectCenterY >= LockTopY && CorrectCenterY <= (LockTopY + LockHeight)) { + StopSnapOffsetY = (LockCenterY - CorrectCenterY) + SnapExtraOffsetY; IsStopped = true; IsLockedCorrect = true; return true; @@ -134,13 +136,14 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi { 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; + local DrawY = TextY + i * RowHeight + ScrollPixelOffset + ColumnYOffset + StopSnapOffsetY; L_sq_DrawCode(NumStr, X + 15 - LenheartTextClass.GetStringLength(NumStr) / 2, DrawY, Color, 0, 1); } } } + class StealC extends LenheartNewUI_Windows { //调试模式 // DeBugMode = true; @@ -154,9 +157,10 @@ class StealC extends LenheartNewUI_Windows { Img = Rindro_Image("steal/widget.img"); //解锁完成度 - UnlockComplete = 0.57; + UnlockComplete = 0.0; CorrectLockedCount = 0; - LockTolerancePx = 8; + LockBoxHeight = 24; + LockSnapOffsetY = -6; constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { Childrens = []; @@ -164,6 +168,7 @@ class StealC extends LenheartNewUI_Windows { RegisterWidget(); LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); + RefreshUnlockComplete(); } function RegisterWidget() { @@ -182,7 +187,7 @@ class StealC extends LenheartNewUI_Windows { //绘制主界面 - function GetLockCenterY() { + function GetLockTopY() { return Y + 268 + 60; } @@ -195,6 +200,25 @@ class StealC extends LenheartNewUI_Windows { return null; } + function GetPasswordBoxTotal() { + local Total = 0; + foreach(Child in Childrens) { + if (Child instanceof StealC_Password_Box) { + Total += 1; + } + } + return Total; + } + + function RefreshUnlockComplete() { + local Total = GetPasswordBoxTotal(); + if (Total <= 0) { + UnlockComplete = 0.0; + return; + } + UnlockComplete = CorrectLockedCount.tofloat() / Total.tofloat(); + } + function CheckSpaceLock() { if (!Visible) { return; @@ -206,8 +230,9 @@ class StealC extends LenheartNewUI_Windows { if (!FocusBox) { return; } - if (FocusBox.TryLockByLine(GetLockCenterY(), LockTolerancePx)) { + if (FocusBox.TryLockByRect(GetLockTopY(), LockBoxHeight, LockSnapOffsetY)) { CorrectLockedCount += 1; + RefreshUnlockComplete(); } }