764 lines
		
	
	
		
			27 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
		
		
			
		
	
	
			764 lines
		
	
	
		
			27 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
|  | /* | ||
|  | 文件名:Scheming.nut | ||
|  | 路径:Project/Scheming/Scheming.nut | ||
|  | 创建日期:2025-03-04	10:15 | ||
|  | 文件用途:心机牌 | ||
|  | */ | ||
|  | class SchemingC_Player { | ||
|  |     Charc = null; | ||
|  |     Name = ""; | ||
|  |     IsMyControl = true; | ||
|  |     Card = null; | ||
|  | 
 | ||
|  | 
 | ||
|  |     //Img | ||
|  |     Img = Rindro_Image("xjp.img"); | ||
|  | 
 | ||
|  |     //生命值 | ||
|  |     Hp = 3; | ||
|  | 
 | ||
|  |     constructor() { | ||
|  |         Card = [0, 1, 2]; | ||
|  |     } | ||
|  | 
 | ||
|  |     //职业int 装备array 名字string | ||
|  |     function SetPlayer(Job, Equ, Name) { | ||
|  |         this.Name = Name; | ||
|  |         Charc = Rindro_Draw_Character(Job, Equ, "rest.ani", null); | ||
|  |     } | ||
|  | 
 | ||
|  |     function SetCard(gCard) { | ||
|  |         Card = gCard; | ||
|  |     } | ||
|  | 
 | ||
|  |     function Draw(Xpos, Ypos) { | ||
|  |         if (!Charc) return; | ||
|  |         //绘制头像背景框 | ||
|  |         sq_DrawBox(Xpos - 1, Ypos - 1, 26, 20, sq_RGBA(127, 132, 142, 250)); | ||
|  |         sq_DrawBox(Xpos - 1, Ypos - 1 + 20, 80, 20, sq_RGBA(127, 132, 142, 250)); | ||
|  |         L_sq_DrawCode(this.Name, Xpos + 44 - (LenheartTextClass.GetStringLength(this.Name) / 2), Ypos + 23, IsMyControl ? sq_RGBA(157, 245, 10, 250) : sq_RGBA(230, 200, 155, 250), 1, 1); | ||
|  |         Charc.DrawFace(Xpos, Ypos); | ||
|  |         DrawHp(Xpos, Ypos); | ||
|  |     } | ||
|  | 
 | ||
|  |     function DrawHp(Xpos, Ypos) { | ||
|  |         for (local i = 0; i< Hp; i++) { | ||
|  |             Img.DrawPng(2, Xpos + 28 + (i * 18), Ypos + 2); | ||
|  |         } | ||
|  |     } | ||
|  | } | ||
|  | class SchemingC_Card extends LenheartNewUI_CommonUi { | ||
|  |     State = 0; | ||
|  |     //Img | ||
|  |     Img = Rindro_Image("xjpcard.img"); | ||
|  |     Id = 1; | ||
|  |     //是否选中 | ||
|  |     IsSelect = false; | ||
|  | 
 | ||
|  |     constructor() { | ||
|  |         Id = 1; | ||
|  |         LenheartNewUI_CommonUi.constructor(0, 0, 82, 107); | ||
|  | 
 | ||
|  |         OnClick = function() { | ||
|  |             IsSelect = !IsSelect; | ||
|  |             if (IsSelect) { | ||
|  |                 Localtion_Y -= 30; | ||
|  |             } else { | ||
|  |                 Localtion_Y += 30; | ||
|  |             } | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     function SetCardId(CardId) { | ||
|  |         Id = CardId + 1; | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     function Show(obj) { | ||
|  |         //不可用 | ||
|  |         if (State == 8) { | ||
|  |             Img.DrawPng(Id, X, Y); | ||
|  |         } else { | ||
|  |             //按下 | ||
|  |             if (isLBDown) { | ||
|  |                 Img.DrawPng(6, X, Y); | ||
|  |                 Img.DrawPng(Id, X, Y); | ||
|  |             } | ||
|  |             //悬停 | ||
|  |             else if (isInRect) { | ||
|  |                 if (!IsSelect) Img.DrawPng(5, X, Y); | ||
|  |                 else Img.DrawPng(6, X, Y); | ||
|  |                 Img.DrawPng(Id, X, Y); | ||
|  |             } | ||
|  |             //普通 | ||
|  |             else { | ||
|  |                 if (IsSelect) Img.DrawPng(6, X, Y); | ||
|  |                 Img.DrawPng(Id, X, Y); | ||
|  |             } | ||
|  |         } | ||
|  |     } | ||
|  | } | ||
|  | class SchemingC extends LenheartNewUI_Windows { | ||
|  |     //调试模式 | ||
|  |     // DeBugMode = true; | ||
|  | 
 | ||
|  |     //不是窗口 | ||
|  |     // NoWindow = true; | ||
|  | 
 | ||
|  | 
 | ||
|  |     //是否可见 | ||
|  |     Visible = false; | ||
|  | 
 | ||
|  |     //本服或跨服模式 | ||
|  |     IsServer = false; | ||
|  | 
 | ||
|  |     //胜利场次 | ||
|  |     WinCount = 0; | ||
|  |     //排名 | ||
|  |     Ranking = 0; | ||
|  |     //跨服排名 | ||
|  |     OnlineRanking = 0; | ||
|  |     //入场券数量 | ||
|  |     TicketCount = 0; | ||
|  | 
 | ||
|  |     //阶段 | ||
|  |     Stage = 0; | ||
|  |     //游戏状态 | ||
|  |     GameState = -1; | ||
|  |     //发牌阶段 | ||
|  |     DealCardState = 0; | ||
|  |     //发牌时间管理器 | ||
|  |     DealCardTimer = Clock(); | ||
|  |     //翻牌阶段 | ||
|  |     FlipCardState = 0; | ||
|  |     //翻牌时间管理器 | ||
|  |     FlipCardTimer = Clock(); | ||
|  |     //随机牌阶段 | ||
|  |     RandCardState = 0; | ||
|  |     //随机牌时间管理器 | ||
|  |     RandCardTimer = Clock(); | ||
|  |     //匹配状态 | ||
|  |     MatchState = 0; | ||
|  | 
 | ||
|  |     //Img | ||
|  |     Img = Rindro_Image("xjp.img"); | ||
|  |     //CardImg | ||
|  |     CardImg = Rindro_Image("xjpcard.img"); | ||
|  | 
 | ||
|  |     //X轴方向偏移基准值 | ||
|  |     XOffset = 0; | ||
|  | 
 | ||
|  |     //玩家集合 | ||
|  |     PlayerList = null; | ||
|  |     PlayerPos = [ | ||
|  |         [360, 550], | ||
|  |         [1, 274], | ||
|  |         [360, 10], | ||
|  |         [720, 274] | ||
|  |     ]; | ||
|  | 
 | ||
|  |     //卡牌集合 | ||
|  |     CardList = null; | ||
|  | 
 | ||
|  |     //点击效果Ani | ||
|  |     ClickEffFrameArr = null; | ||
|  |     ClickEffAni = null; | ||
|  | 
 | ||
|  |     //匹配动画Ani | ||
|  |     MatchImg2 = Rindro_Image("xjploading2.img"); | ||
|  |     MatchAni2 = null; | ||
|  | 
 | ||
|  |     //主牌 | ||
|  |     MainCardId = 0; | ||
|  | 
 | ||
|  |     //出牌动画演出Flag | ||
|  |     PlayCardAniTimer = Clock(); | ||
|  |     PlayCardAniFlag = -1; | ||
|  |     PlayCardAniCount = 3; | ||
|  | 
 | ||
|  |     //质疑开牌动画演出 | ||
|  |     QuestionAniTimer = Clock(); | ||
|  |     QuestionAniFlag = -1; | ||
|  |     QuestionList = null; | ||
|  | 
 | ||
|  |     //回合玩家 | ||
|  |     RoundCharac = 0; | ||
|  |     //回合剩余时间 | ||
|  |     RoundTime = Clock(); | ||
|  | 
 | ||
|  | 
 | ||
|  |     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { | ||
|  |         Childrens = []; | ||
|  |         ClickEffAni = []; | ||
|  |         //计算宽屏适配 | ||
|  |         XOffset = (gWidth == 800 ? 0 : 133); | ||
|  | 
 | ||
|  |         //初始化构造 | ||
|  |         PlayerList = array(4); | ||
|  |         for (local i = 0; i< 4; i++) { | ||
|  |             PlayerList[i] = SchemingC_Player(); | ||
|  |         } | ||
|  |         CardList = array(5); | ||
|  |         for (local i = 0; i< 5; i++) { | ||
|  |             CardList[i] = SchemingC_Card(); | ||
|  |             CardList[i].Localtion_X = (XOffset + 400) - 205 + (i * 82) | ||
|  |             CardList[i].Localtion_Y = 426; | ||
|  |             Childrens.append(CardList[i]); | ||
|  |         } | ||
|  |         //注册控件 | ||
|  |         RegisterWidget(); | ||
|  |         //注册收包 | ||
|  |         RegisterPacket(); | ||
|  | 
 | ||
|  |         LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); | ||
|  | 
 | ||
|  |         //记录点击效果帧 | ||
|  |         ClickEffFrameArr = []; | ||
|  |         for (local i = 0; i< 13; i++) { | ||
|  |             local T = { | ||
|  |                 ImgIndex = i, | ||
|  |                 Delay = 50, | ||
|  |                 Pos = [0, 0] | ||
|  |             } | ||
|  |             ClickEffFrameArr.append(T); | ||
|  |         } | ||
|  | 
 | ||
|  |         //匹配动画 | ||
|  |         local MatchEffFrameArr2 = []; | ||
|  |         for (local i = 0; i< 24; i++) { | ||
|  |             local T = { | ||
|  |                 ImgIndex = i, | ||
|  |                 Delay = 40, | ||
|  |                 Pos = [0, 0] | ||
|  |             } | ||
|  |             MatchEffFrameArr2.append(T); | ||
|  |             //预加载 | ||
|  |             MatchImg2.DrawPng(i, -500, -500); | ||
|  |         } | ||
|  |         MatchAni2 = Lenheart_Ani("xjploading2.img", MatchEffFrameArr2, [XOffset + 356, 310]); | ||
|  |         MatchAni2.ImgPath = "xjploading2.img"; | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  |     function RegisterWidget() { | ||
|  |         //质疑按钮 | ||
|  |         local QuestionButton = LenheartNewUI_BaseButton(getroottable().Rindro_Scr_Width == 800 ? 680 : 860, 500, 87, 34, "xjp.img", 5); | ||
|  |         QuestionButton.OnClick = function() { | ||
|  | 
 | ||
|  |         }.bindenv(this); | ||
|  |         QuestionButton.SetCallBackFunc(function(Button) { | ||
|  |             if (Stage == 0) Button.Visible = false; | ||
|  |             else Button.Visible = true; | ||
|  |         }.bindenv(this)); | ||
|  |         Childrens.append(QuestionButton); | ||
|  | 
 | ||
|  |         //出牌按钮 | ||
|  |         local ProduceButton = LenheartNewUI_BaseButton(getroottable().Rindro_Scr_Width == 800 ? 680 : 860, 536, 87, 34, "xjp.img", 8); | ||
|  |         ProduceButton.OnClick = function() { | ||
|  |             local SendCardList = []; | ||
|  |             foreach(Index, Card in CardList) { | ||
|  |                 if (Card.IsSelect) SendCardList.append(Index); | ||
|  |             } | ||
|  |             if (SendCardList.len() == 0) return; | ||
|  |             //发送出牌包 | ||
|  |             local T = { | ||
|  |                 op = 20092007, | ||
|  |                 CardList = SendCardList | ||
|  |             }; | ||
|  |             SendPackEx(T); | ||
|  |         }.bindenv(this); | ||
|  |         ProduceButton.SetCallBackFunc(function(Button) { | ||
|  |             if (Stage == 0) Button.Visible = false; | ||
|  |             else Button.Visible = true; | ||
|  |         }.bindenv(this)); | ||
|  |         Childrens.append(ProduceButton); | ||
|  | 
 | ||
|  |         //匹配按钮 | ||
|  |         local MatchButton = LenheartNewUI_BaseButton(getroottable().Rindro_Scr_Width == 800 ? 355 : 488, 400, 87, 34, "xjp.img", 16); | ||
|  |         MatchButton.OnClickEx = function(Button) { | ||
|  |             if (!Button.Visible) return; | ||
|  |             //发送开始匹配包 | ||
|  |             local T = { | ||
|  |                 op = 20092001, | ||
|  |             } | ||
|  |             SendPackEx(T); | ||
|  |         }.bindenv(this); | ||
|  |         MatchButton.SetCallBackFunc(function(Button) { | ||
|  |             if (Stage == 0) { | ||
|  |                 if (MatchState == 0) Button.Visible = true; | ||
|  |                 else Button.Visible = false; | ||
|  |             } else Button.Visible = false; | ||
|  |         }.bindenv(this)); | ||
|  |         Childrens.append(MatchButton); | ||
|  | 
 | ||
|  |         //取消匹配按钮 | ||
|  |         local CancelMatchButton = LenheartNewUI_BaseButton(getroottable().Rindro_Scr_Width == 800 ? 355 : 488, 400, 87, 34, "xjp.img", 19); | ||
|  |         CancelMatchButton.OnClickEx = function(Button) { | ||
|  |             if (!Button.Visible) return; | ||
|  |             //发送开始匹配包 | ||
|  |             local T = { | ||
|  |                 op = 20092003, | ||
|  |             } | ||
|  |             SendPackEx(T); | ||
|  |         }.bindenv(this); | ||
|  |         CancelMatchButton.SetCallBackFunc(function(Button) { | ||
|  |             if (Stage == 0) { | ||
|  |                 if (MatchState == 1) Button.Visible = true; | ||
|  |                 else Button.Visible = false; | ||
|  |             } else Button.Visible = false; | ||
|  |         }.bindenv(this)); | ||
|  |         Childrens.append(CancelMatchButton); | ||
|  |     } | ||
|  | 
 | ||
|  |     //绘制主界面 | ||
|  |     function DrawMain(obj) { | ||
|  |         if (Width == 800) { | ||
|  |             Img.DrawPng(0, X, Y); | ||
|  |         } else { | ||
|  |             Img.DrawPng(1, X, Y); | ||
|  |         } | ||
|  | 
 | ||
|  | 
 | ||
|  |         //匹配阶段 | ||
|  |         if (Stage == 0) { | ||
|  |             //绘制标题 | ||
|  |             Img.DrawPng(11, X + XOffset + 124, Y + 60); | ||
|  |             //绘制个人信息框 | ||
|  |             Img.DrawPng(12, X + XOffset + 400 - 135, Y + 200); | ||
|  |             L_sq_DrawCode("胜利场次: " + WinCount + "次", X + XOffset + 400 - 135 + 12, Y + 200 + 20, sq_RGBA(230, 200, 155, 250), 1, 1); | ||
|  |             L_sq_DrawCode("服务器排名: 第" + (IsServer ? OnlineRanking : Ranking) + "名", X + XOffset + 400 - 135 + 12, Y + 200 + 40, sq_RGBA(230, 200, 155, 250), 1, 1); | ||
|  |             if (!IsServer) L_sq_DrawCode("剩余入场券数量: " + Ranking + "张", X + XOffset + 400 - 135 + 12, Y + 200 + 60, sq_RGBA(230, 200, 155, 250), 1, 1); | ||
|  | 
 | ||
|  |             if (MatchState == 0) { | ||
|  | 
 | ||
|  |             } else if (MatchState == 1) { | ||
|  |                 //绘制匹配动画 | ||
|  |                 L_sq_SetDrawImgModel(2, 0); | ||
|  |                 MatchAni2.Show(Duration); | ||
|  |                 L_sq_ReleaseDrawImgModel(); | ||
|  |                 L_sq_DrawCode("匹配中", X + XOffset + 400 - 135 + 116, Y + 200 + 40 + 105, sq_RGBA(230, 200, 155, 250), 1, 1); | ||
|  |             } | ||
|  |         } | ||
|  |         //游戏阶段 | ||
|  |         else if (Stage == 1) { | ||
|  |             //挑选万能牌 | ||
|  |             if (GameState == -1) { | ||
|  |                 local Rate = sq_GetUniformVelocity(0, 100, Clock() - RandCardTimer, 300); | ||
|  |                 if (RandCardState< 3) { | ||
|  |                     if (RandCardState == 0) { | ||
|  |                         if ((Clock() - RandCardTimer >= 300)) { | ||
|  |                             RandCardTimer = Clock(); | ||
|  |                             RandCardState++; | ||
|  |                             return; | ||
|  |                         } | ||
|  |                     } | ||
|  |                     if (RandCardState == 1) { | ||
|  |                         if ((Clock() - RandCardTimer >= 1000)) { | ||
|  |                             RandCardTimer = Clock(); | ||
|  |                             RandCardState++; | ||
|  |                             return; | ||
|  |                         } | ||
|  |                     } | ||
|  |                     if (RandCardState == 2) { | ||
|  |                         if ((Clock() - RandCardTimer >= 1000)) { | ||
|  |                             RandCardTimer = Clock(); | ||
|  |                             RandCardState++; | ||
|  |                             return; | ||
|  |                         } | ||
|  |                     } | ||
|  |                 } | ||
|  |                 if (RandCardState == 3) { | ||
|  |                     GameState = 0; | ||
|  |                     return; | ||
|  |                 } | ||
|  |                 if (RandCardState == 0) { | ||
|  |                     Rate = abs(100 - Rate).tofloat() / 100.0; | ||
|  |                 } else { | ||
|  |                     Rate = Rate.tofloat() / 100.0; | ||
|  |                 } | ||
|  | 
 | ||
|  |                 if (RandCardState == 0) | ||
|  |                     CardImg.DrawExPng(0, ((XOffset + 400) - 41), 240, 0, 0xffffffff, Rate, 1.0); | ||
|  |                 if (RandCardState == 1) | ||
|  |                     CardImg.DrawExPng(MainCardId, ((XOffset + 400) - 41), 240, 0, 0xffffffff, Rate, 1.0); | ||
|  |                 if (RandCardState == 2) { | ||
|  |                     local XBuf = sq_GetUniformVelocity(((XOffset + 400) - 41), 10, Clock() - RandCardTimer, 200); | ||
|  |                     local YBuf = sq_GetUniformVelocity(240, 30, Clock() - RandCardTimer, 200); | ||
|  |                     CardImg.DrawPng(MainCardId, XBuf, YBuf); | ||
|  |                 } | ||
|  |             } | ||
|  |             if (GameState >= 0) { | ||
|  |                 //大于0了就永远绘制主牌 | ||
|  |                 CardImg.DrawPng(MainCardId, 10, 30); | ||
|  |                 //计算时间因子 | ||
|  |                 if (Clock() - DealCardTimer >= 200) { | ||
|  |                     DealCardTimer = Clock(); | ||
|  |                     DealCardState++; | ||
|  | 
 | ||
|  |                     if (DealCardState > 3 && GameState == 0) { | ||
|  |                         GameState = 1; | ||
|  |                         FlipCardTimer = Clock(); | ||
|  |                     } | ||
|  |                 } | ||
|  |                 //绘制发牌动画 | ||
|  |                 for (local i = 0; i< 20; i++) { | ||
|  |                     if (i< 5) { | ||
|  |                         //自己的牌只在发牌阶段绘制 | ||
|  |                         if (GameState == 0) { | ||
|  |                             if (DealCardState == 0) { | ||
|  |                                 local XBuf = sq_GetUniformVelocity((X + XOffset + 400 - 40 - i), ((XOffset + 400) - 205) + (82 * i), Clock() - DealCardTimer, 200); | ||
|  |                                 local YBuf = sq_GetUniformVelocity(Y + 240 - i, 426, Clock() - DealCardTimer, 200); | ||
|  |                                 CardImg.DrawPng(0, XBuf, YBuf); | ||
|  |                             } else { | ||
|  |                                 CardImg.DrawPng(0, ((XOffset + 400) - 205) + (82 * i), 426); | ||
|  |                             } | ||
|  |                         } | ||
|  |                         continue; | ||
|  |                     } else if (i< 10 && DealCardState >= 1) { | ||
|  |                         if (i - 5< PlayerList[i / 5].Card.len()) { | ||
|  |                             if (DealCardState == 1) { | ||
|  |                                 local XBuf = sq_GetUniformVelocity((X + XOffset + 400 - 40 - i), ((XOffset + 80)), Clock() - DealCardTimer, 200); | ||
|  |                                 local YBuf = sq_GetUniformVelocity(Y + 240 - i, 190 + ((i - 5) * 15), Clock() - DealCardTimer, 200); | ||
|  |                                 CardImg.DrawPng(0, XBuf, YBuf); | ||
|  |                             } else { | ||
|  |                                 CardImg.DrawPng(0, ((XOffset + 80)), 190 + ((i - 5) * 15)); | ||
|  |                             } | ||
|  |                         } | ||
|  |                         continue; | ||
|  |                     } else if (i< 15 && DealCardState >= 2) { | ||
|  |                         if (i - 10< PlayerList[i / 5].Card.len()) { | ||
|  |                             if (DealCardState == 2) { | ||
|  |                                 local XBuf = sq_GetUniformVelocity((X + XOffset + 400 - 40 - i), ((XOffset + 400) - 86) + (15 * (i - 10)), Clock() - DealCardTimer, 200); | ||
|  |                                 local YBuf = sq_GetUniformVelocity(Y + 240 - i, 54, Clock() - DealCardTimer, 200); | ||
|  |                                 CardImg.DrawPng(0, XBuf, YBuf); | ||
|  |                             } else { | ||
|  |                                 CardImg.DrawPng(0, ((XOffset + 400) - 86) + (15 * (i - 10)), 54); | ||
|  |                             } | ||
|  |                         } | ||
|  |                         continue; | ||
|  |                     } else if (i< 20 && DealCardState >= 3) { | ||
|  |                         if (i - 15< PlayerList[i / 5].Card.len()) { | ||
|  |                             if (DealCardState == 3) { | ||
|  |                                 local XBuf = sq_GetUniformVelocity((X + XOffset + 400 - 40 - i), ((XOffset + 620)), Clock() - DealCardTimer, 200); | ||
|  |                                 local YBuf = sq_GetUniformVelocity(Y + 240 - i, 190 + ((i - 15) * 15), Clock() - DealCardTimer, 200); | ||
|  |                                 CardImg.DrawPng(0, XBuf, YBuf); | ||
|  |                             } else { | ||
|  |                                 CardImg.DrawPng(0, ((XOffset + 620)), 190 + ((i - 15) * 15)); | ||
|  |                             } | ||
|  |                         } | ||
|  |                         continue; | ||
|  |                     } | ||
|  |                     CardImg.DrawPng(0, X + XOffset + 400 - 40 - i, Y + 240 - i); | ||
|  |                 } | ||
|  |             } | ||
|  | 
 | ||
|  |             //绘制翻牌动画 | ||
|  |             if (GameState == 1) { | ||
|  |                 local Rate = sq_GetUniformVelocity(0, 100, Clock() - FlipCardTimer, 300); | ||
|  |                 if (FlipCardState< 2) { | ||
|  |                     if (FlipCardState == 0) { | ||
|  |                         if ((Clock() - FlipCardTimer >= 300)) { | ||
|  |                             FlipCardTimer = Clock(); | ||
|  |                             FlipCardState++; | ||
|  |                             return; | ||
|  |                         } | ||
|  |                     } | ||
|  |                     if (FlipCardState == 1) { | ||
|  |                         if ((Clock() - FlipCardTimer >= 1000)) { | ||
|  |                             FlipCardTimer = Clock(); | ||
|  |                             FlipCardState++; | ||
|  |                             return; | ||
|  |                         } | ||
|  |                     } | ||
|  |                 } | ||
|  |                 if (FlipCardState == 2) { | ||
|  |                     GameState = 2; | ||
|  |                     return; | ||
|  |                 } | ||
|  |                 if (FlipCardState == 0) { | ||
|  |                     Rate = abs(100 - Rate).tofloat() / 100.0; | ||
|  |                 } else { | ||
|  |                     Rate = Rate.tofloat() / 100.0; | ||
|  |                     if (Rate > 0.95) { | ||
|  |                         for (local i = 0; i< 5; i++) { | ||
|  |                             CardList[i].Visible = true; | ||
|  |                         } | ||
|  |                     } | ||
|  |                 } | ||
|  | 
 | ||
|  |                 for (local i = 0; i< 5; i++) { | ||
|  |                     if (FlipCardState == 0) | ||
|  |                         CardImg.DrawExPng(0, ((XOffset + 400) - 205) + (82 * i), 426, 0, 0xffffffff, Rate, 1.0); | ||
|  |                     if (FlipCardState == 1) | ||
|  |                         CardImg.DrawExPng(CardList[i].Id, ((XOffset + 400) - 205) + (82 * i), 426, 0, 0xffffffff, Rate, 1.0); | ||
|  |                 } | ||
|  |             } | ||
|  | 
 | ||
|  | 
 | ||
|  |             //绘制玩家 | ||
|  |             foreach(Index, PlayerObj in PlayerList) { | ||
|  |                 PlayerObj.Draw(X + (XOffset + PlayerPos[Index][0]), Y + PlayerPos[Index][1]); | ||
|  |             } | ||
|  | 
 | ||
|  |             //绘制文字当前主牌 | ||
|  |             Img.DrawPng(4, X + 10, Y + 10); | ||
|  | 
 | ||
|  | 
 | ||
|  |             //绘制出牌动画 | ||
|  |             if (PlayCardAniFlag == 0) { | ||
|  |                 local XBuf = sq_GetUniformVelocity((X + XOffset + 400 - 40), (X + XOffset + 300 - 40), Clock() - PlayCardAniTimer, 200); | ||
|  |                 local YBuf = sq_GetUniformVelocity(Y + 400, 220, Clock() - PlayCardAniTimer, 200); | ||
|  |                 for (local i = 0; i< PlayCardAniCount; i++) { | ||
|  |                     CardImg.DrawPng(0, XBuf + (12 * i), YBuf); | ||
|  |                 } | ||
|  |             } else if (PlayCardAniFlag == 1) { | ||
|  |                 local XBuf = sq_GetUniformVelocity((X + XOffset + 80), (X + XOffset + 300 - 40), Clock() - PlayCardAniTimer, 200); | ||
|  |                 local YBuf = sq_GetUniformVelocity(Y + 200, 220, Clock() - PlayCardAniTimer, 200); | ||
|  |                 for (local i = 0; i< PlayCardAniCount; i++) { | ||
|  |                     CardImg.DrawPng(0, XBuf + (12 * i), YBuf); | ||
|  |                 } | ||
|  |             } else if (PlayCardAniFlag == 2) { | ||
|  |                 local XBuf = sq_GetUniformVelocity((X + XOffset + 400 - 40), (X + XOffset + 300 - 40), Clock() - PlayCardAniTimer, 200); | ||
|  |                 local YBuf = sq_GetUniformVelocity(Y + 54, 220, Clock() - PlayCardAniTimer, 200); | ||
|  |                 for (local i = 0; i< PlayCardAniCount; i++) { | ||
|  |                     CardImg.DrawPng(0, XBuf + (12 * i), YBuf); | ||
|  |                 } | ||
|  |             } else if (PlayCardAniFlag == 3) { | ||
|  |                 local XBuf = sq_GetUniformVelocity((X + XOffset + 620), (X + XOffset + 300 - 40), Clock() - PlayCardAniTimer, 200); | ||
|  |                 local YBuf = sq_GetUniformVelocity(Y + 200, 220, Clock() - PlayCardAniTimer, 200); | ||
|  |                 for (local i = 0; i< PlayCardAniCount; i++) { | ||
|  |                     CardImg.DrawPng(0, XBuf + (12 * i), YBuf); | ||
|  |                 } | ||
|  |             } | ||
|  | 
 | ||
|  |             { | ||
|  |                 //绘制质疑开牌动画 | ||
|  |                 if (QuestionAniFlag == 1) { | ||
|  |                     local XBufRate = sq_GetUniformVelocity(12, 82, Clock() - QuestionAniTimer, 300); | ||
|  |                     if (XBufRate >= 82) { | ||
|  |                         QuestionAniFlag++; | ||
|  |                         QuestionAniTimer = Clock(); | ||
|  |                     } | ||
|  |                     for (local i = 0; i< QuestionList.len(); i++) { | ||
|  |                         CardImg.DrawPng(0, X + XOffset + 300 - 40 + (XBufRate * i), 220); | ||
|  |                     } | ||
|  |                 } | ||
|  |                 if (QuestionAniFlag >= 2) { | ||
|  |                     local Rate = sq_GetUniformVelocity(0, 100, Clock() - QuestionAniTimer, 200); | ||
|  |                     if (QuestionAniFlag< 5) { | ||
|  |                         if (QuestionAniFlag == 2) { | ||
|  |                             if ((Clock() - QuestionAniTimer >= 300)) { | ||
|  |                                 QuestionAniTimer = Clock(); | ||
|  |                                 QuestionAniFlag++; | ||
|  |                                 return; | ||
|  |                             } | ||
|  |                         } | ||
|  |                         if (QuestionAniFlag == 3) { | ||
|  |                             if ((Clock() - QuestionAniTimer >= 1200)) { | ||
|  |                                 QuestionAniTimer = Clock(); | ||
|  |                                 QuestionAniFlag++; | ||
|  |                                 return; | ||
|  |                             } | ||
|  |                         } | ||
|  |                         if (QuestionAniFlag == 4) { | ||
|  |                             if ((Clock() - QuestionAniTimer >= 1000)) { | ||
|  |                                 QuestionAniTimer = Clock(); | ||
|  |                                 QuestionAniFlag++; | ||
|  |                                 return; | ||
|  |                             } | ||
|  |                         } | ||
|  |                     } | ||
|  |                     if (QuestionAniFlag == 5) { | ||
|  |                         return; | ||
|  |                     } | ||
|  |                     if (QuestionAniFlag == 2) { | ||
|  |                         Rate = abs(100 - Rate).tofloat() / 100.0; | ||
|  |                     } else if (QuestionAniFlag == 3) { | ||
|  |                         Rate = Rate.tofloat() / 100.0; | ||
|  |                     } | ||
|  | 
 | ||
|  |                     for (local i = 0; i< QuestionList.len(); i++) { | ||
|  |                         if (QuestionAniFlag == 2) | ||
|  |                             CardImg.DrawExPng(0, X + XOffset + 300 - 40 + (82 * i), 220, 0, 0xffffffff, Rate, 1.0); | ||
|  |                         if (QuestionAniFlag == 3) | ||
|  |                             CardImg.DrawExPng(QuestionList[i] + 1, X + XOffset + 300 - 40 + (82 * i), 220, 0, 0xffffffff, Rate, 1.0); | ||
|  |                     } | ||
|  |                 } | ||
|  |             } | ||
|  | 
 | ||
|  |             //绘制当前是谁的回合 | ||
|  |             if (RoundCharac == 0) { | ||
|  |                 // Img.DrawPng(5, X + 10, Y + 10); | ||
|  |             } | ||
|  |         } | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  |     function Show(obj) { | ||
|  |         DrawMain(obj); | ||
|  |         LenheartNewUI_Windows.Show(obj); | ||
|  | 
 | ||
|  |         //绘制点击效果 | ||
|  |         L_sq_SetDrawImgModel(2, 0); | ||
|  |         foreach(Ani in ClickEffAni) { | ||
|  |             Ani.ShowEx(Duration, sq_RGBA(255, 255, 255, 250), 0.8, 0.8); | ||
|  |         } | ||
|  |         L_sq_ReleaseDrawImgModel(); | ||
|  |     } | ||
|  | 
 | ||
|  |     function SyncCardPos() { | ||
|  |         //匹配阶段 | ||
|  |         if (Stage == 0) { | ||
|  |             foreach(Card in CardList) { | ||
|  |                 Card.Visible = false; | ||
|  |             } | ||
|  |         } | ||
|  |         //游戏阶段 | ||
|  |         else if (Stage == 1) { | ||
|  |             //State 0 发牌阶段 1 出牌阶段 | ||
|  |             if (GameState == 2) { | ||
|  |                 SynchronizeYourCardPosition(); | ||
|  |             } else if (GameState <= 0) { | ||
|  |                 foreach(Card in CardList) { | ||
|  |                     Card.Visible = false; | ||
|  |                 } | ||
|  |             } | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     function SynchronizeYourCardPosition() { | ||
|  |         //计算数量 | ||
|  |         local DisplayCount = 0; | ||
|  |         foreach(Card in CardList) { | ||
|  |             if (Card.Visible) DisplayCount++; | ||
|  |         } | ||
|  |         //计算卡牌总宽度 | ||
|  |         local TotalWidth = DisplayCount * 82; | ||
|  |         //计算偏移量 居中 卡牌宽度为82 | ||
|  |         local DrawIndex = 0; | ||
|  |         foreach(Card in CardList) { | ||
|  |             if (!Card.Visible) continue; | ||
|  |             Card.Localtion_X = (XOffset + 400) - (TotalWidth / 2) + (DrawIndex * 82); | ||
|  |             DrawIndex++; | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     //逻辑入口 | ||
|  |     function Proc(obj) { | ||
|  |         SyncCardPos(); | ||
|  |         LenheartNewUI_Windows.SyncPos(X, Y); | ||
|  |     } | ||
|  | 
 | ||
|  |     //注册收包 | ||
|  |     function RegisterPacket() { | ||
|  |         //开始匹配回调 | ||
|  |         Pack_Control.rawset(20092002, function(Chunk) { | ||
|  |             local Jso = Json.Decode(Chunk); | ||
|  |             MatchState = 1; | ||
|  |         }.bindenv(this)); | ||
|  |         //取消匹配回调 | ||
|  |         Pack_Control.rawset(20092004, function(Chunk) { | ||
|  |             local Jso = Json.Decode(Chunk); | ||
|  |             MatchState = 0; | ||
|  |         }.bindenv(this)); | ||
|  |         //对局开始回调 | ||
|  |         Pack_Control.rawset(20092006, function(Chunk) { | ||
|  |             local Jso = Json.Decode(Chunk); | ||
|  |             MatchState = 0; | ||
|  |             Stage = 1; | ||
|  |             GameState = -1; | ||
|  |             DealCardTimer = Clock(); | ||
|  |             RandCardTimer = Clock(); | ||
|  |             //设置主牌 | ||
|  |             MainCardId = Jso.MainCard; | ||
|  |             //设置玩家 | ||
|  |             foreach(Index, PlayerObj in Jso.CharacList) { | ||
|  |                 PlayerList[Index].SetPlayer(PlayerObj.Job, PlayerObj.Equ, PlayerObj.Name); | ||
|  |                 PlayerList[Index].SetCard(PlayerObj.CardList); | ||
|  |             } | ||
|  |             //设置自己的牌 | ||
|  |             foreach(Index, CardId in Jso.CharacList[0].CardList) { | ||
|  |                 CardList[Index].SetCardId(CardId); | ||
|  |             } | ||
|  |         }.bindenv(this)); | ||
|  |         //出牌成功回调 | ||
|  |         Pack_Control.rawset(20092008, function(Chunk) { | ||
|  |             local Jso = Json.Decode(Chunk); | ||
|  |             local SendCardList = Jso.CardList; | ||
|  | 
 | ||
|  |             //如果是自己出牌 | ||
|  |             if (Jso.CharacId == 0) { | ||
|  |                 //设定卡牌不可见 | ||
|  |                 foreach(Index in SendCardList) { | ||
|  |                     CardList[Index].Visible = false; | ||
|  |                 } | ||
|  |                 //设置出牌动画Flag | ||
|  |                 PlayCardAniFlag = 0; | ||
|  |             } | ||
|  |             //如果是其他玩家出牌 | ||
|  |             else { | ||
|  |                 PlayerList[Jso.CharacId].Card = array(PlayerList[Jso.CharacId].Card.len() - SendCardList.len()); | ||
|  |                 //设置出牌动画Flag | ||
|  |                 PlayCardAniFlag = Jso.CharacId; | ||
|  |                 //设置出牌张数 | ||
|  |                 PlayCardAniCount = SendCardList.len(); | ||
|  |             } | ||
|  | 
 | ||
|  |         }.bindenv(this)); | ||
|  |         //刷新回合信息回调 | ||
|  |         Pack_Control.rawset(20092010, function(Chunk) { | ||
|  |             local Jso = Json.Decode(Chunk); | ||
|  |             //回合玩家 | ||
|  |             RoundCharac = Jso.RoundCharac; | ||
|  |             //回合剩余时间 | ||
|  |             RoundTime = Jso.RoundTime; | ||
|  |         }.bindenv(this)); | ||
|  | 
 | ||
|  |         //战绩包回调 | ||
|  |         Pack_Control.rawset(20092098, function(Chunk) { | ||
|  |             local Jso = Json.Decode(Chunk); | ||
|  |             this.WinCount = Jso.WinCount; | ||
|  |             this.Ranking = Jso.Ranking; | ||
|  |             this.OnlineRanking = Jso.OnlineRanking; | ||
|  |             this.TicketCount = Jso.TicketCount; | ||
|  |         }.bindenv(this)); | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     ClickFlag = null; | ||
|  |     //鼠标左键按下回调 | ||
|  |     function OnMouseLbDown(MousePos_X, MousePos_Y) { | ||
|  |         LenheartNewUI_Windows.OnMouseLbDown(MousePos_X, MousePos_Y); | ||
|  |         ClickFlag = { | ||
|  |             x = MousePos_X, | ||
|  |             y = MousePos_Y | ||
|  |         }; | ||
|  | 
 | ||
|  |         local ClickEffAniBuffer = Lenheart_Ani("", ClickEffFrameArr, [MousePos_X - (70 * 0.8), MousePos_Y - (75 * 0.8)]); | ||
|  |         ClickEffAniBuffer.ImgPath = "xjpclick2.img"; | ||
|  |         ClickEffAniBuffer.LoopFlag = false; | ||
|  |         ClickEffAni.append(ClickEffAniBuffer); | ||
|  |     } | ||
|  | 
 | ||
|  |     function OpenCallBack() { | ||
|  |         Visible = true; | ||
|  |         //查询战绩 | ||
|  |         local T = { | ||
|  |             op = 20092097, | ||
|  |         }; | ||
|  |         SendPackEx(T); | ||
|  |     } | ||
|  | } | ||
|  | getroottable().rawdelete("Scheming_Obj"); | ||
|  | 
 | ||
|  | function Lenheart_Scheming_Fun(obj) { | ||
|  |     local RootTab = getroottable(); | ||
|  |     if (!RootTab.rawin("Scheming_Obj")) { | ||
|  |         RootTab.rawset("Scheming_Obj", true); | ||
|  |         local width = getroottable().Rindro_Scr_Width; | ||
|  |         local Win = LenheartNewUI_CreateWindow(SchemingC, "心机牌窗口", 0, 0, width, 600, 0); | ||
|  |         EventList_Obj.AddEvent("心机牌大作战", 364, Win); | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | getroottable()["LenheartFuncTab"].rawset("SchemingFuncN", Lenheart_Scheming_Fun); |