137 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			137 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:Shapeshifting.nut
 | |
| 路径:Project/Shapeshifting/Shapeshifting.nut
 | |
| 创建日期:2024-08-24	23:53
 | |
| 文件用途:时装变身
 | |
| */
 | |
| class ShapeshiftingC extends LenheartNewUI_Windows {
 | |
|     //调试模式
 | |
|     // DeBugMode = true;
 | |
| 
 | |
|     //不是窗口
 | |
|     NoWindow = true;
 | |
| 
 | |
|     //是否可见
 | |
|     // Visible = false;
 | |
| 
 | |
|     //信息
 | |
|     Info = null;
 | |
| 
 | |
|     //服务器装备配置
 | |
|     SeverEquInfo = null;
 | |
| 
 | |
|     ShapeMonsterId = null;
 | |
| 
 | |
|     //初始化时间
 | |
|     Timer = 0;
 | |
| 
 | |
|     //收到信息包
 | |
|     function GetInfoCallBack(Chunk) {
 | |
|         if (!this) return;
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         SeverEquInfo = Jso.info;
 | |
|         X = Jso.btnX;
 | |
|         Y = Jso.btnY;
 | |
|     }
 | |
| 
 | |
| 
 | |
|     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
 | |
|         Childrens = [];
 | |
|         Timer = Clock();
 | |
|         //注册控件
 | |
|         RegisterWidget();
 | |
| 
 | |
|         LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
 | |
| 
 | |
|         //信息包
 | |
|         Pack_Control.rawset(20074002, GetInfoCallBack.bindenv(this));
 | |
|     }
 | |
| 
 | |
|     function RegisterWidget() {
 | |
|         //关闭按钮
 | |
|         local CloseButton = LenheartNewUI_BaseButton(0, 0, 28, 28, "interface2/yosin/bianshen.img", 0);
 | |
|         CloseButton.OnClick = function() {
 | |
|             if (ShapeMonsterId) {
 | |
|                 L_sq_SendPackType(214);
 | |
|                 L_sq_SendPackByte(2);
 | |
|                 L_sq_SendPackWord(ShapeMonsterId);
 | |
|                 L_sq_SendPack();
 | |
|             }
 | |
|         }.bindenv(this);
 | |
|         CloseButton.SetCallBackFunc(function(Button) {
 | |
| 
 | |
|         })
 | |
|         Childrens.append(CloseButton);
 | |
|     }
 | |
| 
 | |
|     //绘制主界面
 | |
|     function DrawMain(obj) {
 | |
| 
 | |
|     }
 | |
| 
 | |
|     function Show(obj) {
 | |
|         DrawMain(obj);
 | |
|         LenheartNewUI_Windows.Show(obj);
 | |
| 
 | |
|     }
 | |
| 
 | |
| 
 | |
|     function CheckPlayerInfoToSeverShapeInfo() {
 | |
|         if(!SeverEquInfo)return;
 | |
|         local Toubu = L_sq_GetCharacterAttribute(0x1C, 14);
 | |
|         local Maozi = L_sq_GetCharacterAttribute(0x1C, 13);
 | |
|         local Lianbu = L_sq_GetCharacterAttribute(0x1C, 15);
 | |
|         local Guanghuan = L_sq_GetCharacterAttribute(0x1C, 22);
 | |
|         local Xiongbu = L_sq_GetCharacterAttribute(0x1C, 19);
 | |
|         local Shangyi = L_sq_GetCharacterAttribute(0x1C, 16);
 | |
|         local Pifu = L_sq_GetCharacterAttribute(0x1C, 21);
 | |
|         local Yaobu = L_sq_GetCharacterAttribute(0x1C, 20);
 | |
|         local Xiazhuang = L_sq_GetCharacterAttribute(0x1C, 17);
 | |
|         local Xie = L_sq_GetCharacterAttribute(0x1C, 18);
 | |
| 
 | |
|         foreach(v in SeverEquInfo) {
 | |
|             if (v.Toubu != Toubu && v.Toubu != 0) continue;
 | |
|             if (v.Maozi != Maozi && v.Maozi != 0) continue;
 | |
|             if (v.Lianbu != Lianbu && v.Lianbu != 0) continue;
 | |
|             if (v.Guanghuan != Guanghuan && v.Guanghuan != 0) continue;
 | |
|             if (v.Xiongbu != Xiongbu && v.Xiongbu != 0) continue;
 | |
|             if (v.Shangyi != Shangyi && v.Shangyi != 0) continue;
 | |
|             if (v.Pifu != Pifu && v.Pifu != 0) continue;
 | |
|             if (v.Yaobu != Yaobu && v.Yaobu != 0) continue;
 | |
|             if (v.Xiazhuang != Xiazhuang && v.Xiazhuang != 0) continue;
 | |
|             if (v.Xie != Xie && v.Xie != 0) continue;
 | |
|             ShapeMonsterId = v.MonsterId;
 | |
|             return;
 | |
|         }
 | |
|         ShapeMonsterId = null;
 | |
|     }
 | |
| 
 | |
|     //逻辑入口
 | |
|     function Proc(obj) {
 | |
|         LenheartNewUI_Windows.SyncPos(X, Y);
 | |
| 
 | |
|         //每五秒获取一次本地数据信息
 | |
|         if (Clock() - Timer >= 5000) {
 | |
|             Timer = Clock();
 | |
|             CheckPlayerInfoToSeverShapeInfo();
 | |
|         }
 | |
| 
 | |
|         if (!ShapeMonsterId) {
 | |
|             Visible = false;
 | |
|         } else {
 | |
|             Visible = true;
 | |
|         }
 | |
|     }
 | |
| 
 | |
| }
 | |
| getroottable().rawdelete("Shapeshifting_Obj");
 | |
| 
 | |
| function Lenheart_Shapeshifting_Fun(obj) {
 | |
|     local RootTab = getroottable();
 | |
|     if (!RootTab.rawin("Shapeshifting_Obj")) {
 | |
|         RootTab.rawset("Shapeshifting_Obj", true);
 | |
|         LenheartNewUI_CreateWindow(ShapeshiftingC, "时装变身窗口", 430, 500, 28, 28, 0);
 | |
|     }
 | |
| }
 | |
| 
 | |
| getroottable()["LenheartFuncTab"].rawset("ShapeshiftingFuncN", Lenheart_Shapeshifting_Fun); |