Rindro-Sqr/Project/AradPass/AradPass_Reward.nut

428 lines
19 KiB
Plaintext
Raw Normal View History

2024-09-16 17:09:36 +08:00
/*
文件名:AradPass_Reward.nut
路径:Project/AradPass/AradPass_Reward.nut
创建日期:2024-08-13 22:17
文件用途:奖励
*/
class AradPass_RewardC extends LenheartNewUI_Windows {
//调试模式
// DeBugMode = true;
//不是窗口
// NoWindow = true;
//是否可见
Visible = false;
//等级按钮数组
LevelButton = null;
//当前页面
Page = 0;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
Childrens = [];
LevelButton = [];
//注册控件
RegisterWidget();
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
}
//因为要重载LenheartNewUI_Windows的构造函数
function ResetFocus() {
}
function ChangePage(ToPage) {
foreach(ButtonObj in LevelButton) {
ButtonObj.State = 0;
}
LevelButton[ToPage].State = 1;
Page = ToPage;
}
function RegisterWidget() {
//注册等级按钮
local LevelButton_1 = LenheartNewUI_TabbarsText(61, 215, "1 - 10", 88, 25);
LevelButton_1.SetFrame("interface2/ui/aradpass/chn/aradpass.img", 15);
LevelButton_1.SetTextOffset(42 - LenheartTextClass.GetStringLength("1 - 10") / 2, 6);
LevelButton_1.State = 1;
LevelButton_1.OnClick = function() {
ChangePage(0);
}.bindenv(this);
AddChild(LevelButton_1);
LevelButton.append(LevelButton_1);
local LevelButton_2 = LenheartNewUI_TabbarsText(154, 215, "11 - 20", 88, 25);
LevelButton_2.SetFrame("interface2/ui/aradpass/chn/aradpass.img", 15);
LevelButton_2.SetTextOffset(42 - LenheartTextClass.GetStringLength("11 - 20") / 2, 6);
LevelButton_2.OnClick = function() {
ChangePage(1);
}.bindenv(this);
AddChild(LevelButton_2);
LevelButton.append(LevelButton_2);
local LevelButton_3 = LenheartNewUI_TabbarsText(247, 215, "21 - 30", 88, 25);
LevelButton_3.SetFrame("interface2/ui/aradpass/chn/aradpass.img", 15);
LevelButton_3.SetTextOffset(42 - LenheartTextClass.GetStringLength("11 - 20") / 2, 6);
LevelButton_3.OnClick = function() {
ChangePage(2);
}.bindenv(this);
AddChild(LevelButton_3);
LevelButton.append(LevelButton_3);
local LevelButton_4 = LenheartNewUI_TabbarsText(340, 215, "31 - 40", 88, 25);
LevelButton_4.SetFrame("interface2/ui/aradpass/chn/aradpass.img", 15);
LevelButton_4.SetTextOffset(42 - LenheartTextClass.GetStringLength("11 - 20") / 2, 6);
LevelButton_4.OnClick = function() {
ChangePage(3);
}.bindenv(this);
AddChild(LevelButton_4);
LevelButton.append(LevelButton_4);
local LevelButton_5 = LenheartNewUI_TabbarsText(433, 215, "41 - 50", 88, 25);
LevelButton_5.SetFrame("interface2/ui/aradpass/chn/aradpass.img", 15);
LevelButton_5.SetTextOffset(42 - LenheartTextClass.GetStringLength("11 - 20") / 2, 6);
LevelButton_5.OnClick = function() {
ChangePage(4);
}.bindenv(this);
AddChild(LevelButton_5);
LevelButton.append(LevelButton_5);
//全部领取按钮
local ClaimAllButton = LenheartNewUI_ButtonText(460, 440, 15, "全部领取");
ClaimAllButton.SetFrame(null, 323);
ClaimAllButton.SetTextOffset(-7, 1);
ClaimAllButton.OnClick = function() {
local T = {
op = 20059009
}
SendPackEx(T);
}.bindenv(this);
AddChild(ClaimAllButton);
}
//绘制主界面
function DrawMain(obj) {
if (!Parent.BaseInfo) return;
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 1, X + 11, Y - 210 + 50 + 162);
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 2, X + 11, Y - 210 + 50 + 162 + 214);
L_sq_DrawCode("区", X + 11 + 14, Y - 210 + 50 + 162 + 14, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawCode("间", X + 11 + 14, Y - 210 + 50 + 162 + 14 + 19, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawCode("免", X + 11 + 14, Y - 210 + 50 + 162 + 14 + 19 + 47, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawCode("费", X + 11 + 14, Y - 210 + 50 + 162 + 14 + 19 + 47 + 19, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawCode("追", X + 11 + 14, Y - 210 + 50 + 162 + 14 + 19 + 47 + 19 + 54, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawCode("加", X + 11 + 14, Y - 210 + 50 + 162 + 14 + 19 + 47 + 19 + 54 + 19, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 19, X + 11, Y - 210 + 240);
if (LevelButton.len() > 0) {
foreach(Pos, Value in LevelButton) {
if (Value.State == 1) {
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 18, X + 11 + 50 + (Pos * 93), Y - 210 + 215);
}
//绘制是否可领取奖励的感叹号
if (Parent.RewardSuccessTips[Pos] == 1) {
L_sq_DrawImg("interface/Lenheartwindowcommon.img", 301, X + 125 + (Pos * 93), Y - 210 + 224, 0, sq_RGBA(255, 255, 255, 210), 0.8, 0.8);
}
}
}
for (local i = 0; i< 10; i++) {
DrawSmallNumber(i + 1 + (Page * 10), 124 - 91 + (i * 47));
}
DrawRewardItem(obj);
L_sq_DrawImg("interface/Lenheartwindowcommon.img", 504, X + 24, Y - 210 + 438, 0, sq_RGBA(255, 255, 255, 250), 0.8, 0.8);
L_sq_DrawImg("interface/Lenheartwindowcommon.img", 504, X + 24, Y - 210 + 460, 0, sq_RGBA(255, 255, 255, 250), 0.8, 0.8);
L_sq_DrawCode("获得的物品将发放至物品栏。", X + 44, Y - 210 + 438, sq_RGBA(179, 169, 135, 150), 1, 1);
L_sq_DrawCode("未使用的奖励道具将在本季通行券结束时删除。", X + 44, Y - 210 + 460, sq_RGBA(179, 169, 135, 150), 1, 1);
}
//绘制奖励
function DrawRewardItem(obj) {
local Idx = Page * 10;
for (local i = 0; i< 10; i++) {
//奖励下标
local RealPos = Idx + i;
if (RealPos in Parent.RewardInfoObject) {
local RewardObject = Parent.RewardInfoObject[RealPos];
//普通道具
if ("itemid" in RewardObject) {
//普通底
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 21, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 61);
DrawItemBase(X + 64 + (i * 47), Y - 210 + 296, RewardObject.itemid, RewardObject.num);
//已领取
if (RewardObject.isOrdinary) {
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 23, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 61);
}
//未领取
else if (!RewardObject.isOrdinary) {
//快达到等级
if ((RealPos + 1) == Parent.MyPassLevel + 1) {
}
//已达到等级
else if ((RealPos + 1) <= Parent.MyPassLevel) {
local A = 60;
if (Parent.RewardInfoEffTimer) {
if (Clock() - Parent.RewardInfoEffTimer <= 1000) {
A = sq_GetUniformVelocity(60, 255, Clock() - Parent.RewardInfoEffTimer, 1000);
}
if (Clock() - Parent.RewardInfoEffTimer <= 2000 && Clock() - Parent.RewardInfoEffTimer > 1000) {
A = sq_GetUniformVelocity(255, 60, Clock() - Parent.RewardInfoEffTimer - 1000, 1000);
}
if (Clock() - Parent.RewardInfoEffTimer > 2000) {
Parent.RewardInfoEffTimer = Clock();
}
}
L_sq_SetDrawImgModel(2, 0);
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 29, X + 7 + 45 + (i * 47), Y - 210 + 50 + 162 + 58, 0, sq_RGBA(255, 255, 255, A), 1.0, 1.0);
L_sq_ReleaseDrawImgModel();
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X + 7 + 45 + (i * 47), Y - 210 + 50 + 162 + 58, 44, 74)) {
if (MouseClickFlag) {
local T = {
op = 20059007,
Type = 0,
lv = RealPos + 1,
}
SendPackEx(T);
}
}
}
//未达到等级
else {
//普通底Eff 未领取
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 33, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 61);
}
}
}
//是不是VIP
local IsVip = Parent.BaseInfo.isVip;
//进阶道具
if ("additionalItemId" in RewardObject && "additionalItemId2" in RewardObject) {
//普通底
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 26, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 138);
DrawItemBase(X + 64 + (i * 47), Y - 210 + 356, RewardObject.additionalItemId, RewardObject.additionalNum);
DrawItemBase(X + 64 + (i * 47), Y - 210 + 390, RewardObject.additionalItemId2, RewardObject.additionalNum2);
if (RewardObject.isadditional) {
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 28, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 138);
} else {
if (!IsVip) {
//普通底
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 32, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 138);
} else {
//快达到等级
if ((RealPos + 1) == Parent.MyPassLevel + 1) {
}
//已达到等级
else if ((RealPos + 1) <= Parent.MyPassLevel) {
local A = 60;
if (Parent.RewardInfoEffTimer) {
if (Clock() - Parent.RewardInfoEffTimer <= 1000) {
A = sq_GetUniformVelocity(60, 255, Clock() - Parent.RewardInfoEffTimer, 1000);
}
if (Clock() - Parent.RewardInfoEffTimer <= 2000 && Clock() - Parent.RewardInfoEffTimer > 1000) {
A = sq_GetUniformVelocity(255, 60, Clock() - Parent.RewardInfoEffTimer - 1000, 1000);
}
if (Clock() - Parent.RewardInfoEffTimer > 2000) {
Parent.RewardInfoEffTimer = Clock();
}
}
L_sq_SetDrawImgModel(2, 0);
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 30, X + 7 + 45 + (i * 47), Y - 210 + 45 + 162 + 138, 0, sq_RGBA(255, 255, 255, A), 1.0, 1.0);
L_sq_ReleaseDrawImgModel();
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X + 7 + 45 + (i * 47), Y - 210 + 45 + 162 + 138, 44, 74)) {
if (MouseClickFlag) {
local T = {
op = 20059007,
Type = 1,
lv = RealPos + 1,
}
SendPackEx(T);
}
}
}
//未达到等级
else {
//普通底Eff 未领取
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 33, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 138);
}
}
}
} else {
//普通底
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 25, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 138);
DrawItemBase(X + 64 + (i * 47), Y - 210 + 373, RewardObject.additionalItemId, RewardObject.additionalNum);
if (RewardObject.isadditional) {
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 27, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 138);
} else {
if (!IsVip) {
//普通底
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 31, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 138);
} else {
//快达到等级
if ((RealPos + 1) == Parent.MyPassLevel + 1) {
}
//已达到等级
else if ((RealPos + 1) <= Parent.MyPassLevel) {
local A = 60;
if (Parent.RewardInfoEffTimer) {
if (Clock() - Parent.RewardInfoEffTimer <= 1000) {
A = sq_GetUniformVelocity(60, 255, Clock() - Parent.RewardInfoEffTimer, 1000);
}
if (Clock() - Parent.RewardInfoEffTimer <= 2000 && Clock() - Parent.RewardInfoEffTimer > 1000) {
A = sq_GetUniformVelocity(255, 60, Clock() - Parent.RewardInfoEffTimer - 1000, 1000);
}
if (Clock() - Parent.RewardInfoEffTimer > 2000) {
Parent.RewardInfoEffTimer = Clock();
}
}
L_sq_SetDrawImgModel(2, 0);
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 30, X + 7 + 45 + (i * 47), Y - 210 + 45 + 162 + 138, 0, sq_RGBA(255, 255, 255, A), 1.0, 1.0);
L_sq_ReleaseDrawImgModel();
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X + 7 + 45 + (i * 47), Y - 210 + 45 + 162 + 138, 44, 74)) {
if (MouseClickFlag) {
local T = {
op = 20059007,
Type = 1,
lv = RealPos + 1,
}
SendPackEx(T);
}
}
}
//未达到等级
else {
//普通底Eff 未领取
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 33, X + 11 + 45 + (i * 47), Y - 210 + 50 + 162 + 138);
}
}
}
}
}
}
if (Parent.MyPassLevel >= Page * 10) {
//是不是VIP
local IsVip = false;
if ("isVip" in Parent.BaseInfo && Parent.BaseInfo.isVip) IsVip = true;
local MyExp;
local Rate;
if (Parent.MyPassLevel == Page * 10) {
MyExp = (Parent.BaseInfo.Exp + 1000.0) % 10000.0;
Rate = MyExp.tofloat() / 10000.0;
} else if (Parent.MyPassLevel<(Page + 1) * 10) {
MyExp = Parent.BaseInfo.Exp % 10000.0 + 1000.0;
Rate = MyExp.tofloat() / 10000.0;
} else {
Rate = 100.0;
}
local ImgIndex = 34;
if (IsVip) ImgIndex = 35;
if (Rate <= 0) Rate = 0.01;
setClip(X + 11 + 45, Y - 210, X + 11 + 45 + (470 * Rate).tointeger(), Y - 210 + 264 + 4); //开始裁切
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", ImgIndex, X + 11 + 45, Y - 210 + 264);
releaseClip(); //裁切结束
L_sq_SetDrawImgModel(2, 0);
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", ImgIndex + 2, X + 11 + 34 + (470 * Rate).tointeger(), Y - 210 + 255);
L_sq_ReleaseDrawImgModel();
}
}
//绘制等级数字
function DrawSmallNumber(num, bx) {
num = num.tostring();
local x = X + 38 + bx;
local y = Y + 40;
if (num.len() == 2) x = X + 33 + bx;
for (local i = 0; i< num.len(); i++) {
local n = num.slice(i, i + 1);
n = n.tointeger();
local Img = "interface2/ui/aradpass/chn/aradpassnum.img";
if ("isVip" in Parent.BaseInfo && Parent.BaseInfo.isVip) Img = "interface2/ui/aradpass/chn/aradpassnumy.img";
L_sq_DrawImg(Img, n, x + (i * 9), y, 0, sq_RGBA(255, 255, 255, 255), 0.5, 0.5);
}
}
MouseClickFlag = false;
//鼠标左键弹起回调
function OnMouseLbUp(MousePos_X, MousePos_Y) {
MouseClickFlag = true;
LenheartNewUI_Windows.OnMouseLbUp(MousePos_X, MousePos_Y);
}
function Show(obj) {
DrawMain(obj);
LenheartNewUI_Windows.Show(obj);
MouseClickFlag = false;
}
//逻辑入口
function Proc(obj) {
LenheartNewUI_Windows.SyncPos(X, Y - 210);
if (Parent && Parent.Visible && Parent.PageSelectM == 0) {
Visible = true;
X = Parent.X;
Y = Parent.Y + 210;
} else {
Visible = false;
}
if (IMouse.IsWheelUp()) {
if (Page > 0) {
ChangePage(Page - 1);
};
}
if (IMouse.IsWheelDown()) {
if (Page< 4) {
ChangePage(Page + 1);
};
}
}
}
// getroottable().rawdelete("AradPass_Obj");
// local T = {
// op = 20059015,
// }
// Rindro_BaseToolClass.SendPackEx(T);