Rindro-Sqr/Project/Tuguan/Tuguan.nut

415 lines
16 KiB
Plaintext

/*
文件名:Tuguan.nut
路径:Project/Tuguan/Tuguan.nut
创建日期:2024-08-06 21:53
文件用途:土罐
*/
class Tuguan_NewC extends LenheartNewUI_Windows {
//调试模式
// DeBugMode = true;
//默认显示状态需要是关闭 因为要通过收包打开
Visible = false;
//初始化状态
InitState = false;
//抽奖模式
OpenFlag = 1;
//主界面音效播放开关
MainSoundsSw = 0;
ASoundSw = 0;
SSoundSw = 0;
State = 0;
BoxId = null;
BoxCount = null;
ProbabilityTab = "www.qq.com";
BoxWindowName = "土罐的黄金袖珍罐";
//Ani对象
P1_01 = null;
P2_01 = null;
P3_01 = null;
P4_02 = null;
MainEffAni = null;
AniType = null;
RewardObj = null;
//界面回包
function TuguanConfigCallBack(Chunk) {
local Jso = Json.Decode(Chunk);
if (State == 0) {
BoxId = Jso.BoxId;
BoxCount = Jso.BoxCount;
ProbabilityTab = Jso.ProbabilityTab;
State = 2;
}
//读取物品名称
local ItemObject = L_sq_GetItem(BoxId);
local NamePointer = L_sq_RA(ItemObject + 0x20);
local Name = NativePointer(L_sq_I2P(NamePointer)).readUnicodeString();
BoxWindowName = Name;
Visible = true;
//初始化完成
InitState = true;
}
PackTime = 0;
//抽奖回包
function TuguanRewardCallBack(Chunk) {
local Jso = Json.Decode(Chunk);
AniType = Jso.AniType;
BoxCount = Jso.BoxCount;
RewardObj = Jso.itemBuffers;
PackTime = Clock();
State = 3;
}
//绘制抽奖动画
function DrawRewardAni(obj) {
//停止斗篷风声
obj.stopSound(2022121701);
P1_01 = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/" + AniType + "/" + AniType + "1_01.ani", X + 20, Y + 30, "TuguanSystemDrawReward" + AniType + "1_01" + PackTime);
//土罐眼睛闪光
if (P1_01 && sq_GetAnimationFrameIndex(P1_01) == 13) {
if (AniType == "a" || AniType == "s") obj.sq_PlaySound("DANJIN_START_AS");
else obj.sq_PlaySound("DANJIN_START_N");
}
if (P1_01 && sq_IsEnd(P1_01)) P2_01 = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/" + AniType + "/" + AniType + "2_01.ani", X + 20, Y + 30, "TuguanSystemDrawReward" + AniType + "2_01" + PackTime);
if (P2_01 && sq_GetAnimationFrameIndex(P2_01) == 0) {
if (AniType == "b") obj.sq_PlaySound("DANJIN_SUMMON_B");
else if (AniType == "a") obj.sq_PlaySound("DANJIN_SUMMON_A");
else if (AniType == "s") obj.sq_PlaySound("DANJIN_SUMMON_S");
}
if (P2_01 && sq_GetAnimationFrameIndex(P2_01) == 8) {
if (AniType == "b") obj.sq_PlaySound("DANJIN_GAMBLE_B");
else if (AniType == "a") obj.sq_PlaySound("DANJIN_GAMBLE_A");
else if (AniType == "s") obj.sq_PlaySound("DANJIN_GAMBLE_S");
}
if (P2_01 && sq_IsEnd(P2_01)) P3_01 = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/" + AniType + "/" + AniType + "3_01.ani", X + 20, Y + 30, "TuguanSystemDrawReward" + AniType + "3_01" + PackTime);
if (P3_01 && sq_IsEnd(P3_01)) P4_02 = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/" + AniType + "/" + AniType + "4_02.ani", X + 20, Y + 30, "TuguanSystemDrawReward" + AniType + "4_02" + PackTime);
if (P4_02 && sq_IsEnd(P4_02)) {
P1_01 = null;
P2_01 = null;
P3_01 = null;
P4_02 = null;
obj.sq_PlaySound("DANJIN_GAMBLE_FIN");
State = 4;
}
}
//绘制奖励列表
function DrawRewardItem(obj) {
//单抽
if (OpenFlag == 1) {
T_DrawStayAni(obj, "common/tuguan/main.ani", X + 20, Y + 30, 5, "TuguanRewardMain");
L_sq_DrawCode("最后结果", (X - 195) + 377, (Y - 100) + 182, sq_RGBA(255, 177, 0, 250), 1, 1);
T_DrawStayAni(obj, "common/tuguan/main.ani", X + 20 + 141, Y + 30 + 91, 7, "TuguanRewardMainOneX");
for (local z = 0; z< 2; z++) {
//绘制槽
T_DrawStayAni(obj, "common/tuguan/main.ani", X + 20 + 141 + 9 + (z * 34), Y + 30 + 91 + 9, 8, "TuguanRewardMainOneXx");
}
for (local x = 0; x< 2; x++) {
//品级背景光
local Rarity = RewardObj[0][x]["typ"];
switch (Rarity) {
case 2:
T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/light_iconslot.ani", X + 20 + 141 + 9 + (x * 34), Y + 30 + 91 + 9, "TuguanRewardMainoieff" + Rarity + PackTime);
break;
case 3:
T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/light_iconslot_1.ani", X + 20 + 141 + 9 + (x * 34), Y + 30 + 91 + 9, "TuguanRewardMainoieff" + Rarity + PackTime);
break;
}
}
for (local i = 0; i< 2; i++) {
local ItemId = RewardObj[0][i]["itemid"];
local ItemCount = RewardObj[0][i]["num"];
//绘制物品
DrawItemEx(X + 20 + 141 + 9 + (i * 34) + 3, Y + 30 + 91 + 9 + 3, ItemId, ItemCount);
//物品刷新光
local Ani = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/common_excute_icon_front_a.ani", X + 20 + 141 + 13 + (i * 34), Y + 30 + 91 + 12, "TuguanRewardMainoieff" + i + PackTime);
//品级闪烁光
local Rarity = RewardObj[0][i]["typ"];
switch (Rarity) {
case 2:
if (ASoundSw == 0) {
obj.sq_PlaySound("DANJIN_GAMBLE_CLASS_A");
ASoundSw = 1;
}
local RAni = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/iconslot_00.ani", X + 20 + 141 + 13 + (i * 34), Y + 30 + 91 + 12, "TuguanRewardMainoreff" + 2 + PackTime);
break;
case 3:
if (SSoundSw == 0) {
obj.sq_PlaySound("DANJIN_GAMBLE_FANFARE");
SSoundSw = 1;
}
local RAni = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/iconslot_01.ani", X + 20 + 141 + 13 + (i * 34), Y + 30 + 91 + 12, "TuguanRewardMainoreff" + 3 + PackTime);
break;
}
}
L_sq_DrawCode("祝你发大财!", (X - 195) + 371, (Y - 100) + 320, sq_RGBA(255, 177, 0, 250), 1, 1);
}
//10连抽
else if (OpenFlag == 10) {
T_DrawStayAni(obj, "common/tuguan/main.ani", X + 20, Y + 30, 6, "TuguanRewardMainT");
L_sq_DrawCode("最后结果", (X - 195) + 377, (Y - 100) + 142, sq_RGBA(255, 177, 0, 250), 1, 1);
for (local i = 0; i< 10; i++) {
local ofs = i;
if (i > 7) ofs += 1;
T_DrawStayAni(obj, "common/tuguan/main.ani", (X - 195) + 198 + 30 + ((ofs % 4) * 86), Y + 62 + ((ofs / 4) * 50), 7, "TuguanRewardMainTenX");
for (local y = 0; y< 2; y++) {
//绘制槽
T_DrawStayAni(obj, "common/tuguan/main.ani", (X - 195) + 198 + 30 + 9 + ((ofs % 4) * 86) + (y * 34), Y + 62 + 9 + ((ofs / 4) * 50), 8, "TuguanRewardMainOneXx");
}
for (local x = 0; x< 2; x++) {
//品级背景光
local Rarity = RewardObj[i][x]["typ"];
switch (Rarity) {
case 2:
T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/light_iconslot.ani", (X - 195) + 198 + 30 + 10 + ((ofs % 4) * 86) + (x * 34), Y + 62 + 10 + ((ofs / 4) * 50), "TuguanRewardMainoieff" + Rarity + PackTime);
break;
case 3:
T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/light_iconslot_1.ani", (X - 195) + 198 + 30 + 10 + ((ofs % 4) * 86) + (x * 34), Y + 62 + 10 + ((ofs / 4) * 50), "TuguanRewardMainoieff" + Rarity + PackTime);
break;
}
}
for (local z = 0; z< 2; z++) {
local ItemId = RewardObj[i][z]["itemid"];
local ItemCount = RewardObj[i][z]["num"];
//绘制物品
DrawItemEx((X - 195) + 198 + 30 + 9 + ((ofs % 4) * 86) + (z * 34) + 3, Y + 62 + 9 + ((ofs / 4) * 50) + 3, ItemId, ItemCount);
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, (X - 195) + 198 + 30 + 9 + ((ofs % 4) * 86) + (z * 34) + 3, Y + 62 + 9 + ((ofs / 4) * 50) + 3, 24, 24)) {
ItemInfoDrawS = {};
ItemInfoDrawS.X <- (X - 195) + 198 + 30 + 9 + ((ofs % 4) * 86) + (z * 34) + 3;
ItemInfoDrawS.Y <- Y + 62 + 9 + ((ofs / 4) * 50) + 3;
ItemInfoDrawS.ItemId <- ItemId;
}
//物品刷新光
local Ani = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/common_excute_icon_front_a.ani", (X - 195) + 198 + 30 + 13 + ((ofs % 4) * 86) + (z * 34), Y + 62 + 12 + ((ofs / 4) * 50), "TuguanRewardMainoieff" + z + PackTime);
//品级闪烁光
local Rarity = RewardObj[i][z]["typ"];
switch (Rarity) {
case 2:
if (ASoundSw == 0) {
obj.sq_PlaySound("DANJIN_GAMBLE_CLASS_A");
ASoundSw = 1;
}
local RAni = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/iconslot_00.ani", (X - 195) + 198 + 30 + 13 + ((ofs % 4) * 86) + (z * 34), Y + 62 + 12 + ((ofs / 4) * 50), "TuguanRewardMainoreff" + 2 + PackTime);
break;
case 3:
if (SSoundSw == 0) {
obj.sq_PlaySound("DANJIN_GAMBLE_FANFARE");
SSoundSw = 1;
}
local RAni = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/iconslot_01.ani", (X - 195) + 198 + 30 + 13 + ((ofs % 4) * 86) + (z * 34), Y + 62 + 12 + ((ofs / 4) * 50), "TuguanRewardMainoreff" + 3);
break;
}
}
}
L_sq_DrawCode("祝你发大财!", (X - 195) + 371, (Y - 100) + 336, sq_RGBA(255, 177, 0, 250), 1, 1);
}
MainEffAni = T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/background_excute_front_supreme.ani", X + 20, Y + 30, "TuguanSystemDrawRewardMainAniL" + PackTime);
}
//播放主界面音效
function PlayMainSounds(obj) {
if (State == 2 && MainSoundsSw == 0) {
obj.sq_PlaySound("DANJIN_START_LOOP", 2022121701);
MainSoundsSw = 1;
}
if (State != 2 && State != 3) {
obj.stopSound(2022121701);
MainSoundsSw = 0;
}
if (State != 4) {
SSoundSw = 0;
ASoundSw = 0;
}
}
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
Childrens = [];
//注册控件
RegisterWidget();
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
//土罐开启界面回包
Pack_Control.rawset(20071004, TuguanConfigCallBack.bindenv(this));
//抽奖奖励回包
Pack_Control.rawset(20071008, TuguanRewardCallBack.bindenv(this));
}
function RegisterWidget() {
//关闭按钮
local CloseButton = LenheartNewUI_BaseButton(386, 2, 11, 12, "interface/lenheartwindowcommon.img", 276);
CloseButton.OnClick = function() {
this.Visible = false;
}.bindenv(this);
Childrens.append(CloseButton);
//单抽复选框
local OneOpenBtn = LenheartNewUI_SwitchButtonText(16 + 50, 30 + 253, "开启1个");
OneOpenBtn.ImgIndex = 358;
OneOpenBtn.SetTextPos(12, 2);
OneOpenBtn.Width = 76;
OneOpenBtn.Height = 16;
OneOpenBtn.OnClick = function() {
switch (OpenFlag) {
case 1:
OpenFlag = 10;
break;
case 10:
OpenFlag = 1;
break;
}
State = 2;
}.bindenv(this);
OneOpenBtn.SetCallBackFunc(function(obj) {
if (OpenFlag == 1) obj.State = 1;
else obj.State = 0;
}.bindenv(this));
AddChild(OneOpenBtn);
//单抽复选框
local TenOpenBtn = LenheartNewUI_SwitchButtonText(16 + 50 + 204, 30 + 253, "开启10个");
TenOpenBtn.ImgIndex = 358;
TenOpenBtn.SetTextPos(12, 2);
TenOpenBtn.Width = 76;
TenOpenBtn.Height = 16;
TenOpenBtn.OnClick = function() {
switch (OpenFlag) {
case 1:
OpenFlag = 10;
break;
case 10:
OpenFlag = 1;
break;
}
State = 2;
}.bindenv(this);
TenOpenBtn.SetCallBackFunc(function(obj) {
if (OpenFlag == 10) obj.State = 1;
else obj.State = 0;
}.bindenv(this));
AddChild(TenOpenBtn);
//搜索按钮
local ProbabilityButton = LenheartNewUI_ButtonText(18, 28 + 290, 5, "※查看概率");
ProbabilityButton.Idx = 74; //很小的图 这样就不会显示按钮了
ProbabilityButton.SetTextOffset(-14, 1);
ProbabilityButton.OnClick = function() {
L_Cmd("start iexplore.exe " + ProbabilityTab);
}.bindenv(this);
AddChild(ProbabilityButton);
//抽奖按钮
local OpenButton = LenheartNewUI_ButtonText(18 + 157, 66 + 280, 5, "开启");
OpenButton.SetTextOffset(-1, 1);
OpenButton.OnClick = function() {
local T = {
op = 20071005,
Num = OpenFlag
}
SendPackEx(T);
}.bindenv(this);
AddChild(OpenButton);
}
//绘制主界面
function DrawMain(obj) {
if (!InitState) return;
//窗口
L_sq_DrawImg("tuguan/main.img", 0, X, Y);
//标题
L_sq_DrawCode(BoxWindowName, X + 200 - LenheartTextClass.GetStringLength(BoxWindowName) / 2, Y + 6, sq_RGBA(230, 200, 155, 250), 1, 1);
//动画
if (State == 2) T_DrawDynamicAni(obj, "common/tuguan/0510_danjinjar/lobby/lobby_wait_rank_1step_1_step_common_0510_danjin_body.ani", X + 20, Y + 30, "New_TuguanSystemMainbackgroundeff");
//抽奖动画
if (State == 3) {
DrawRewardAni(obj);
}
//奖励列表
if (State == 4) {
DrawRewardItem(obj);
}
//遮罩
T_DrawStayAni(obj, "common/tuguan/main.ani", X + 17, Y + 26, 1, "TuguanSystemMainbackgroundblack");
//图标框
T_DrawStayAni(obj, "common/tuguan/main.ani", X + 187, Y + 26 + 250, 3, "TuguanSystemMainbackgrounditem");
//盒子数量
DrawItemEx(X + 187 + 3, Y + 26 + 250 + 3, BoxId, BoxCount);
// if (State == 2) ItemInfoDrawS = null;
}
function Show(obj) {
DrawMain(obj);
//播放主界面音效
PlayMainSounds(obj);
LenheartNewUI_Windows.Show(obj);
}
//逻辑入口
function Proc(obj) {
LenheartNewUI_Windows.SyncPos(X, Y);
}
}
getroottable().rawdelete("Tuguan_NewC_Obj");
function Lenheart_Tuguan_New(obj) {
local RootTab = getroottable();
if (!RootTab.rawin("Tuguan_NewC_Obj")) {
RootTab.rawset("Tuguan_NewC_Obj", true);
LenheartNewUI_CreateWindow(Tuguan_NewC, "新土罐窗口", ((getroottable().Rindro_Scr_Width - 405) / 2).tointeger(), 64, 405, 372, 28);
}
}
getroottable()["LenheartFuncTab"].rawset("Lenheart_Tuguan_NewFunc", Lenheart_Tuguan_New);