414 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			414 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:WorldBoss.nut
 | |
| 路径:Project/WorldBoss/WorldBoss.nut
 | |
| 创建日期:2025-05-01	23:54
 | |
| 文件用途:世界BOSS
 | |
| */
 | |
| 
 | |
| class WorldBossC extends LenheartNewUI_Windows {
 | |
|     //调试模式
 | |
|     // DeBugMode = true;
 | |
| 
 | |
|     //不是窗口
 | |
|     // NoWindow = true;
 | |
| 
 | |
|     //是否可见
 | |
|     Visible = false;
 | |
| 
 | |
|     WindowImg = Rindro_Image("hud/worldboss.img");
 | |
|     WindowTimeImg = Rindro_Image("hud/worldboss_time.img");
 | |
|     WindowTimeNumImg = Rindro_Image("hud/worldboss_timenum.img");
 | |
| 
 | |
|     //基础信息
 | |
|     BaseInfo = null;
 | |
| 
 | |
|     //Pvf信息
 | |
|     PvfInfo = null;
 | |
| 
 | |
|     //伤害列表
 | |
|     RankList = null;
 | |
| 
 | |
| 
 | |
|     //页面
 | |
|     Page = 0;
 | |
|     //查询排名页数
 | |
|     CheckPage = 1;
 | |
|     MaxPage = 50;
 | |
| 
 | |
| 
 | |
|     //计时器
 | |
|     TiemrCache = null;
 | |
|     Timer = null;
 | |
| 
 | |
|     //累计伤害
 | |
|     TotalDamage = null;
 | |
| 
 | |
|     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
 | |
|         Childrens = [];
 | |
| 
 | |
|         InitButtonConfig();
 | |
|         //注册控件
 | |
|         RegisterWidget();
 | |
| 
 | |
|         LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
 | |
| 
 | |
| 
 | |
|         Pack_Control.rawset(20060002, function(Chunk) {
 | |
|             local Jso = Json.Decode(Chunk);
 | |
|             BaseInfo = Jso;
 | |
|         }.bindenv(this));
 | |
| 
 | |
|         Pack_Control.rawset(20060006, function(Chunk) {
 | |
|             local Jso = Json.Decode(Chunk);
 | |
|             RankList = Jso.list;
 | |
|         }.bindenv(this));
 | |
| 
 | |
|         Pack_Control.rawset(20060014, function(Chunk) {
 | |
|             local Jso = Json.Decode(Chunk);
 | |
|             Timer = Clock();
 | |
|             TiemrCache = Jso.endTime;
 | |
|         }.bindenv(this));
 | |
| 
 | |
| 
 | |
|         PushDamageFontFuncTab.rawset("DamagePerSecondCFunc", function(ObjAddress, MySelfAddress, Value) {
 | |
|             if (!SendDamagePackFlag) return;
 | |
|             if (ObjAddress == 0 || ObjAddress == MySelfAddress) {
 | |
|                 if (!TotalDamage) TotalDamage = longlong(0);
 | |
|                 TotalDamage += longlong(Value);
 | |
|             }
 | |
|         }.bindenv(this));
 | |
| 
 | |
| 
 | |
| 
 | |
|         // ChangePage(1);
 | |
|         // SendPackEx({
 | |
|         //     op = 20060005,
 | |
|         //     page = 1
 | |
|         // })
 | |
|     }
 | |
| 
 | |
|     function InitButtonConfig() {
 | |
|         PvfInfo = Rindro_Script.GetFileData("etc/rindro/worldboss/worldboss.etc", function(DataTable, Data) {
 | |
|             while (!Data.Eof()) {
 | |
|                 local Key = Data.Get();
 | |
|                 if (Key == "[Enter Button]") {
 | |
|                     DataTable.EnterButton <- {
 | |
|                         x = Data.Get(),
 | |
|                         y = Data.Get(),
 | |
|                         width = Data.Get(),
 | |
|                         height = Data.Get()
 | |
|                     }
 | |
|                 } else if (Key == "[Refresh Button]") {
 | |
|                     DataTable.RefreshButton <- {
 | |
|                         x = Data.Get(),
 | |
|                         y = Data.Get(),
 | |
|                         width = Data.Get(),
 | |
|                         height = Data.Get()
 | |
|                     }
 | |
|                 } else if (Key == "[Rank List]") {
 | |
|                     DataTable.RankList <- {
 | |
|                         x = Data.Get(),
 | |
|                         y = Data.Get()
 | |
|                     }
 | |
|                 } else if (Key == "[Time Countdown]") {
 | |
|                     DataTable.Countdown <- {
 | |
|                         x = Data.Get(),
 | |
|                         y = Data.Get()
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }.bindenv(this));
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //标题栏
 | |
|     Title = null;
 | |
| 
 | |
|     function ChangePage(ToPage) {
 | |
|         foreach(ButtonObj in Title) {
 | |
|             ButtonObj.State = 0;
 | |
|         }
 | |
|         Page = ToPage;
 | |
|         Title[ToPage].State = 1;
 | |
|     }
 | |
| 
 | |
|     function RegisterWidget() {
 | |
|         Title = [];
 | |
|         local Tabbars1 = LenheartNewUI_TabbarsText(2, 27, "玩法简介");
 | |
|         Tabbars1.State = 1;
 | |
|         Tabbars1.SetTextOffset(7, 4);
 | |
|         AddChild(Tabbars1);
 | |
|         Tabbars1.OnClick = function() {
 | |
|             ChangePage(0);
 | |
|         }.bindenv(this);
 | |
|         Title.append(Tabbars1);
 | |
| 
 | |
|         local Tabbars2 = LenheartNewUI_TabbarsText(64, 27, "世界BOSS");
 | |
|         Tabbars2.SetTextOffset(7, 4);
 | |
|         AddChild(Tabbars2);
 | |
|         Tabbars2.OnClick = function() {
 | |
|             ChangePage(1);
 | |
|         }.bindenv(this);
 | |
|         Title.append(Tabbars2);
 | |
| 
 | |
| 
 | |
|         //关闭按钮
 | |
|         local CloseButton = LenheartNewUI_BaseButton(600, 5, 11, 12, "interface/lenheartwindowcommon.img", 276);
 | |
|         CloseButton.OnClick = function() {
 | |
|             this.Visible = false;
 | |
|         }.bindenv(this);
 | |
|         Childrens.append(CloseButton);
 | |
| 
 | |
|         //进入按钮
 | |
|         local EnterButton = LenheartNewUI_BaseButton(PvfInfo.EnterButton.x, PvfInfo.EnterButton.y, PvfInfo.EnterButton.width, PvfInfo.EnterButton.height, "hud/worldboss.img", 1);
 | |
|         EnterButton.OnClick = function() {
 | |
|             SendPackEx({
 | |
|                 op = 20060007
 | |
|             })
 | |
|         }.bindenv(this);
 | |
|         EnterButton.SetCallBackFunc(function(Btn) {
 | |
|             if (Page == 1)
 | |
|                 Btn.Visible = true;
 | |
|             else
 | |
|                 Btn.Visible = false;
 | |
|         }.bindenv(this))
 | |
|         Childrens.append(EnterButton);
 | |
| 
 | |
|         //刷新按钮
 | |
|         local RefreshButton = LenheartNewUI_BaseButton(PvfInfo.RefreshButton.x, PvfInfo.RefreshButton.y, PvfInfo.RefreshButton.width, PvfInfo.RefreshButton.height, "hud/worldboss.img", 5);
 | |
|         RefreshButton.OnClick = function() {
 | |
| 
 | |
|         }.bindenv(this);
 | |
|         RefreshButton.SetCallBackFunc(function(Btn) {
 | |
|             if (Page == 1)
 | |
|                 Btn.Visible = true;
 | |
|             else
 | |
|                 Btn.Visible = false;
 | |
|         }.bindenv(this))
 | |
|         Childrens.append(RefreshButton);
 | |
| 
 | |
| 
 | |
|         //左按钮
 | |
|         local LeftButton = LenheartNewUI_BaseButton(PvfInfo.RankList.x + 150, PvfInfo.RankList.y + 284, 12, 9, "interface/lenheartwindowcommon.img", 511);
 | |
|         LeftButton.OnClick = function() {
 | |
|             if (CheckPage > 1) CheckPage--;
 | |
|             SendPackEx({
 | |
|                 op = 20060005,
 | |
|                 Page = CheckPage
 | |
|             })
 | |
|         }.bindenv(this);
 | |
|         LeftButton.SetCallBackFunc(function(Btn) {
 | |
|             if (Page == 1)
 | |
|                 Btn.Visible = true;
 | |
|             else
 | |
|                 Btn.Visible = false;
 | |
|         }.bindenv(this))
 | |
|         Childrens.append(LeftButton);
 | |
|         //关闭按钮
 | |
|         local RightButton = LenheartNewUI_BaseButton(PvfInfo.RankList.x + 196, PvfInfo.RankList.y + 284, 12, 9, "interface/lenheartwindowcommon.img", 521);
 | |
|         RightButton.OnClick = function() {
 | |
|             if (CheckPage< MaxPage) CheckPage++;
 | |
|             SendPackEx({
 | |
|                 op = 20060005,
 | |
|                 page = CheckPage
 | |
|             })
 | |
|         }.bindenv(this);
 | |
|         RightButton.SetCallBackFunc(function(Btn) {
 | |
|             if (Page == 1)
 | |
|                 Btn.Visible = true;
 | |
|             else
 | |
|                 Btn.Visible = false;
 | |
|         }.bindenv(this))
 | |
|         Childrens.append(RightButton);
 | |
|     }
 | |
| 
 | |
|     //悬停层绘制Flag
 | |
|     HoverFlag = null;
 | |
| 
 | |
|     //绘制主界面
 | |
|     function DrawMain(obj) {
 | |
|         //玩法简介
 | |
|         if (Page == 0) {
 | |
|             WindowImg.DrawPng(0, X, Y);
 | |
|         }
 | |
|         //世界BOSS
 | |
|         else if (Page == 1) {
 | |
|             WindowImg.DrawPng(9, X, Y);
 | |
|             WindowImg.DrawPng(10, X + PvfInfo.RankList.x, Y + PvfInfo.RankList.y);
 | |
| 
 | |
|             //绘制查询页数
 | |
|             local Str = CheckPage + "/" + MaxPage;
 | |
|             L_sq_DrawCode(Str, X + PvfInfo.RankList.x + 179 - LenheartTextClass.GetStringLength(Str) / 2, Y + PvfInfo.RankList.y + 283, sq_RGBA(230, 200, 155, 255), 0, 1);
 | |
| 
 | |
|             HoverFlag = null;
 | |
|             //绘制排行榜
 | |
|             if (RankList) {
 | |
|                 foreach(Pos, info in RankList) {
 | |
|                     local Rank = info.rank.tostring();
 | |
|                     L_sq_DrawCode(Rank, X + PvfInfo.RankList.x + 18 - LenheartTextClass.GetStringLength(Rank) / 2, Y + PvfInfo.RankList.y + 10 + (Pos * 20), sq_RGBA(230, 200, 155, 255), 0, 1);
 | |
| 
 | |
|                     local TeamName = info.teamName;
 | |
|                     L_sq_DrawCode(TeamName, X + PvfInfo.RankList.x + 70 - LenheartTextClass.GetStringLength(TeamName) / 2, Y + PvfInfo.RankList.y + 10 + (Pos * 20), sq_RGBA(230, 200, 155, 255), 0, 1);
 | |
| 
 | |
|                     local Damage = info.totalDamage.tostring();
 | |
|                     L_sq_DrawCode(Damage, X + PvfInfo.RankList.x + 150 - LenheartTextClass.GetStringLength(Damage) / 2, Y + PvfInfo.RankList.y + 10 + (Pos * 20), sq_RGBA(230, 200, 155, 255), 0, 1);
 | |
| 
 | |
|                     if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X + PvfInfo.RankList.x, Y + PvfInfo.RankList.y + (Pos * 20), 200, 20)) {
 | |
|                         HoverFlag = Pos;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|             //悬停层
 | |
|             if (HoverFlag != null) {
 | |
|                 L_sq_DrawWindow(X + PvfInfo.RankList.x, Y + PvfInfo.RankList.y + (HoverFlag * 20), 200, 100, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13);
 | |
|                 L_sq_DrawWindow(X + PvfInfo.RankList.x, Y + PvfInfo.RankList.y + (HoverFlag * 20), 200, 100, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13);
 | |
| 
 | |
|                 L_sq_DrawCode(RankList[HoverFlag].teamName, X + PvfInfo.RankList.x + 104 - LenheartTextClass.GetStringLength(RankList[HoverFlag].teamName) / 2, Y + PvfInfo.RankList.y + (HoverFlag * 20) + 14, sq_RGBA(83, 205, 255, 255), 0, 1);
 | |
|                 local Yoffset = 40;
 | |
|                 for (local Pos = 0; Pos < 4; Pos++) {
 | |
|                     local info = {
 | |
|                         name = "无队员",
 | |
|                         job = "无职业",
 | |
|                         damage = "0",
 | |
|                         color = sq_RGBA(174, 174, 174, 255)
 | |
|                     }
 | |
|                     if(RankList[HoverFlag].team.len() > Pos) {
 | |
|                         info = RankList[HoverFlag].team[Pos];
 | |
|                         info.color <- sq_RGBA(218, 248, 129, 255);
 | |
|                     }
 | |
|                     local Name = info.name;
 | |
|                     L_sq_DrawCode(Name, X + PvfInfo.RankList.x + 28 - LenheartTextClass.GetStringLength(Name) / 2, Y + PvfInfo.RankList.y + (HoverFlag * 20) + Yoffset + (Pos * 20), info.color, 0, 1);
 | |
|                     local Job = info.job;
 | |
|                     L_sq_DrawCode(Job, X + PvfInfo.RankList.x + 110 - LenheartTextClass.GetStringLength(Job) / 2, Y + PvfInfo.RankList.y + (HoverFlag * 20) + Yoffset + (Pos * 20), info.color, 0, 1);
 | |
| 
 | |
|                     local Damage = info.damage.tostring();
 | |
|                     L_sq_DrawCode(Damage, X + PvfInfo.RankList.x + 202 - LenheartTextClass.GetStringLength(Damage), Y + PvfInfo.RankList.y + (HoverFlag * 20) + Yoffset + (Pos * 20), info.color, 0, 1);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
|     function DrawTime(obj) {
 | |
|         if (!TiemrCache || !Timer) return;
 | |
|         local DrawX = PvfInfo.Countdown.x;
 | |
|         local DrawY = PvfInfo.Countdown.y;
 | |
|         //背景绘制
 | |
|         WindowTimeImg.DrawPng(1, DrawX, DrawY);
 | |
|         WindowTimeImg.DrawPng(0, DrawX, DrawY + 2);
 | |
| 
 | |
|         //时间绘制
 | |
|         local DrawTime = TiemrCache - (Clock() - Timer);
 | |
|         local TotalSeconds = DrawTime / 1000;
 | |
|         local Minutes = (TotalSeconds % 3600) / 60;
 | |
|         local Seconds = (TotalSeconds % 3600) % 60;
 | |
|         local Millisecond = DrawTime % 1000 / 10;
 | |
| 
 | |
|         local Offset = 43;
 | |
|         DrawNum(format("%02d", Minutes), Offset);
 | |
|         Offset += 40;
 | |
|         WindowTimeNumImg.DrawPng(10, DrawX + Offset - 5, DrawY + 27);
 | |
|         DrawNum(format("%02d", Seconds), Offset);
 | |
|         Offset += 40;
 | |
|         WindowTimeNumImg.DrawPng(10, DrawX + Offset - 5, DrawY + 27);
 | |
|         DrawNum(format("%02d", Millisecond), Offset);
 | |
|     }
 | |
| 
 | |
|     function DrawNum(time, Xoffset) {
 | |
|         local DrawX = PvfInfo.Countdown.x;
 | |
|         local DrawY = PvfInfo.Countdown.y;
 | |
|         for (local i = 0; i< time.len(); i++) {
 | |
|             local DrawNum = time.slice(i, i + 1);
 | |
|             WindowTimeNumImg.DrawPng(DrawNum.tointeger(), DrawX + Xoffset + (i * 15), DrawY + 21);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function Show(obj) {
 | |
|         DrawMain(obj);
 | |
|         LenheartNewUI_Windows.Show(obj);
 | |
| 
 | |
|     }
 | |
| 
 | |
|     //进入副本初始化包Flag
 | |
|     EnterMapPackFlag = false;
 | |
|     //发送伤害包Flag
 | |
|     SendDamagePackFlag = false;
 | |
| 
 | |
|     //副本逻辑
 | |
|     function DungeonLogic() {
 | |
|         local stage = sq_GetGlobaludpModuleStage();
 | |
|         local mapIndex = sq_GetMapIndex(stage);
 | |
|         local dungeon = sq_GetDungeonByStage(stage);
 | |
|         local dungeonIndex = sq_GetDuegonIndex(dungeon);
 | |
|         if (dungeonIndex == BaseInfo.dgn && mapIndex == BaseInfo.map) {
 | |
|             if (!EnterMapPackFlag) {
 | |
|                 EnterMapPackFlag = true;
 | |
|                 SendPackEx({
 | |
|                     op = 20060013
 | |
|                 })
 | |
|             }
 | |
|             SendDamagePackFlag = true;
 | |
|         } else {
 | |
|             SendDamagePackFlag = false;
 | |
|             TiemrCache = null;
 | |
|             Timer = null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //发送伤害计时器
 | |
|     SendDamageT = 0;
 | |
|     //逻辑入口
 | |
|     function Proc(obj) {
 | |
|         LenheartNewUI_Windows.SyncPos(X, Y);
 | |
|         if (!BaseInfo) return;
 | |
|         DungeonLogic();
 | |
|         DrawTime(obj);
 | |
| 
 | |
|         //在副本中需要发送伤害的时候
 | |
|         if (TotalDamage) {
 | |
|             if (SendDamagePackFlag) {
 | |
|                 SendDamageT += Rindro_Duration;
 | |
|                 if (SendDamageT > 5000) {
 | |
|                     SendDamageT = 0;
 | |
|                     SendPackEx({
 | |
|                         op = 20060017,
 | |
|                         Damage = TotalDamage.Value
 | |
|                     })
 | |
|                     TotalDamage = null;
 | |
|                 }
 | |
|             }
 | |
|             //结束时再发一次
 | |
|             else {
 | |
|                 SendPackEx({
 | |
|                     op = 20060017,
 | |
|                     Damage = TotalDamage.Value
 | |
|                 })
 | |
|                 TotalDamage = null;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function OpenCallBack() {
 | |
|         Visible = true;
 | |
| 
 | |
|         SendPackEx({
 | |
|             op = 20060005,
 | |
|             page = 1
 | |
|         })
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| function Lenheart_WorldBoss_Fun(obj) {
 | |
|     local RootTab = getroottable();
 | |
|     if (!RootTab.rawin("WorldBoss_Obj")) {
 | |
|         RootTab.rawset("WorldBoss_Obj", true);
 | |
|         local Win = LenheartNewUI_CreateWindow(WorldBossC, "阿拉德守卫战窗口", ((getroottable().Rindro_Scr_Width - 620) / 2).tointeger(), 64, 620, 430, 28);
 | |
|         EventList_Obj.AddEvent("阿拉德守卫战", 1001, Win);
 | |
|     }
 | |
| }
 | |
| 
 | |
| getroottable()["LenheartFuncTab"].rawset("WorldBossFuncN", Lenheart_WorldBoss_Fun);
 | |
| 
 |