190 lines
7.9 KiB
Plaintext
190 lines
7.9 KiB
Plaintext
/*
|
|
文件名:TreasureGoblin.nut
|
|
路径:Project/TreasureGoblin/TreasureGoblin.nut
|
|
创建日期:2025-08-06 09:34
|
|
文件用途:TreasureGoblin
|
|
*/
|
|
class TreasureGoblinC extends LenheartNewUI_Windows {
|
|
//调试模式
|
|
// DeBugMode = true;
|
|
|
|
//不是窗口
|
|
// NoWindow = true;
|
|
|
|
//是否可见
|
|
// Visible = false;
|
|
|
|
BaseImg = Rindro_Image("interface2/rindro_reward.img");
|
|
MainImg = Rindro_Image("treasuregoblin/main.img");
|
|
|
|
|
|
//窗口名称
|
|
WindowTitle = "普通宝藏哥布林的宝箱";
|
|
|
|
//搜索时间Flag
|
|
SearchTimeFlag = 0;
|
|
//搜索时间品级对应表
|
|
SearchTimeGradeTable = [1000, 1500, 2000, 2500, 3000, 3500];
|
|
|
|
//奖励包
|
|
RewardPackage = null;
|
|
|
|
//动画队列
|
|
AniQueue = null;
|
|
|
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
|
Childrens = [];
|
|
|
|
AniQueue = QuestQueue();;
|
|
//注册控件
|
|
RegisterWidget();
|
|
|
|
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
|
|
|
|
|
local RewList = [7422, 7422, 7422, 7422, 7422, 2682154, 2682154, 2682154, 2682154, 2682154, 10007482, 10007482, 10007482, 10007482, 10007482, 10007483, 10007483, 10007483, 10007483, 10007483, 10007484, 10007484, 10007484, 10007484, 10007484, 10092470, 10092470, 10092470, 10092470, 10092470, 490701711, 490701711, 490701711, 490701711, 490701711, 490701712, 490701712, 490701712, 490701712, 490701712, 2660671, 2660671, 2660671, 2660671, 2660671, 2660672, 2660672, 2660672, 2660672, 2660672, 7163, 1298, 2682833, 7163, 1298, 2682833, 7163, 1298, 2682833, 2682834, 2682835, 10007249, 10007250, 10007251, 10015164, 10015165, 10015166, 10015167, 10015168, 10015169, 10015170, 10015171, 10015172, 10015173, 10015174, 490001458, 490001942, 490001937, 490001941, 490002485, 490001940, 490001956, 490001693, 490011087, 490703966, 490702732, 490702941, 490700168, 10008064, 10008065, 10008066, 10008067, 10008068, 10008069, 10008070, 10008071, 10008072, 10008073, 10008074, 10008075, 10008076, 10008077, 10008078, 10008079, 10008080, 10008081, 10008082, 10008083, 10008084, 10008085, 10008086, 10008087, 10008088, 10008089, 10008090, 10008091, 10008092, 10008093, 10008094, 10008095, 10008096, 10008097, 10008098, 10008099, 10008100, 10008101, 10008102, 10008103, 10008104, 10008105, 10008106, 10008107, 10008910, 10008911, 8381, 2681176, 2681177, 2681178, 2681179, 2681180, 2681181, 2681182, 2681183, 2681184, 2681185, 2681186, 2681187, 2681482, 2681483, 2681486, 2681487, 2747554, 2747555, 2747556, 2747557, 2747558, 2747559, 2747560, 2747561, 20210112, 20210113];
|
|
|
|
RewardPackage = [];
|
|
for (local i = 0; i< sq_getRandom(5, 16); i++) {
|
|
local T = {};
|
|
T.ItemId <- RewList[sq_getRandom(0, RewList.len() - 1)];
|
|
T.Count <- sq_getRandom(1, 5);
|
|
T.IsSearch <- false; //是否已经搜索
|
|
// T.Grade <- L_sq_RA(L_sq_GetItem(T.ItemId) + 0xF4); //到时候品级由服务端决定下发
|
|
// T.Grade <- L_sq_RA(L_sq_GetItem(T.ItemId) + 0xF4);
|
|
T.Grade <- sq_getRandom(4, 5);
|
|
RewardPackage.append(T);
|
|
}
|
|
}
|
|
|
|
function RegisterWidget() {
|
|
//关闭按钮
|
|
local CloseButton = LenheartNewUI_BaseButton(303, 6, 11, 12, "interface/lenheartwindowcommon.img", 276);
|
|
CloseButton.OnClick = function() {
|
|
this.Visible = false;
|
|
}.bindenv(this);
|
|
Childrens.append(CloseButton);
|
|
|
|
local PickAllButton = LenheartNewUI_ButtonText(108, 341, 45, "全部拾取");
|
|
PickAllButton.SetTextOffset(9, 1);
|
|
PickAllButton.OnClick = function() {
|
|
|
|
}.bindenv(this);
|
|
AddChild(PickAllButton);
|
|
}
|
|
|
|
|
|
|
|
//绘制主界面
|
|
function DrawMain(obj) {
|
|
|
|
//绘制标题
|
|
DrawWindowTitle(318);
|
|
//绘制标题名
|
|
L_sq_DrawCode(WindowTitle, X + 158 - LenheartTextClass.GetStringLength(WindowTitle) / 2, Y + 7, sq_RGBA(230, 200, 155, 255), 0, 1);
|
|
|
|
//绘制窗口
|
|
DrawNineBox(X, Y + 23, 316, 350, "interface/lenheartwindowcommon.img", 213); //背景框
|
|
|
|
//绘制内嵌窗口
|
|
DrawNineBox(X + 8, Y + 32, 299, 299, "interface/lenheartwindowcommon.img", 204); //背景框
|
|
|
|
//绘制分割线
|
|
MainImg.DrawExPng(0, X + 10, Y + 34, 0, sq_RGBA(127, 132, 142, 250), 1.0, 1.0);
|
|
|
|
|
|
if (RewardPackage) {
|
|
foreach(Index, Info in RewardPackage) {
|
|
local XPos = X + 11 + ((Index % 8) * 37);
|
|
local YPos = Y + ((Index / 8).tointeger() * 37) + 35;
|
|
if (Info.IsSearch) {
|
|
BaseImg.DrawPng(Info.Grade, XPos, YPos);
|
|
DrawItemBase(XPos + 3, YPos + 3, Info.ItemId, Info.Count);
|
|
} else {
|
|
MainImg.DrawPng(1, XPos + 10, YPos + 10);
|
|
}
|
|
}
|
|
|
|
foreach(Index, Info in RewardPackage) {
|
|
local XPos = X + 11 + ((Index % 8) * 37);
|
|
local YPos = Y + ((Index / 8).tointeger() * 37) + 35;
|
|
//如果是没有搜索状态
|
|
if (!Info.IsSearch) {
|
|
//还没有开始计时
|
|
if (!Info.rawin("SeachTimer")) {
|
|
Info.SeachTimer <- 0;
|
|
}
|
|
if (Duration< 100) Info.SeachTimer += Duration;
|
|
if (Info.SeachTimer< SearchTimeGradeTable[Info.Grade]) {
|
|
local T = GetClockwiseCirclePoint(Info.SeachTimer / 1300.0, 0, 0, 6);
|
|
Rindro_Image_GlobalMap["lenheartui"].DrawPng(159, XPos + 12 + T.x, YPos + 12 + T.y);
|
|
} else {
|
|
Info.IsSearch = true;
|
|
R_Utils.PlaySound("ICON_KEY");
|
|
|
|
AniQueue.AddQuest("搜索完成动画" + Info.Grade, function(Name, Time, Grade, XPos, YPos) {
|
|
local AniPath = "common/item_effect/custom_2option_setting.ani";
|
|
if (Grade == 3) AniPath = "common/item_effect/custom_3option.ani";
|
|
if (Grade == 5) AniPath = "common/item_effect/custom_4option.ani";
|
|
if (Grade == 4) AniPath = "common/item_effect/custom_honor_4option.ani";
|
|
local Ani = DrawAniEx(XPos, YPos, AniPath);
|
|
if (sq_GetAnimationFrameIndex(Ani) == 14) {
|
|
sq_Rewind(Ani);
|
|
AniQueue.RemoveQuest(Name);
|
|
}
|
|
}.bindenv(this), Info.Grade, XPos + 1, YPos + 1);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function Show(obj) {
|
|
DrawMain(obj);
|
|
AniQueue.Run();
|
|
LenheartNewUI_Windows.Show(obj);
|
|
}
|
|
|
|
//逻辑入口
|
|
function Proc(obj) {
|
|
LenheartNewUI_Windows.SyncPos(X, Y);
|
|
IsFocus = true;
|
|
}
|
|
|
|
function GetClockwiseCirclePoint(dt, centerX, centerY, radius) {
|
|
// 将dt映射到角度(0到2π弧度),并反转方向实现顺时针
|
|
local angle = 2 * 3.1415926535 * (1.0 - dt);
|
|
|
|
// 计算相对圆心的偏移量
|
|
local offsetX = radius * cos(angle);
|
|
local offsetY = radius * sin(angle);
|
|
|
|
// 返回包含坐标的表
|
|
return {
|
|
x = centerX + offsetX,
|
|
y = centerY + offsetY
|
|
};
|
|
}
|
|
}
|
|
getroottable().rawdelete("TreasureGoblin_Obj");
|
|
|
|
function Lenheart_TreasureGoblin_Fun(obj) {
|
|
local RootTab = getroottable();
|
|
if (!RootTab.rawin("TreasureGoblin_Obj")) {
|
|
RootTab.rawset("TreasureGoblin_Obj", true);
|
|
LenheartNewUI_CreateWindow(TreasureGoblinC, "宝藏哥布林的宝箱窗口", ((getroottable().Rindro_Scr_Width - 317) / 2).tointeger(), 80, 317, 370, 26);
|
|
}
|
|
}
|
|
|
|
getroottable()["LenheartFuncTab"].rawset("TreasureGoblinFuncN", Lenheart_TreasureGoblin_Fun);
|
|
|
|
|
|
|
|
|
|
L_Windows_List <- [];
|
|
getroottable().rawdelete("LenheartPluginsInitFlag");
|
|
getroottable().rawdelete("EventList_Obj")
|
|
getroottable().rawdelete("TreasureGoblin_Obj");
|
|
|
|
// L_sq_GoDungeon(3709); |