438 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			438 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:RaidAuction.nut
 | |
| 路径:Plugins/RaidAuction/RaidAuction.nut
 | |
| 创建日期:2023-04-24	15:43
 | |
| 文件用途:团本竞拍
 | |
| */
 | |
| 
 | |
| //HudPro按钮类
 | |
| class RAIDAUCTIONButtonPro extends BasicsDrawTool //  obj  --  按钮名称  --  X坐标  --  Y坐标  --  Ani调用路径  --  宽度  --  高度
 | |
| {
 | |
|     obj = null; //Obj对象
 | |
|     State = 0; //按钮状态
 | |
|     ClickEnble = false; //点击效果
 | |
|     ButtonDynamic = false; //动态按钮效果
 | |
|     BaseFrame = null;
 | |
| 
 | |
|     CustomClickEnble = false; //自定义点击效果
 | |
|     CustomClickAnifile = null; //自定义点击效果Ani路径
 | |
|     CustomButtonName = null; //自定义点击效果名称
 | |
|     CustomClickFrame = null; //自定义点击效果Ani编号
 | |
|     CustomClickx = null; //自定义点击效果X坐标
 | |
|     CustomClicky = null; //自定义点击效果Y坐标
 | |
| 
 | |
| 
 | |
|     RectEnble = false; //悬停效果
 | |
|     RectButtonName = null; //悬停名称
 | |
|     RectBaseAnifile = null; //悬停Ani路径
 | |
|     RectFrame = null; //非动态按钮的悬停调用Ani编号
 | |
|     Rectx = null; //悬停X坐标
 | |
|     Recty = null; //悬停Y坐标
 | |
| 
 | |
| 
 | |
|     ButtonName = null; //按钮名称
 | |
|     x = null; //X坐标
 | |
|     y = null; //Y坐标
 | |
|     BaseAnifile = null; //调用Ani路径
 | |
|     width = null; //可点击宽度
 | |
|     length = null; //可点击高度
 | |
| 
 | |
|     Mobj = null; //鼠标对象
 | |
|     //构造函数
 | |
|     constructor(gObj, gButtonName, gX, gY, gAnifile, gWidth, gLength, gBaseFrame) {
 | |
|         obj = gObj;
 | |
|         ButtonName = gButtonName;
 | |
|         x = gX;
 | |
|         y = gY;
 | |
|         BaseAnifile = gAnifile;
 | |
|         width = gWidth;
 | |
|         length = gLength;
 | |
|         BaseFrame = gBaseFrame;
 | |
|         if (getroottable().rawin("MouseObject")) Mobj = getroottable()["MouseObject"];
 | |
|     }
 | |
|     //绘制按钮
 | |
|     function Show() {
 | |
|         if (ClickEnble) //是否开启点击效果
 | |
|         {
 | |
|             if (isLBDown() && State == 0) //按下左键并且按钮处于弹起状态
 | |
|             {
 | |
|                 State = 1; //按键进入按下状态
 | |
|                 ++y;
 | |
|             }
 | |
|             if (!isLBDown() && State == 1) //按下左键并且按钮处于弹起状态
 | |
|             {
 | |
|                 State = 0; //按键进入弹起状态
 | |
|                 --y;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         if (CustomClickEnble) //是否开启自定义点击效果
 | |
|         {
 | |
|             if (isLBDown()) //按下左键并且按钮处于弹起状态
 | |
|             {
 | |
|                 if (!ButtonDynamic) T_DrawStayAni(obj, CustomClickAnifile, CustomClickx, CustomClicky, CustomClickFrame, CustomButtonName);
 | |
|                 else T_DrawDynamicAni(obj, CustomClickAnifile, CustomClickx, CustomClicky, CustomButtonName);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         if (RectEnble) //开启悬停效果时
 | |
|         {
 | |
|             if ((isInRect() && !isLBDown()) || (isInRect() && !CustomClickEnble)) //如果鼠标悬停的时候  并且没有点击的时候
 | |
|             {
 | |
|                 //IMouse.SetMouseTask(44);
 | |
|                 if (!ButtonDynamic) T_DrawStayAni(obj, RectBaseAnifile, Rectx, Recty, RectFrame, RectButtonName);
 | |
|                 else T_DrawDynamicAni(obj, RectBaseAnifile, Rectx, Recty, RectButtonName);
 | |
|             }
 | |
|         }
 | |
|         if (!isInRect()) //如果鼠标没有悬停的时候
 | |
|         {
 | |
|             //IMouse.SetMouseTask(0);
 | |
|             if (!ButtonDynamic) T_DrawStayAni(obj, BaseAnifile, x, y, BaseFrame, ButtonName);
 | |
|             else T_DrawDynamicAni(obj, BaseAnifile, x, y, ButtonName);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //设置自定义点击效果
 | |
|     function SetCustomClickEnble(bool, gButtonName, gX, gY, gAnifile, gFrame) {
 | |
|         CustomClickEnble = bool; //自定义点击效果
 | |
|         CustomClickAnifile = gAnifile; //自定义点击效果Ani路径
 | |
|         CustomButtonName = gButtonName; //自定义点击效果名称
 | |
|         CustomClickFrame = gFrame; //自定义点击效果Ani编号
 | |
|         CustomClickx = gX; //自定义点击效果X坐标
 | |
|         CustomClicky = gY; //自定义点击效果Y坐标
 | |
|     }
 | |
| 
 | |
|     //设置悬停效果
 | |
|     function SetRectEnble(bool, gButtonName, gX, gY, gAnifile, gFrame) {
 | |
|         RectEnble = bool; //悬停效果
 | |
|         RectButtonName = gButtonName; //悬停名称
 | |
|         RectBaseAnifile = gAnifile; //悬停Ani路径
 | |
|         RectFrame = gFrame; //非动态按钮的悬停调用Ani编号
 | |
|         Rectx = gX; //悬停X坐标
 | |
|         Recty = gY; //悬停Y坐标
 | |
|     }
 | |
| 
 | |
|     //设置动态按钮
 | |
|     function SetClickEnble(bool) {
 | |
|         ButtonDynamic = bool;
 | |
|     }
 | |
| 
 | |
|     //设置点击效果
 | |
|     function SetClickEnble(bool) {
 | |
|         ClickEnble = bool;
 | |
|     }
 | |
| 
 | |
|     //悬停状态
 | |
|     function isInRect() {
 | |
|         if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 5, 5, x, y, width, length)) return true;
 | |
|         else return false;
 | |
|     }
 | |
|     //左键按下状态
 | |
|     function isLBDown() {
 | |
|         if (isInRect() && Mobj.Lb == 1) return true;
 | |
|         else return false;
 | |
|     }
 | |
|     //左键弹起状态
 | |
|     function isLBUp() {
 | |
|         if (isInRect() && Mobj.Lb == 0) return true;
 | |
|         else return false;
 | |
|     }
 | |
| 
 | |
|     //左键单击状态
 | |
|     function isLBActive() {
 | |
|         if (isInRect() && Mobj.LbEvent) return true;
 | |
|         else return false;
 | |
|     }
 | |
| }
 | |
| 
 | |
| class RAIDAUCTIONWindow extends BasicsDrawTool {
 | |
|     //宽度
 | |
|     Width = null;
 | |
|     //高度
 | |
|     Height = null;
 | |
|     //标题高度
 | |
|     TitleH = null;
 | |
| 
 | |
|     //X坐标
 | |
|     X = null;
 | |
|     //Y坐标
 | |
|     Y = null;
 | |
| 
 | |
|     YMouseSw = true;
 | |
|     Mobj = 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 Show(obj) {
 | |
|         //sq_DrawBox(X, Y, Width, Height, 0xffffffff);
 | |
| 
 | |
|         //设定鼠标逻辑
 | |
|         LockMouse();
 | |
| 
 | |
| 
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| class RAIDAUCTIONC extends BasicsDrawTool {
 | |
| 
 | |
|     Window = null;
 | |
|     WindowName = null;
 | |
|     X = 235;
 | |
|     Y = 109;
 | |
|     State = 0;
 | |
| 
 | |
|     AuctionPack = null;
 | |
|     Cost = null;
 | |
|     NowPrice = null;
 | |
| 
 | |
|     TimeObj = null;
 | |
| 
 | |
| 
 | |
|     function Raid_Auction_Item_Pack_CallBack(Chunk) {
 | |
|         //Sout("收到包内容为 \n %L", Chunk);
 | |
|         local Buffer = Json_STL("Raid_Auction_Item_Pack_CallBack");
 | |
|         Buffer.Parse(Chunk, 0, false);
 | |
| 
 | |
|         local RootTab = getroottable();
 | |
|         if (RootTab.rawin("RAIDAUCTIONObj")) {
 | |
|             RootTab["RAIDAUCTIONObj"].State = 1;
 | |
|             RootTab["RAIDAUCTIONObj"].Cost = Buffer.Get("cost");
 | |
|             RootTab["RAIDAUCTIONObj"].WindowName = Buffer.Get("PDungeon_Name");
 | |
|             RootTab["RAIDAUCTIONObj"].AuctionTimeReset();
 | |
| 
 | |
|             RootTab["RAIDAUCTIONObj"].AuctionPack = null;
 | |
|             RootTab["RAIDAUCTIONObj"].AuctionPack = [];
 | |
| 
 | |
|             for (local i = 0; i< 5; i++) {
 | |
|                 local Gid = Buffer.Get("auctionpack->" + i + "->id");
 | |
|                 if (Gid == false) break;
 | |
|                 local Gcount = Buffer.Get("auctionpack->" + i + "->count");
 | |
|                 local Gname = Buffer.Get("auctionpack->" + i + "->name");
 | |
|                 local Grarity = Buffer.Get("auctionpack->" + i + "->rarity");
 | |
|                 local Gprice = Buffer.Get("auctionpack->" + i + "->price");
 | |
| 
 | |
|                 // local Gnow = i == 0 ? true : false;
 | |
|                 local Gnow = Buffer.Get("auctionpack->" + i + "->now");
 | |
|                 local Gover = Buffer.Get("auctionpack->" + i + "->over");
 | |
|                 local Gplayer = Buffer.Get("auctionpack->" + i + "->playername");
 | |
|                 local T = {
 | |
|                     id = Gid,
 | |
|                     count = Gcount,
 | |
|                     name = Gname,
 | |
|                     rarity = Grarity,
 | |
|                     price = Gprice,
 | |
|                     now = Gnow,
 | |
|                     over = Gover,
 | |
|                     player = Gplayer,
 | |
|                 }
 | |
|                 RootTab["RAIDAUCTIONObj"].AuctionPack.append(T);
 | |
|             }
 | |
| 
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function Raid_Auction_Close_Window_CallBack(Chunk) {
 | |
|         ////Sout("收到包内容为 \n %L", Chunk);
 | |
|         //local Buffer = Json_STL("Raid_Auction_Item_Pack_CallBack");
 | |
|         //Buffer.Parse(Chunk, 0, false);
 | |
| 
 | |
|         local RootTab = getroottable();
 | |
|         if (RootTab.rawin("RAIDAUCTIONObj")) {
 | |
|             RootTab["RAIDAUCTIONObj"].State = 0;
 | |
|             RootTab["RAIDAUCTIONObj"].Cost = null;
 | |
|             RootTab["RAIDAUCTIONObj"].WindowName = null;
 | |
|             RootTab["RAIDAUCTIONObj"].AuctionPack = null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     constructor() {
 | |
|         AuctionPack = [];
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         //注册装备信息回调
 | |
|         Pack_Control.rawset(25700002, Raid_Auction_Item_Pack_CallBack);
 | |
|         //关闭窗口回调
 | |
|         Pack_Control.rawset(25700008, Raid_Auction_Close_Window_CallBack);
 | |
|     }
 | |
| 
 | |
| 
 | |
|     function AuctionTimeReset() {
 | |
|         if (TimeObj) TimeObj.Delete();
 | |
|         TimeObj = null;
 | |
|         TimeObj = TimeSTL("AuctionTimeObj", 15000);
 | |
|         TimeObj.Start();
 | |
|     }
 | |
| 
 | |
|     function Proc(obj) {
 | |
|         //窗口打开生成窗口
 | |
|         if (!this.Window && State == 1) {
 | |
|             this.Window = RAIDAUCTIONWindow(235, 109, 329, 382, 24);
 | |
|         } else if (this.Window && State == 1) {
 | |
|             this.Window.Show(obj);
 | |
|         } else if (State == 0) {
 | |
|             if (this.Window && this.Window.YMouseSw == false) {
 | |
|                 IMouse.ReleaseMouseClick();
 | |
|                 this.Window.YMouseSw = true;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         if (KeyPressNB.isKeyPress(48, "RaidAuction")) {
 | |
|             State = 0;
 | |
|         }
 | |
| 
 | |
|     }
 | |
| 
 | |
| 
 | |
| 
 | |
|     //绘制主界面
 | |
|     function DrawMain(obj) {
 | |
|         //主界面背景
 | |
|         T_DrawStayAni(obj, "common/raid_auction/yosin/tbjp.ani", X, Y, 4, "Raid_AuctionSystemMain");
 | |
| 
 | |
|         //绘制窗口名字
 | |
|         L_sq_DrawCode("副本: 【" + WindowName + "】 的竞拍", X + 112, Y + 7, sq_RGBA(255, 255, 184, 250), 0, 1);
 | |
|     }
 | |
| 
 | |
|     //绘制竞拍项目
 | |
|     function DrawItem(obj) {
 | |
|         foreach(Pos, Item in AuctionPack) {
 | |
| 
 | |
|             if (Item.now == true) {
 | |
|                 T_DrawStayAni(obj, "common/raid_auction/yosin/tbjp.ani", X + 38 + (Pos * 50), Y + 40, 3, "Raid_AuctionSystemSlotLight");
 | |
|                 T_DrawStayAni(obj, "common/raid_auction/yosin/tbjp.ani", X + 38 + (Pos * 50), Y + 40, 7, "Raid_AuctionSystemSlotLight + 1");
 | |
|                 //绘制竞拍物品名字
 | |
|                 L_sq_DrawCode("【" + Item.name + "】", X + 52, Y + 230 - 35, sq_RGBA(255, 255, 184, 250), 0, 1);
 | |
|                 //绘制竞拍者名字
 | |
|                 L_sq_DrawCode("【" + Item.player + "】", X + 52, Y + 230, sq_RGBA(255, 255, 184, 250), 0, 1);
 | |
|                 //绘制当前价格
 | |
|                 L_sq_DrawCode(Item.price.tostring(), X + 52 + 172, Y + 230, sq_RGBA(255, 255, 184, 250), 0, 1);
 | |
|                 NowPrice = Item.price;
 | |
|             }
 | |
|             L_Sq_DrawItem(X + 51 + (Pos * 50), Y + 53, Item.id, Item.count, 0, 0, 0);
 | |
|             if (Item.over == true) {
 | |
|                 T_DrawStayAni(obj, "common/raid_auction/yosin/tbjp.ani", X + 48 + (Pos * 50), Y + 50, 5, "Raid_AuctionSystemSlotOver");
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //绘制进度条
 | |
|     function DrawTimeP(obj) {
 | |
|         if (TimeObj == null) return;
 | |
| 
 | |
|         local Time = TimeObj.Get();
 | |
|         local NTime = ((15000 - Time).tofloat() / 1000.0).tostring();
 | |
|         local HRate = Time.tofloat() / 15000.0;
 | |
| 
 | |
| 
 | |
|         //进度条
 | |
|         setClip(X + 29, Y + 119, X + 29 + 272 - (272.0 * HRate).tointeger(), Y + 119 + 12); //开始裁切
 | |
|         T_DrawStayAni(obj, "common/raid_auction/yosin/tbjp.ani", X + 29, Y + 119, 6, "Raid_AuctionSystemTimeP");
 | |
|         releaseClip(); //裁切结束
 | |
| 
 | |
|         //剩余时间
 | |
|         L_sq_DrawCode("剩余时间: " + NTime + "s", X + 128, Y + 119, sq_RGBA(21, 187, 255, 250), 0, 1);
 | |
|     }
 | |
| 
 | |
| 
 | |
|     function GetNum(count) {
 | |
|         local a = 1;
 | |
|         if (count == 0) return a;
 | |
|         local b = 10;
 | |
|         for (local i = 0; i< count - 1; i++) {
 | |
|             b *= b;
 | |
|         }
 | |
|         return a * b;
 | |
|     }
 | |
|     //绘制按钮
 | |
|     function DrawAuctionButton(obj) {
 | |
| 
 | |
|         for (local i = 0; i< 3; i++) {
 | |
|             local Button = RAIDAUCTIONButtonPro(obj, "Raid_AuctionButton" + i, X + 28 + (i * 98), Y + 266, "common/raid_auction/yosin/tbjp.ani", 77, 24, 0);
 | |
|             Button.SetRectEnble(true, "Raid_AuctionButtonr" + i, X + 28 + (i * 98), Y + 266, "common/raid_auction/yosin/tbjp.ani", 1);
 | |
|             Button.SetCustomClickEnble(true, "Raid_AuctionButtonc" + i, X + 28 + (i * 98), Y + 266, "common/raid_auction/yosin/tbjp.ani", 2);
 | |
|             Button.Show();
 | |
| 
 | |
|             L_sq_DrawCode("+" + GetNum(i), X + 60 + (i * 98), Y + 272, sq_RGBA(21, 187, 255, 250), 0, 1);
 | |
|             if (Button.isLBActive()) {
 | |
|                 //print(i);
 | |
|                 local T = {
 | |
|                     op = 25700003,
 | |
|                     price = NowPrice + GetNum(i),
 | |
|                     cost = this.Cost,
 | |
|                     addcost = GetNum(i),
 | |
|                 }
 | |
| 
 | |
|                 local str = Json.Encode(T);
 | |
|                 L_sq_SendPackType(130);
 | |
|                 L_sq_SendPackWChar(str);
 | |
|                 L_sq_SendPack();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|     }
 | |
| 
 | |
| 
 | |
|     function Draw(obj) {
 | |
|         if (State == 1) {
 | |
|             DrawMain(obj); //绘制主界面
 | |
| 
 | |
|             DrawItem(obj); //绘制竞拍项目
 | |
| 
 | |
|             DrawTimeP(obj); //绘制进度条
 | |
| 
 | |
|             DrawAuctionButton(obj); //绘制按钮
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| function Raid_Auction(obj) {
 | |
|     local RootTab = getroottable();
 | |
|     if (!RootTab.rawin("RAIDAUCTIONObj")) {
 | |
|         local Cobj = RAIDAUCTIONC();
 | |
|         RootTab.rawset("RAIDAUCTIONObj", Cobj);
 | |
|     } else {
 | |
|         RootTab["RAIDAUCTIONObj"].Proc(obj);
 | |
|         RootTab["RAIDAUCTIONObj"].Draw(obj);
 | |
|     }
 | |
|     // print(11);
 | |
| } |