328 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			328 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| class New_RotersC extends BasicsDrawTool {
 | |
|     //世界BOSS是否打开
 | |
|     EventState = false;
 | |
|     //活动开启的动画是否播放过
 | |
|     EventAnimationPlayFlag = false;
 | |
|     //活动开启动画Timer
 | |
|     EventAnimationTimer = null;
 | |
| 
 | |
| 
 | |
|     //基础奖励道具信息
 | |
|     RewardInfo = null;
 | |
|     ItemInfoObject = null;
 | |
|     ItemInfoDrawS = null;
 | |
|     //排名信息
 | |
|     RankInfo = null;
 | |
| 
 | |
|     //BOSS血量
 | |
|     BOSS_HP_RATE = 1;
 | |
| 
 | |
|     WindowObj = null; //窗口对象
 | |
|     MainState = false; //主状态
 | |
|     X = 124;
 | |
|     Y = 16;
 | |
| 
 | |
| 
 | |
|     //收包逻辑
 | |
|     function GetWolrdBossEventStateCallBack(Chunk) {
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         switch (Jso.State) {
 | |
|             //未开启
 | |
|             case 0: {
 | |
| 
 | |
|             }
 | |
|             break;
 | |
|             //开启中
 | |
|             case 1: {
 | |
|                 if (EventState == false) {
 | |
|                     EventState = true;
 | |
|                     EventAnimationPlayFlag = true;
 | |
|                     EventIcon("世界BOSS   ", 232, 232, this);
 | |
|                 }
 | |
|             }
 | |
|             break;
 | |
|             //结算中
 | |
|             case 2: {
 | |
|                 if (EventState == false) {
 | |
|                     EventState = true;
 | |
|                     EventAnimationPlayFlag = true;
 | |
|                     EventIcon("世界BOSS   ", 232, 232, this);
 | |
|                 }
 | |
|             }
 | |
|             break;
 | |
|             default:
 | |
|                 break;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //获取排名信息
 | |
|     function GetWorldBossEventRankInfoCallBack(Chunk) {
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         RankInfo = Jso.RankInfo;
 | |
|         BOSS_HP_RATE = Jso.BossHpRate;
 | |
|         if (BOSS_HP_RATE == 0) BOSS_HP_RATE = 0.01;
 | |
|     }
 | |
| 
 | |
|     //获取基础信息包
 | |
|     function GetWorldBossEventBaseInfoCallBack(Chunk) {
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         RewardInfo = Jso.RewardInfo;
 | |
|         local GetItemInfoArr = [];
 | |
|         foreach(Value in RewardInfo) {
 | |
|             if (!(ItemInfoObject.rawin(Value))) {
 | |
|                 GetItemInfoArr.append(Value);
 | |
|             }
 | |
|         }
 | |
|         if (GetItemInfoArr.len() > 0) {
 | |
|             local T = {
 | |
|                 op = 20231010,
 | |
|                 realop = 20060020,
 | |
|                 itemId = RewardInfo,
 | |
|                 Type = 2,
 | |
|             }
 | |
|             SendPack(T);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function GetWorldBossEventBaseItemInfoCallBack(Chunk) {
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         foreach(Pos, Value in Jso.itemInfo) {
 | |
|             if (Value.Name2.len() == 0)
 | |
|                 Value.Name2 = "Yosin-Team";
 | |
|             ItemInfoObject.rawset(Jso.itemId[Pos], Value);
 | |
|         }
 | |
|     }
 | |
|     //收包逻辑
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|     //发包逻辑
 | |
|     function GetWolrdBossEventState() {
 | |
|         local T = {
 | |
|             op = 20060001
 | |
|         }
 | |
|         SendPack(T);
 | |
|     }
 | |
| 
 | |
|     function GetWorldBossEventRankInfo() {
 | |
|         local T = {
 | |
|             op = 20060003,
 | |
|             Page = 0
 | |
|         }
 | |
|         SendPack(T);
 | |
|     }
 | |
| 
 | |
|     function GetWorldBossEventBaseInfo() {
 | |
|         local T = {
 | |
|             op = 20060009,
 | |
|         }
 | |
|         SendPack(T);
 | |
|     }
 | |
|     //发包逻辑
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|     constructor() {
 | |
|         ItemInfoObject = {};
 | |
|         //判断活动是否开启
 | |
|         Pack_Control.rawset(20060002, GetWolrdBossEventStateCallBack.bindenv(this));
 | |
|         //获取排名信息
 | |
|         Pack_Control.rawset(20060004, GetWorldBossEventRankInfoCallBack.bindenv(this));
 | |
|         //获取基础信息包
 | |
|         Pack_Control.rawset(20060010, GetWorldBossEventBaseInfoCallBack.bindenv(this));
 | |
|         //获取道具信息
 | |
|         Pack_Control.rawset(20060020, GetWorldBossEventBaseItemInfoCallBack.bindenv(this));
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         GetWolrdBossEventState();
 | |
|         GetWorldBossEventRankInfo();
 | |
|         GetWorldBossEventBaseInfo();
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //绘制道具带道具信息
 | |
|     function DrawItemEx(X, Y, Id, Count) {
 | |
|         L_sq_DrawImg("roters/rankmain.img", 9, X - 4, Y - 2);
 | |
|         L_Sq_DrawItem(X, Y, Id, Count, 0, 0, 0);
 | |
|         if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, 24, 24)) {
 | |
|             ItemInfoDrawS = {};
 | |
|             ItemInfoDrawS.X <- X;
 | |
|             ItemInfoDrawS.Y <- Y;
 | |
|             ItemInfoDrawS.ItemId <- Id;
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|     //绘制世界Boss渐出动画
 | |
|     function ShowEventOpenAnimation(obj) {
 | |
|         if (!EventAnimationPlayFlag) return;
 | |
|         if (EventAnimationTimer == null) EventAnimationTimer = Clock();
 | |
| 
 | |
|         local A = 60;
 | |
|         if (EventAnimationTimer) {
 | |
|             if (Clock() - EventAnimationTimer <= 2000) {
 | |
|                 A = sq_GetUniformVelocity(60, 255, Clock() - EventAnimationTimer, 2000);
 | |
|             }
 | |
|             if (Clock() - EventAnimationTimer <= 4000 && Clock() - EventAnimationTimer > 2000) {
 | |
|                 A = sq_GetUniformVelocity(255, 0, Clock() - EventAnimationTimer - 2000, 2000);
 | |
|             }
 | |
|             if (Clock() - EventAnimationTimer > 4000) {
 | |
|                 EventAnimationTimer = null;
 | |
|                 EventAnimationPlayFlag = false;
 | |
|             } else {
 | |
|                 L_sq_DrawImg("roters/rankmain.img", 1, 80, 20, 0, sq_RGBA(255, 255, 255, A), 1.0, 1.0);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //绘制主界面
 | |
|     function DrawMain(obj) {
 | |
|         //Item信息框一般为211的宽度
 | |
|         L_sq_DrawWindow(X, Y, 540, 470, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13);
 | |
| 
 | |
|         L_sq_DrawImg("roters/rankmain.img", 0, X + 9, Y + 6);
 | |
| 
 | |
|         //Boss血量
 | |
|         setClip(X + 15, Y + 30, X + 15 + (532 * BOSS_HP_RATE).tointeger(), Y + 30 + 17); //开始裁切
 | |
|         L_sq_DrawImg("roters/rankmain.img", 8, X + 15, Y + 30);
 | |
|         releaseClip(); //裁切结束
 | |
| 
 | |
|         //TODO 要判断这次攻坚是否成功了 成功了就不绘制
 | |
|         L_sq_DrawImg("roters/rankmaineff.img", 0, X + 13, Y + 50);
 | |
| 
 | |
| 
 | |
| 
 | |
|         //绘制奖励
 | |
|         if (RewardInfo) {
 | |
|             L_sq_DrawWindow(X + 10, Y + 228, 100, 48, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13);
 | |
|             L_sq_DrawCode("活动奖励预览", X + 24, Y + 240, sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|             foreach(Pos, Value in RewardInfo) {
 | |
|                 DrawItemEx(X + 22 + (Pos * 34), Y + 264, Value, 1);
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         //绘制排名
 | |
|         if (RankInfo) {
 | |
|             foreach(Pos, Value in RankInfo) {
 | |
|                 if (Pos< 10) {
 | |
|                     L_sq_DrawCode(Value.RankTop.tostring(), X + 46 - LenheartTextClass.GetStringLength(Value.RankTop.tostring()) / 2, Y + 324 + (Pos * 16), sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|                     L_sq_DrawCode(Value.Name.tostring(), X + 158 - LenheartTextClass.GetStringLength(Value.Name.tostring()) / 2, Y + 324 + (Pos * 16), sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|                     L_sq_DrawCode(Value.Job.tostring(), X + 310 - LenheartTextClass.GetStringLength(Value.Job.tostring()) / 2, Y + 324 + (Pos * 16), sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|                     L_sq_DrawCode(Value.Damage.tostring(), X + 466 - LenheartTextClass.GetStringLength(Value.Damage.tostring()) / 2, Y + 324 + (Pos * 16), sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|                 } else {
 | |
|                     L_sq_DrawCode(Value.RankTop.tostring(), X + 46 - LenheartTextClass.GetStringLength(Value.RankTop.tostring()) / 2, Y + 486, sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|                     L_sq_DrawCode(Value.Name.tostring(), X + 158 - LenheartTextClass.GetStringLength(Value.Name.tostring()) / 2, Y + 486, sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|                     L_sq_DrawCode(Value.Job.tostring(), X + 310 - LenheartTextClass.GetStringLength(Value.Job.tostring()) / 2, Y + 486, sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|                     L_sq_DrawCode(Value.Damage.tostring(), X + 466 - LenheartTextClass.GetStringLength(Value.Damage.tostring()) / 2, Y + 486, sq_RGBA(251, 251, 181, 250), 1, 1);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         local AttackButton = LenheartTabbars(X + 11 + 50, Y + 215, 50, 17);
 | |
|         AttackButton.SetFrame("roters/rankmain.img", 2);
 | |
|         AttackButton.SyncPos(X + 499, Y + 501);
 | |
|         AttackButton.Show();
 | |
|         if (AttackButton.isLBActive()) {
 | |
| 
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //开启界面回调
 | |
|     function OpenClassCallBack() {
 | |
| 
 | |
|         L_NewWindows("Lenheart", 170, 0x65535);
 | |
|         local W = sq_GetPopupWindowMainCotrol(170);
 | |
|         W.SetVisible(false);
 | |
|         W.SetEnable(false);
 | |
| 
 | |
| 
 | |
|         GetWorldBossEventRankInfo();
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //绘制道具相信信息
 | |
|     ItemObject = null;
 | |
| 
 | |
|     function DrawItemInfo(obj) {
 | |
|         if (ItemInfoDrawS && ItemInfoObject) {
 | |
|             if (!ItemObject) {
 | |
|                 local ItemId = ItemInfoDrawS.ItemId;
 | |
|                 if (ItemInfoObject.rawin(ItemId)) {
 | |
|                     ItemObject = ItemInfoClass(ItemInfoObject[ItemId]);
 | |
|                 }
 | |
|             }
 | |
|             ItemObject.Show(ItemInfoDrawS.X, ItemInfoDrawS.Y - ItemObject.PageLength);
 | |
|         } else {
 | |
|             ItemObject = null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //绘制入口
 | |
|     function Draw(obj) {
 | |
|         ItemInfoDrawS = null;
 | |
| 
 | |
|         if (MainState) {
 | |
|             if (WindowObj) {
 | |
|                 DrawMain(obj);
 | |
|                 WindowObj.Show(obj);
 | |
|                 X = WindowObj.X;
 | |
|                 Y = WindowObj.Y;
 | |
| 
 | |
|                 DrawItemInfo(obj);
 | |
|             } else {
 | |
|                 WindowObj = LenheartWindow(X, Y, 558, 470, 15); //坐标 大小 标题栏高度
 | |
|                 // WindowObj.DeBugMode = true;
 | |
|             }
 | |
|         } else {
 | |
|             if (WindowObj && WindowObj.YMouseSw == false) {
 | |
|                 IMouse.ReleaseMouseClick();
 | |
|                 WindowObj.YMouseSw = true;
 | |
|                 WindowObj = null;
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         //播放活动开启过场动画
 | |
|         // ShowEventOpenAnimation(obj);
 | |
|     }
 | |
| 
 | |
|     //逻辑入口
 | |
|     function Proc(obj) {
 | |
|         if (KeyPressNB.isKeyPress(48, "New_RotersCloseKey")) {
 | |
|             MainState = false;
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| // function New_Roters(obj) {
 | |
| //     local RootTab = getroottable();
 | |
| //     if (!RootTab.rawin("New_RotersCObj")) {
 | |
| //         local Cobj = New_RotersC();
 | |
| //         RootTab.rawset("New_RotersCObj", Cobj);
 | |
| //     } else {
 | |
| //         RootTab["New_RotersCObj"].Proc(obj);
 | |
| //         RootTab["New_RotersCObj"].Draw(obj);
 | |
| //     }
 | |
| // }
 | |
| // if (getroottable().rawin("LenheartFuncTab")) {
 | |
| //     getroottable()["LenheartFuncTab"].rawset("New_Roters_LenheartFunc", New_Roters);
 | |
| // } else {
 | |
| //     local T = {};
 | |
| //     T.rawset("New_Roters_LenheartFunc", New_Roters);
 | |
| //     getroottable().rawset("LenheartFuncTab", T);
 | |
| // } |