/// <summary> /// 设置插牌动作数据 /// </summary> /// <param name="handStyle"></param> /// <param name="orgPaiIdx"></param> /// <param name="dstHandPaiIdx"></param> /// <param name="orgPaiType"></param> /// <param name="adjustDirection"></param> /// <param name="opCmdNode"></param> public void SetChaPaiData( PlayerType handStyle, int orgPaiIdx, int dstHandPaiIdx, HandPaiType orgPaiType, HandPaiAdjustDirection adjustDirection, LinkedListNode <MahjongMachineCmd> opCmdNode = null) { this.handStyle = handStyle; this.orgPaiIdx = orgPaiIdx; this.chaPaiDstHandPaiIdx = dstHandPaiIdx; this.chaPaiHandPaiType = orgPaiType; this.adjustDirection = adjustDirection; this.opCmdNode = opCmdNode; }
/// <summary> /// 选择打牌结束回调 /// </summary> /// <param name="selectPaiHandPaiIdx"></param> /// <param name="paiType"></param> void SelectDaPaiEnd(int selectPaiHandPaiIdx, HandPaiType paiType) { MahjongDaPaiOpCmd cmd = (MahjongDaPaiOpCmd)CmdPool.Instance.CreateCmd(MahjongOpCode.DaPai); cmd.seatIdx = 0; cmd.handStyle = PlayerType.FEMALE; cmd.paiIdx = selectPaiHandPaiIdx; cmd.paiType = paiType; cmd.mjFaceValue = GetHandPaiMjFaceValue(0, selectPaiHandPaiIdx); mjOpCmdList.Append(cmd); MahjongPaiOpCmd cmd2 = (MahjongPaiOpCmd)CmdPool.Instance.CreateCmd(MahjongOpCode.SortPai); cmd2.seatIdx = 0; cmd2.handStyle = PlayerType.FEMALE; cmd2.canSelectPaiAfterCmdEnd = true; mjOpCmdList.Append(cmd2); //test ReqSelectDaPaiOpCmd cmdx = (ReqSelectDaPaiOpCmd)CmdPool.Instance.CreateCmd(MahjongOpCode.ReqSelectDaPai); mjOpCmdList.Append(cmdx); }
/// <summary> /// 插牌 /// </summary> /// <param name="seatIdx">对应的玩家座号</param> /// <param name="orgPaiIdx">原始需要插牌的麻将号</param> /// <param name="dstHandPaiIdx">目标位置号</param> /// <param name="orgPaiType">需要插牌的麻将类型</param> /// <param name="adjustDirection">插排后手牌列表移动的方向</param> public void ChaPai(int seatIdx, PlayerType handStyle, int orgPaiIdx, int dstHandPaiIdx, HandPaiType orgPaiType, HandPaiAdjustDirection adjustDirection, LinkedListNode <MahjongMachineCmd> opCmdNode = null) { StopSelectPaiActionState(seatIdx); if (playerStateData[seatIdx].playerHandActionState != HandActionState.ACTION_END || mjSeatHandPaiLists[seatIdx].Count == 0 || mjSeatHandPaiLists[seatIdx][0] == null) { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } if (orgPaiType == HandPaiType.HandPai) { if (orgPaiIdx >= mjSeatHandPaiLists[seatIdx].Count) { RemoveHandActionOpCmd(seatIdx, opCmdNode); { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } } } else { if (orgPaiIdx >= mjSeatMoPaiLists[seatIdx].Count) { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } } if (dstHandPaiIdx >= mjSeatHandPaiLists[seatIdx].Count) { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } playerStateData[seatIdx].SetChaPaiData(handStyle, orgPaiIdx, dstHandPaiIdx, orgPaiType, adjustDirection, opCmdNode); playerStateData[seatIdx].SetPlayerState(HandActionState.CHA_PAI_START, Time.time, -1); }
/// <summary> /// 打牌 /// </summary> /// <param name="seatIdx">出牌玩家座号</param> /// <param name="paiIdx">牌号</param> /// <param name="paiType">牌类型(已有手牌还是摸过来的牌)</param> /// <param name="mjFaceValue">牌面值</param> /// <param name="handActionNum">手部动作编号</param> public void DaPai(int seatIdx, PlayerType handStyle, int paiIdx, HandPaiType paiType, MahjongFaceValue mjFaceValue, bool isJiaoTing, ActionCombineNum handActionNum, LinkedListNode <MahjongMachineCmd> opCmdNode = null) { StopSelectPaiActionState(seatIdx); if (playerStateData[seatIdx].playerHandActionState != HandActionState.ACTION_END || mjSeatHandPaiLists[seatIdx].Count == 0 || mjSeatHandPaiLists[seatIdx][0] == null) { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } if (paiIdx >= 0 && ((paiIdx < mjSeatHandPaiLists[seatIdx].Count && paiType == HandPaiType.HandPai) || (paiIdx < mjSeatMoPaiLists[seatIdx].Count && paiType == HandPaiType.MoPai))) { if (paiType == HandPaiType.HandPai) { if (paiIdx >= mjSeatHandPaiLists[seatIdx].Count) { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } GameObject mj = mjSeatHandPaiLists[seatIdx][paiIdx]; if (mj == null) { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } mjSeatHandPaiLists[seatIdx].RemoveAt(paiIdx); if (seatIdx != 0) { mjAssetsMgr.PushMjToOtherHandMjPool(mj); } else { mjAssetsMgr.PushMjToDeskOrSelfHandMjPool(mj); } } else { if (paiIdx >= mjSeatMoPaiLists[seatIdx].Count) { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } GameObject mj = mjSeatMoPaiLists[seatIdx][paiIdx]; if (mj == null) { RemoveHandActionOpCmd(seatIdx, opCmdNode); return; } mjSeatMoPaiLists[seatIdx].RemoveAt(paiIdx); if (seatIdx != 0) { mjAssetsMgr.PushMjToOtherHandMjPool(mj); } else { mjAssetsMgr.PushMjToDeskOrSelfHandMjPool(mj); } } } NextDeskMjPos(seatIdx); Vector3Int mjposIdx = GetCurtDeskMjPosIdx(seatIdx); playerStateData[seatIdx].SetDaPaiData(handStyle, mjposIdx, mjFaceValue, isJiaoTing, handActionNum, opCmdNode); playerStateData[seatIdx].SetPlayerState(HandActionState.DA_PAI_START, Time.time, -1); }