/* 文件名:MarrySystem.nut 路径:Plugins/MarrySystem/MarrySystem.nut 创建日期:2023-06-16 10:29 文件用途: */ class MarrySystemWindow extends BasicsDrawTool { //宽度 Width = null; //高度 Height = null; //标题高度 TitleH = null; //X坐标 X = null; B_X = null; //Y坐标 Y = null; B_Y = null; YMouseSw = true; DeBugMode = false; Mobj = null; M_Xpos = null; M_Ypos = null; constructor(gX, gY, gWidth, gHeight, gTitleH) { //宽度 Width = gWidth; //高度 Height = gHeight; //标题高度 TitleH = gTitleH; //X坐标 X = gX; //Y坐标 Y = gY; if (getroottable().rawin("MouseObject")) Mobj = getroottable()["MouseObject"]; } //设定鼠标逻辑 function LockMouse() { if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, Width, Height)) { IMouse.LockMouseClick(); YMouseSw = false; } else { if (YMouseSw == false && sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, 0, 0, 800, 600)) { IMouse.ReleaseMouseClick(); YMouseSw = true; } } } //设定窗口拖动逻辑 function MoveWindow() { if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, Width, TitleH)) { if (Mobj.Lb == 1) { if (!M_Xpos) M_Xpos = IMouse.GetXPos(); //原始鼠标位置数据 if (!M_Ypos) M_Ypos = IMouse.GetYPos(); if (!B_X) B_X = X; //原始窗口位置 if (!B_Y) B_Y = Y; X = B_X - (M_Xpos - IMouse.GetXPos()); Y = B_Y - (M_Ypos - IMouse.GetYPos()); } else if (Mobj.Lb == 0) { M_Xpos = null; M_Ypos = null; B_X = null; B_Y = null; } } } function Show(obj) { if (DeBugMode) sq_DrawBox(X, Y, Width, Height, 0xffffffff); //设定鼠标逻辑 LockMouse(); //设定窗口拖动逻辑 MoveWindow(); } } class MarrySystemC extends BasicsDrawTool { WindowObj = null; //窗口对象 MainState = false; //主状态 X = 235; Y = 52; Avatar = null; LevelInfo = null; NameInfo = null; TabName = [ "力量 +", "体力 +", "智力 +", "精神 +", "独立攻击力 +", "物理攻击力 +", "魔法攻击力 +", "物理防御 +", "魔法防御 +", "移动速度 +", "攻击速度 +", "释放速度 +", "物理暴击 +", "魔法暴击 +", "命中率 +", "光属性强化 +", "暗属性强化 +", "水属性强化 +", "火属性强化 +", "全属性强化 +" ] PrintAbTab = null; AbTab = null; DgnAddBuff = false; function PleaseMarryMe(gname) { local T = { op = 20019101, name = gname } local str = Json.Encode(T); L_sq_SendPackType(130); L_sq_SendPackWChar(str); L_sq_SendPack(); } function PleaseDivorceMe(gname) { local T = { op = 20019103, name = gname } local str = Json.Encode(T); L_sq_SendPackType(130); L_sq_SendPackWChar(str); L_sq_SendPack(); } function CheckOtherPlayerMarryInfo(gname) { local T = { op = 20019011, name = gname } local str = Json.Encode(T); L_sq_SendPackType(130); L_sq_SendPackWChar(str); L_sq_SendPack(); } function CheckPlayerMarryInfo() { local T = { op = 20019009 } local str = Json.Encode(T); L_sq_SendPackType(130); L_sq_SendPackWChar(str); L_sq_SendPack(); } function CheckPlayerMarryInfoCallBack(Chunk) { local Buffer = Json_STL("CheckPlayerMarryInfoCallBackBuffer"); Buffer.Parse(Chunk, 0, false); local RootTab = getroottable(); if (RootTab.rawin("MarrySystemCObj")) { local Tobj = RootTab["MarrySystemCObj"]; Tobj.Avatar = { Player1 = Buffer.Get("job"), Player2 = Buffer.Get("partnerJob"), } Tobj.LevelInfo = { level = Buffer.Get("lv"), nexp = Buffer.Get("experience"), mexp = Buffer.Get("experienceMax"), } Tobj.NameInfo = { Player1 = Buffer.Get("name"), Player2 = Buffer.Get("partnerName"), } Tobj.PrintAbTab = null; Tobj.PrintAbTab = []; Tobj.AbTab = null; Tobj.AbTab = []; for (local i = 0; i < 20; i++) { local buf = Buffer.Get("attribute->" + i); if (!buf && i == 0) break; Tobj.PrintAbTab.append(buf); Tobj.AbTab.append(buf); } local EventTab = null; if (RootTab.rawin("YosinPlayerEachSystem")) { EventTab = RootTab["YosinPlayerEachSystem"]; local pos1 = null; local pos2 = null; foreach(pos, value in EventTab) { if (value.Name == "邀请结婚") { pos1 = pos; } if (value.Name == "我要离婚") { pos2 = pos; } } if (pos1) EventTab.remove(pos1); if (pos2) EventTab.remove(pos2); if (Tobj.PrintAbTab == null) PlayerEachIcon("邀请结婚", Tobj.PleaseMarryMe); else PlayerEachIcon("我要离婚", Tobj.PleaseDivorceMe); } if (EventTab) { RootTab.rawdelete("YosinPlayerEachSystem"); RootTab.rawset("YosinPlayerEachSystem", EventTab); } } } function CheckOtherPlayerMarryInfoCallBack(Chunk) { local Buffer = Json_STL("CheckOtherPlayerMarryInfoCallBackBuffer"); Buffer.Parse(Chunk, 0, false); local RootTab = getroottable(); if (RootTab.rawin("MarrySystemCObj")) { local Tobj = RootTab["MarrySystemCObj"]; Tobj.MainState = true; L_NewWindows("Lenheart", 170, 0x65535); local W = sq_GetPopupWindowMainCotrol(170); W.SetVisible(false); W.SetEnable(false); // BandObject.OpenClassCallBack(); Tobj.Avatar = null; if (Buffer.Get("job")) { Tobj.Avatar = { Player1 = Buffer.Get("job"), Player2 = Buffer.Get("partnerJob"), } } Tobj.LevelInfo = null; if (Buffer.Get("lv")) { Tobj.LevelInfo = { level = Buffer.Get("lv"), nexp = Buffer.Get("experience"), mexp = Buffer.Get("experienceMax"), } } Tobj.NameInfo = null; if (Buffer.Get("name")) { Tobj.NameInfo = { Player1 = Buffer.Get("name"), Player2 = Buffer.Get("partnerName"), } } Tobj.PrintAbTab = null; Tobj.PrintAbTab = []; for (local i = 0; i < 20; i++) { local buf = Buffer.Get("attribute->" + i); if (!buf && i == 0) break; Tobj.PrintAbTab.append(buf); } } } function DivorceCallBack(Chunk) { local RootTab = getroottable(); if (RootTab.rawin("MarrySystemCObj")) { RootTab.rawdelete("MarrySystemCObj"); } } constructor() { Pack_Control.rawset(20019010, CheckPlayerMarryInfoCallBack); Pack_Control.rawset(20019012, CheckOtherPlayerMarryInfoCallBack); Pack_Control.rawset(20019106, DivorceCallBack); CheckPlayerMarryInfo(); } function T_DrawDynamicAni(obj, aniFileName, x, y, aniname) { local ani = obj.getVar().GetAnimationMap(aniname, aniFileName); sq_AnimationProc(ani); sq_drawCurrentFrame(ani, x, y, true); return ani; } function T_DrawDynamicAni_Fx(obj, aniFileName, x, y, aniname) { local ani = obj.getVar().GetAnimationMap(aniname, aniFileName); ani.setImageRateFromOriginal(-1.0, 1.0); sq_AnimationProc(ani); sq_drawCurrentFrame(ani, x, y, true); return ani; } //绘制等级相关信息 function DrawLevelInfo(obj) { if (Avatar && LevelInfo) { local PosArr = [ [40, 75], [40, 75], [54, 24], [60, 86], [40, 45], [50, 50], [50, 50], [50, 45], [55, 70], [40, 75], [60, 86], ]; //绘制职业 // for (local i = 0; i < 10; i++) { // local SSS = Avatar.Player1 + i; // T_DrawDynamicAni(obj, "common/marrysystem/avatar/" + SSS + ".ani", X + PosArr[SSS][0], Y + PosArr[SSS][1], "MarrySystem_player" + SSS); // } T_DrawDynamicAni(obj, "common/marrysystem/avatar/" + Avatar.Player1 + ".ani", X + PosArr[Avatar.Player1][0], Y + PosArr[Avatar.Player1][1], "MarrySystem_player1" + Avatar.Player1); T_DrawDynamicAni_Fx(obj, "common/marrysystem/avatar/" + Avatar.Player2 + ".ani", X + 215 + PosArr[Avatar.Player2][0], Y + PosArr[Avatar.Player2][1], "MarrySystem_player2" + Avatar.Player2); //婚姻名字 L_sq_DrawCode(NameInfo.Player1, X + 68, Y + 190, sq_RGBA(230, 200, 155, 250), 1, 1); L_sq_DrawCode(NameInfo.Player2, X + 68 + 158, Y + 190, sq_RGBA(230, 200, 155, 250), 1, 1); //婚戒等级 T_DrawStayAni(obj, "common/marrysystem/coupleinfopopupui.ani", X + 14, Y + 221, 1 + LevelInfo.level, "MarrySystem_LEVEL_c"); //婚姻等级 L_sq_DrawCode("Lv . " + LevelInfo.level, X + 80, Y + 236, sq_RGBA(230, 200, 155, 250), 1, 1); //婚姻经验 L_sq_DrawCode(LevelInfo.nexp + " / " + LevelInfo.mexp, X + 208, Y + 220, sq_RGBA(230, 200, 155, 250), 1, 1); //进度条 T_DrawStayAni(obj, "common/marrysystem/main.ani", X + 144, Y + 228, 1, "MarrySystem_Now_Main"); setClip(X + 144, Y + 228, X + 144 + ((LevelInfo.nexp.tofloat() / LevelInfo.mexp.tofloat()) * 174.0).tointeger(), Y + 228 + 23); //开始裁切 T_DrawStayAni(obj, "common/marrysystem/main.ani", X + 144, Y + 228, 2, "MarrySystem_Max_Main"); releaseClip(); //裁切结束 } } //附加属性 function AddAb(obj) { if (sq_GetCurrentModuleType() == 3) { if (!AbTab) return; if (DgnAddBuff == false) { DgnAddBuff = true; local appendage = CNSquirrelAppendage.sq_AppendAppendage(obj, obj, -1, false, "appendage/marry/marry.nut", true); CNSquirrelAppendage.sq_Append(appendage, obj, obj); local change_appendage = appendage.sq_getChangeStatus("Yosin_MarryDgnBuff"); if (!change_appendage) { change_appendage = appendage.sq_AddChangeStatusAppendageID(obj, obj, 0, CHANGE_STATUS_TYPE_COOLTIME_DECLINE, false, 0, 114515); } if (change_appendage) { change_appendage.clearParameter(); //print(WearSlotM.Item.TabName[0]); foreach(Key, Value in AbTab) { if (Key == 0) change_appendage.addParameter(0, false, Value.tofloat()); else if (Key == 1) change_appendage.addParameter(3, false, Value.tofloat()); else if (Key == 2) change_appendage.addParameter(2, false, Value.tofloat()); else if (Key == 3) change_appendage.addParameter(1, false, Value.tofloat()); else if (Key == 4) change_appendage.addParameter(53, false, Value.tofloat()); else if (Key == 5) change_appendage.addParameter(4, false, Value.tofloat()); else if (Key == 6) change_appendage.addParameter(31, false, Value.tofloat()); else if (Key == 7) change_appendage.addParameter(5, false, Value.tofloat()); else if (Key == 8) change_appendage.addParameter(32, false, Value.tofloat()); else if (Key == 9) change_appendage.addParameter(11, false, Value.tofloat()); else if (Key == 10) change_appendage.addParameter(10, false, Value.tofloat()); else if (Key == 11) change_appendage.addParameter(12, false, Value.tofloat()); else if (Key == 12) change_appendage.addParameter(15, false, Value.tofloat() / 10.0); else if (Key == 13) change_appendage.addParameter(16, false, Value.tofloat() / 10.0); else if (Key == 14) change_appendage.addParameter(33, false, 0 - (Value.tofloat() / 10.0)); else if (Key == 15) change_appendage.addParameter(45, false, Value.tofloat()); else if (Key == 16) change_appendage.addParameter(44, false, Value.tofloat()); else if (Key == 17) change_appendage.addParameter(43, false, Value.tofloat()); else if (Key == 18) change_appendage.addParameter(42, false, Value.tofloat()); else if (Key == 19) change_appendage.addParameter(46, false, Value.tofloat()); } } } } else { DgnAddBuff = false; } } //绘制属性 function DrawAttribute(obj) { if (PrintAbTab) { for (local i = 0; i < 20; i++) { L_sq_DrawCode(TabName[i] + " " + PrintAbTab[i], X + 20 + ((i / 10) * 170), Y + 264 + ((i % 10) * 17), sq_RGBA(255, 255, 255, 250), 1, 1); } } } //绘制主界面 function DrawMain(obj) { //窗口 T_DrawStayAni(obj, "common/marrysystem/main.ani", X, Y, 0, "MarrySystemMain"); //绘制等级相关信息 if (LevelInfo) DrawLevelInfo(obj); //绘制属性相关信息 DrawAttribute(obj); } //开启界面回调 function OpenClassCallBack() { L_NewWindows("Lenheart", 170, 0x65535); local W = sq_GetPopupWindowMainCotrol(170); W.SetVisible(false); W.SetEnable(false); CheckPlayerMarryInfo(); } //绘制入口 function Draw(obj) { if (MainState) { if (WindowObj) { DrawMain(obj); WindowObj.Show(obj); X = WindowObj.X; Y = WindowObj.Y; } else { WindowObj = MarrySystemWindow(X, Y, 329, 404, 28); //坐标 大小 标题栏高度 // WindowObj.DeBugMode = true; } } else { if (WindowObj && WindowObj.YMouseSw == false) { IMouse.ReleaseMouseClick(); WindowObj.YMouseSw = true; WindowObj = null; } } } //逻辑入口 function Proc(obj) { //附加属性 AddAb(obj); if (KeyPressNB.isKeyPress(48, "MarrySystemCloseKey")) { MainState = false; } if(obj.isDead()){ DgnAddBuff = false; } } } function MarrySystem(obj) { local RootTab = getroottable(); if (!RootTab.rawin("MarrySystemCObj")) { local Cobj = MarrySystemC(); RootTab.rawset("MarrySystemCObj", Cobj); EventIcon("婚姻殿堂", 31, 31, Cobj); PlayerEachIcon("查看婚姻信息", Cobj.CheckOtherPlayerMarryInfo); // PlayerEachIcon("我要离婚", PleaseDivorceMe); if (RootTab.rawin("YosinPlayerEachSystem")) { local EventTab = RootTab["YosinPlayerEachSystem"]; local pos1 = null; local pos2 = null; foreach(pos, value in EventTab) { if (value.Name == "邀请结婚") { pos1 = pos; } if (value.Name == "我要离婚") { pos2 = pos; } } if (pos1) EventTab.remove(pos1); if (pos2) EventTab.remove(pos2); if (Cobj.PrintAbTab == null) PlayerEachIcon("邀请结婚", Cobj.PleaseMarryMe); else PlayerEachIcon("我要离婚", Cobj.PleaseDivorceMe); } } else { RootTab["MarrySystemCObj"].Proc(obj); RootTab["MarrySystemCObj"].Draw(obj); } }