예제 #1
0
 /// <summary>
 /// 设置交换牌动作数据
 /// </summary>
 /// <param name="fromPos"></param>
 /// <param name="toSeatIdx"></param>
 /// <param name="mjHandPaiFaceValues"></param>
 /// <param name="fromSeatHandPaiIdx"></param>
 /// <param name="mjMoPaiFaceValues"></param>
 /// <param name="fromSeatMoPaiIdx"></param>
 /// <param name="toSeatHandPaiIdx"></param>
 /// <param name="swapDir"></param>
 /// <param name="isShowBack"></param>
 /// <param name="opCmdNode"></param>
 public void SetSwapPaiData(
     Vector3 fromPos,
     int toSeatIdx,
     MahjongFaceValue[] mjHandPaiFaceValues,
     int[] fromSeatHandPaiIdx,
     MahjongFaceValue[] mjMoPaiFaceValues,
     int[] fromSeatMoPaiIdx,
     int[] toSeatHandPaiIdx,
     SwapPaiDirection swapDir,
     bool isShowBack,
     LinkedListNode <MahjongMachineCmd> opCmdNode = null)
 {
     this.swapPaiToSeatIdx         = toSeatIdx;
     this.swapPaiFromPos           = fromPos;
     this.swapPaiFaceValues        = mjHandPaiFaceValues;
     this.swapPaiFromSeatPaiIdxs   = fromSeatHandPaiIdx;
     this.swapPaiMoPaiFaceValues   = mjMoPaiFaceValues;
     this.swapPaiFromSeatMoPaiIdxs = fromSeatMoPaiIdx;
     this.swapPaiToSeatPaiIdxs     = toSeatHandPaiIdx;
     this.swapPaiIsShowBack        = isShowBack;
     swapPaiDir     = swapDir;
     this.opCmdNode = opCmdNode;
 }
예제 #2
0
 public void SetData(SwapPaiDirection swapPaiDirection)
 {
     this.swapPaiDirection = swapPaiDirection;
 }
예제 #3
0
        /// <summary>
        /// 交换牌
        /// </summary>
        /// <param name="fromSeatIdx"></param>
        /// <param name="toSeatIdx"></param>
        /// <param name="swapMjCount"></param>
        /// <param name="mjFaceValues"></param>
        /// <param name="fromSeatHandPaiIdx"></param>
        /// <param name="toSeatHandPaiIdx"></param>
        /// <param name="isShowBack"></param>
        /// <param name="opCmdNode"></param>
        public void SwapPai(
            int fromSeatIdx,
            int toSeatIdx,
            int swapMjCount,
            int[] toSeatHandPaiIdx,
            MahjongFaceValue[] mjHandPaiFaceValues,
            int[] fromSeatHandPaiIdx,
            MahjongFaceValue[] mjMoPaiFaceValues = null,
            int[] fromSeatMoPaiIdx   = null,
            bool isShowBack          = true,
            SwapPaiDirection swapDir = SwapPaiDirection.CLOCKWISE,
            LinkedListNode <MahjongMachineCmd> opCmdNode = null)
        {
            StopSelectPaiActionState(fromSeatIdx);

            if (playerStateData[fromSeatIdx].playerHandActionState != HandActionState.ACTION_END ||
                mjSeatHandPaiLists[toSeatIdx].Count == 0 || mjSeatHandPaiLists[toSeatIdx][0] == null)
            {
                RemoveHandActionOpCmd(fromSeatIdx, opCmdNode);
                return;
            }


            if (mjHandPaiFaceValues == null)
            {
                mjHandPaiFaceValues = new MahjongFaceValue[swapMjCount];
                for (int i = 0; i < swapMjCount; i++)
                {
                    mjHandPaiFaceValues[i] = MahjongFaceValue.MJ_ZFB_FACAI;
                }
            }

            if (fromSeatHandPaiIdx == null)
            {
                fromSeatHandPaiIdx = Common.GetRandom(swapMjCount, 0, mjSeatHandPaiLists[fromSeatIdx].Count);
                Array.Sort(fromSeatHandPaiIdx);
            }

#if (DEBUG)
            string s = "seat" + fromSeatIdx + "交换牌到" + "seat" + toSeatIdx + ",发起交换seat的手牌idx:";
            string w = "";
            for (int i = 0; i < fromSeatHandPaiIdx.Length; i++)
            {
                w += fromSeatHandPaiIdx[i] + ",";
            }
            Debug.Log(s + w);
#endif


#if (DEBUG)
            if (fromSeatMoPaiIdx != null)
            {
                s = "seat" + fromSeatIdx + "交换牌到" + "seat" + toSeatIdx + ",发起交换seat的摸牌idx:";
                w = "";
                for (int i = 0; i < fromSeatMoPaiIdx.Length; i++)
                {
                    w += fromSeatMoPaiIdx[i] + ",";
                }
                Debug.Log(s + w);
            }
#endif

            if (toSeatHandPaiIdx == null)
            {
                int handPaiLen = mjSeatHandPaiLists[toSeatIdx].Count - mjHandPaiFaceValues.Length;

                if (mjMoPaiFaceValues != null)
                {
                    handPaiLen -= mjMoPaiFaceValues.Length;
                }

                toSeatHandPaiIdx = Common.GetRandom(swapMjCount, 0, handPaiLen);
                Array.Sort(toSeatHandPaiIdx);
            }

#if (DEBUG)
            s = "seat" + fromSeatIdx + "交换牌到" + "seat" + toSeatIdx + ",接受交换seat的手牌目标idx:";
            w = "";
            for (int i = 0; i < toSeatHandPaiIdx.Length; i++)
            {
                w += toSeatHandPaiIdx[i] + ",";
            }
            Debug.Log(s + w);
#endif

            float   h      = GetDeskMjSizeByAxis(Axis.Z);
            Vector3 orgPos = new Vector3(swapPaiCenterPosSeat[fromSeatIdx].x, deskFacePosY + h / 2, swapPaiCenterPosSeat[fromSeatIdx].z);

            playerStateData[fromSeatIdx].SetSwapPaiData(
                orgPos, toSeatIdx, mjHandPaiFaceValues,
                fromSeatHandPaiIdx, mjMoPaiFaceValues, fromSeatMoPaiIdx, toSeatHandPaiIdx,
                swapDir,
                isShowBack, opCmdNode);

            playerStateData[fromSeatIdx].SetPlayerState(HandActionState.SWAP_PAI_START, Time.time, -1);
        }