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(); } }