380 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			380 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:MidsummerParty.nut
 | |
| 路径:Plugins/MidsummerParty/MidsummerParty.nut
 | |
| 创建日期:2023-10-28	17:40
 | |
| 文件用途:
 | |
| */
 | |
| 
 | |
| class MidsummerPartyC extends BasicsDrawTool {
 | |
|     WindowObj = null; //窗口对象
 | |
|     MainState = false; //主状态
 | |
|     X = 0;
 | |
|     Y = 0;
 | |
| 
 | |
|     InitState = false;
 | |
| 
 | |
|     ItemInfoObject = null;
 | |
|     RewardItemObject = null;
 | |
|     UseItemInfo = null;
 | |
|     ExRewardSchedule = null;
 | |
| 
 | |
|     function GetInfoCallBack(Chunk) {
 | |
|         // Sout("收到包 : \n %L", Chunk);
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         foreach(Value in Jso.items) {
 | |
|             if (Value.Name2.len() == 0)
 | |
|                 Value.Name2 = "Rindro-Team";
 | |
|             ItemInfoObject[Value.Id] <- Value;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function GetInfo() {
 | |
|         local T = {
 | |
|             op = 20061001
 | |
|         }
 | |
|         SendPack(T);
 | |
|     }
 | |
| 
 | |
|     EndRewardFlag = false;
 | |
| 
 | |
|     function GetRewardInfoCallBack(Chunk) {
 | |
|         // Sout("收到包 : \n %L", Chunk);
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         //常规奖励
 | |
|         foreach(Value in Jso.items) {
 | |
|             RewardItemObject[Value.index] <- Value;
 | |
|             // if (Value.ifhas == 0) EndRewardFlag = false;
 | |
|         }
 | |
|         //最终奖励
 | |
|         RewardItemObject["ExReward"] <- Jso.endItem;
 | |
|         //是否已经集齐
 | |
|         EndRewardFlag = Jso.endani;
 | |
|         //消耗道具
 | |
|         UseItemInfo.Id <- Jso.useItem;
 | |
|         //消耗道具数量
 | |
|         UseItemInfo.Count <- Jso.usrItemNum;
 | |
|         if (UseItemInfo.Count > 16) UseItemInfo.Count = 16;
 | |
|         //特殊奖励均衡器
 | |
|         ExRewardSchedule = Jso.plusNum;
 | |
|         local obj = sq_GetMyMasterCharacter();
 | |
|         switch (ExRewardSchedule) {
 | |
|             case 0:
 | |
|                 break;
 | |
|             case 1:
 | |
|                 obj.sq_PlaySound("SUMMERLISTEN_PLAY_01");
 | |
|                 break;
 | |
|             case 2:
 | |
|                 obj.sq_PlaySound("SUMMERLISTEN_PLAY_02");
 | |
|                 break;
 | |
|             case 3:
 | |
|                 obj.sq_PlaySound("SUMMERLISTEN_PLAY_03");
 | |
|                 break;
 | |
|             case 4:
 | |
|                 obj.sq_PlaySound("SUMMERLISTEN_PLAY_04");
 | |
|                 break;
 | |
|         }
 | |
| 
 | |
|         InitState = true;
 | |
|     }
 | |
| 
 | |
|     function GetRewardInfo() {
 | |
|         local T = {
 | |
|             op = 20061003
 | |
|         }
 | |
|         SendPack(T);
 | |
|     }
 | |
| 
 | |
| 
 | |
|     AnimotionState = 0;
 | |
|     AnimotionEndFlag = 0;
 | |
|     NowReawrdObject = null;
 | |
| 
 | |
|     function LotteryPackCallBack(Chunk) {
 | |
|         // Sout("收到包 : \n %L", Chunk);
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         NowReawrdObject = Jso.item;
 | |
|         AnimotionState = 1;
 | |
|         AnimotionEndFlag = Jso.endani;
 | |
|         local obj = sq_GetMyMasterCharacter();
 | |
|         obj.sq_PlaySound("SUMMERLISTEN_START");
 | |
|     }
 | |
| 
 | |
|     //抽奖包
 | |
|     function LotteryPack() {
 | |
|         local T = {
 | |
|             op = 20061005
 | |
|         }
 | |
|         SendPack(T);
 | |
|     }
 | |
| 
 | |
| 
 | |
| 
 | |
|     function EndRewardPackCallBack(Chunk) {
 | |
|         GetRewardInfo();
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //最终奖励包
 | |
|     function EndRewardPack() {
 | |
|         local T = {
 | |
|             op = 20061009
 | |
|         }
 | |
|         SendPack(T);
 | |
|     }
 | |
| 
 | |
| 
 | |
|     constructor() {
 | |
|         ItemInfoObject = {};
 | |
|         RewardItemObject = {};
 | |
|         UseItemInfo = {};
 | |
| 
 | |
|         //获取基础配置回调包
 | |
|         Pack_Control.rawset(20061002, GetInfoCallBack.bindenv(this));
 | |
|         //获取奖励配置回调包
 | |
|         Pack_Control.rawset(20061004, GetRewardInfoCallBack.bindenv(this));
 | |
|         //抽奖回调包
 | |
|         Pack_Control.rawset(20061008, LotteryPackCallBack.bindenv(this));
 | |
|         //最终奖励回包
 | |
|         Pack_Control.rawset(20061010, EndRewardPackCallBack.bindenv(this));
 | |
| 
 | |
|         //获取基础配置
 | |
|         GetInfo();
 | |
|         //获取奖励配置
 | |
|         GetRewardInfo();
 | |
|     }
 | |
| 
 | |
|     function DrawRewardAnimotion(obj) {
 | |
|         if (AnimotionState == 1) {
 | |
|             local Ani = T_DrawDynamicAni(obj, "common/midsummerpartypackage/main_play.ani", X, Y, "MidsummerPartyCR1Effect");
 | |
|             if (sq_IsEnd(Ani)) {
 | |
|                 sq_Rewind(Ani);
 | |
|                 AnimotionState = 2;
 | |
|                 local obj = sq_GetMyMasterCharacter();
 | |
|                 obj.sq_PlaySound("SUMMERLISTEN_RESULT");
 | |
|             }
 | |
|         } else if (AnimotionState == 2) {
 | |
|             local Ani = T_DrawDynamicAni(obj, "common/midsummerpartypackage/main_slotchange.ani", X + 81 + ((NowReawrdObject.index % 4) * 132), Y + 102 + ((NowReawrdObject.index / 4) * 70), "MidsummerPartyCR2Effect");
 | |
|             if (sq_IsEnd(Ani)) {
 | |
|                 sq_Rewind(Ani);
 | |
|                 AnimotionState = 3;
 | |
|             }
 | |
|         } else if (AnimotionState == 3) {
 | |
|             local path = "normal";
 | |
|             if (NowReawrdObject.typ == 1) path = "special";
 | |
|             local Ani = T_DrawDynamicAni(obj, "common/midsummerpartypackage/reward_" + path + "_00.ani", X, Y, "MidsummerPartyCREffect" + NowReawrdObject.typ);
 | |
|             //特殊奖励
 | |
|             DrawItemEx(X + 382, Y + 285, NowReawrdObject.itemid, NowReawrdObject.num);
 | |
| 
 | |
|             local OkButton = LenheartBaseButton(X + 362, Y + 344, 68, 35, "interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 11);
 | |
|             OkButton.Show();
 | |
|             if (OkButton.isLBActive()) {
 | |
|                 local obj = sq_GetMyMasterCharacter();
 | |
|                 obj.sq_PlaySound("SUMMERLISTEN_CLICK");
 | |
| 
 | |
|                 if (AnimotionEndFlag) {
 | |
|                     AnimotionState = 4;
 | |
|                     local obj = sq_GetMyMasterCharacter();
 | |
|                     obj.sq_PlaySound("SUMMERLISTEN_RESULT_02");
 | |
|                 } else {
 | |
|                     AnimotionState = 0;
 | |
|                 }
 | |
| 
 | |
|                 GetRewardInfo();
 | |
|             }
 | |
|         } else if (AnimotionState == 4) {
 | |
|             local Ani = T_DrawDynamicAni(obj, "common/midsummerpartypackage/main_slotchange_all.ani", X, Y, "MidsummerPartyCR6Effect");
 | |
|             if (sq_IsEnd(Ani)) {
 | |
|                 sq_Rewind(Ani);
 | |
|                 AnimotionState = 0;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //绘制主界面
 | |
|     function DrawMain(obj) {
 | |
|         if (!InitState) return;
 | |
|         //绘制主界面
 | |
|         L_sq_DrawImg("interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 0, X, Y);
 | |
|         L_sq_SetDrawImgModel(2, 0);
 | |
|         L_sq_DrawImg("interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 44, X + 242, Y + 22, 0, sq_RGBA(255, 255, 255, 250), 1.0, 1.0, 1);
 | |
|         L_sq_ReleaseDrawImgModel();
 | |
|         T_DrawDynamicAni(obj, "common/midsummerpartypackage/main_loop.ani", X, Y, "MidsummerPartyCMainEffect");
 | |
| 
 | |
|         if (EndRewardFlag) {
 | |
|             L_sq_DrawImg("interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 39, X + 92, Y + 114);
 | |
| 
 | |
|             local OkButton = LenheartBaseButton(X + 652, Y + 239, 68, 35, "interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 11);
 | |
|             OkButton.Show();
 | |
|             if (OkButton.isLBActive()) {
 | |
|                 local obj = sq_GetMyMasterCharacter();
 | |
|                 obj.sq_PlaySound("SUMMERLISTEN_CLICK");
 | |
|                 EndRewardPack();
 | |
|             }
 | |
|         } else {
 | |
|             //常规奖励
 | |
|             foreach(Value in RewardItemObject) {
 | |
|                 if ("index" in Value) {
 | |
|                     if (Value.ifhas) {
 | |
|                         L_sq_DrawImg("interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 23 + Value.index, X + 81 + ((Value.index % 4) * 132), Y + 102 + ((Value.index / 4) * 70));
 | |
|                     } else {
 | |
|                         DrawItemEx(X + 142 + ((Value.index % 4) * 132), Y + 134 + ((Value.index / 4) * 70), Value.itemid, Value.num);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         //特殊奖励
 | |
|         DrawItemEx(X + 672, Y + 204, RewardItemObject.ExReward, 1);
 | |
| 
 | |
|         //消耗道具信息绘制
 | |
|         if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X + 271, Y + 448, 24, 24)) {
 | |
|             ItemInfoDrawS = {};
 | |
|             ItemInfoDrawS.X <- X + 271;
 | |
|             ItemInfoDrawS.Y <- Y + 448;
 | |
|             ItemInfoDrawS.ItemId <- UseItemInfo.Id;
 | |
|         }
 | |
| 
 | |
|         //消耗道具数量绘制
 | |
|         L_sq_DrawImg("interface2/cs_shop/cs_packageevent/2021_summer/num_blue.img", 10, X + 258, Y + 465);
 | |
|         DrawSmallNumber(UseItemInfo.Count);
 | |
| 
 | |
|         //特殊奖励均衡器
 | |
|         L_sq_DrawImg("interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 5 + ExRewardSchedule, X + 459, Y + 431);
 | |
| 
 | |
| 
 | |
| 
 | |
|         //启动按钮
 | |
|         local PlayButton = LenheartBaseButton(X + 338, Y + 410, 121, 86, "interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 1);
 | |
|         PlayButton.Show();
 | |
|         if (PlayButton.isLBActive()) {
 | |
|             local obj = sq_GetMyMasterCharacter();
 | |
|             obj.sq_PlaySound("SUMMERLISTEN_TAG");
 | |
|             LotteryPack();
 | |
|         }
 | |
| 
 | |
|         //购买按钮
 | |
|         local ShopButton = LenheartBaseButton(X + 352, Y + 500, 121, 86, "interface2/cs_shop/cs_packageevent/2021_summer/hearoursummer.img", 40);
 | |
|         ShopButton.Show();
 | |
|         if (ShopButton.isLBActive()) {
 | |
|             local obj = sq_GetMyMasterCharacter();
 | |
|             obj.sq_PlaySound("SUMMERLISTEN_CLICK");
 | |
|             L_sq_UseSkill(DIK_F5);
 | |
|             MainState = false;
 | |
|         }
 | |
| 
 | |
|     }
 | |
| 
 | |
|     //开启界面回调
 | |
|     function OpenClassCallBack() {
 | |
| 
 | |
|         L_NewWindows("Lenheart", 170, 0x65535);
 | |
|         local W = sq_GetPopupWindowMainCotrol(170);
 | |
|         W.SetVisible(false);
 | |
|         W.SetEnable(false);
 | |
| 
 | |
| 
 | |
|         //获取奖励配置
 | |
|         GetRewardInfo();
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //绘制道具相信信息
 | |
|     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;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     ItemInfoDrawS = null;
 | |
|     //绘制入口
 | |
|     function Draw(obj) {
 | |
|         ItemInfoDrawS = null;
 | |
| 
 | |
|         if (MainState) {
 | |
|             if (WindowObj) {
 | |
|                 DrawMain(obj);
 | |
|                 DrawRewardAnimotion(obj);
 | |
|                 WindowObj.Show(obj);
 | |
|                 X = WindowObj.X;
 | |
|                 Y = WindowObj.Y;
 | |
| 
 | |
|                 DrawItemInfo(obj);
 | |
|             } else {
 | |
|                 WindowObj = LenheartWindow(X, Y, 800, 600, 28); //坐标 大小 标题栏高度
 | |
|                 // WindowObj.DeBugMode = true;
 | |
|             }
 | |
|         } else {
 | |
|             if (WindowObj && WindowObj.YMouseSw == false) {
 | |
|                 IMouse.ReleaseMouseClick();
 | |
|                 WindowObj.YMouseSw = true;
 | |
|                 WindowObj = null;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //逻辑入口
 | |
|     function Proc(obj) {
 | |
|         if (KeyPressNB.isKeyPress(48, "MidsummerPartyCloseKey")) {
 | |
|             MainState = false;
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|     //绘制道具带道具信息
 | |
|     function DrawItemEx(X, Y, Id, Count) {
 | |
|         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;
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //绘制等级数字
 | |
|     function DrawSmallNumber(num) {
 | |
|         num = num.tostring();
 | |
|         local x = X + 284;
 | |
|         local y = Y + 465;
 | |
|         if (num.len() == 2) x = X + 276;
 | |
|         for (local i = 0; i< num.len(); i++) {
 | |
|             local n = num.slice(i, i + 1);
 | |
|             n = n.tointeger();
 | |
|             local Img = "interface2/cs_shop/cs_packageevent/2021_summer/num_blue.img";
 | |
|             L_sq_DrawImg(Img, n, x + (i * 9), y);
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| function MidsummerParty(obj) {
 | |
|     local RootTab = getroottable();
 | |
|     if (!RootTab.rawin("MidsummerPartyCObj")) {
 | |
|         local Cobj = MidsummerPartyC();
 | |
|         RootTab.rawset("MidsummerPartyCObj", Cobj);
 | |
|         EventIcon("希曼音乐会", 133, 133, Cobj);
 | |
|     } else {
 | |
|         RootTab["MidsummerPartyCObj"].Proc(obj);
 | |
|         RootTab["MidsummerPartyCObj"].Draw(obj);
 | |
|     }
 | |
| }
 | |
| if (getroottable().rawin("LenheartFuncTab")) {
 | |
|     getroottable()["LenheartFuncTab"].rawset("MidsummerParty_LenheartFunc", MidsummerParty);
 | |
| } else {
 | |
|     local T = {};
 | |
|     T.rawset("MidsummerParty_LenheartFunc", MidsummerParty);
 | |
|     getroottable().rawset("LenheartFuncTab", T);
 | |
| } |