コード例 #1
0
    //吃 碰 明杠  arg[0] 第一个手牌id  arg[0][1] 第二个 arg[0][2] 第三 arg[0][3] 四   arg[1] 牌型
    IEnumerator UserChiCard(int userID, int supID, UserAction action, params List <int>[] arg)
    {
        //获取吃牌的第一个手牌
        MahjongPrefab card1;
        //第二个时手牌已减1 对应索引减1 第三个要减2
        MahjongPrefab card2;

        //吃掉出牌玩家刚出的牌
        MahjongPrefab card = userPriority[supID].outCardPoint.GetMahjongCard();

        switch (action)
        {
        case UserAction.chi:
        case UserAction.peng:
            card1 = userPriority[userID].handCard.GetMahjongCard(arg[0][0], 0);
            card2 = userPriority[userID].handCard.GetMahjongCard(arg[0][1] - 1, 0);
            //牌型验证
            if (arg.Length > 1 && arg[1].Count > 2)
            {
                card1.mesh.mesh = ResoucreMtr.Instance.GetMesh(arg[1][0]);
                card2.mesh.mesh = ResoucreMtr.Instance.GetMesh(arg[1][1]);
                card.mesh.mesh  = ResoucreMtr.Instance.GetMesh(arg[1][2]);
            }

            yield return(gameAct.AddPengChi(userPriority[userID], CardActType.Chi, card, card1, card2));

            break;

        case UserAction.ming_gang:
            card1 = userPriority[userID].handCard.GetMahjongCard(arg[0][0], 0);
            card2 = userPriority[userID].handCard.GetMahjongCard(arg[0][1] - 1, 0);
            MahjongPrefab card3 = userPriority[userID].handCard.GetMahjongCard(arg[0][2] - 2, 0);
            //牌型验证
            if (arg.Length > 1 && arg[1].Count > 3)
            {
                card1.mesh.mesh = ResoucreMtr.Instance.GetMesh(arg[1][0]);
                card2.mesh.mesh = ResoucreMtr.Instance.GetMesh(arg[1][1]);
                card3.mesh.mesh = ResoucreMtr.Instance.GetMesh(arg[1][2]);
                card.mesh.mesh  = ResoucreMtr.Instance.GetMesh(arg[1][3]);
            }

            yield return(gameAct.AddGang(userPriority[userID], CardActType.MingGang, card, card1, card2, card3));

            break;

        //吃胡将吃牌加入Handlecard
        case UserAction.chi_hu:
            yield return(gameAct.AddHandleCard(userPriority[userID], card));

            nextState = Logic.hu;
            yield return(LogicCprocessor());

            break;
        }
        control.EndStatusFlag(userID, action);
    }
コード例 #2
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        #region 麻将抽发测试  已完成 2016/12/28
        GUILayout.BeginVertical();
        if (GUILayout.Button("发牌顺序:R-F-L-H"))
        {
            GameAct.CardDirection(1);
        }

        if (GUILayout.Button("发牌顺序:H-R-F-L"))
        {
            GameAct.CardDirection(0);
        }

        if (GUILayout.Button("断开连接"))
        {
            GameAct.BreakAllLink();
        }

        if (GUILayout.Button("洗牌"))
        {
            StartCoroutine(GetTest(CardTest.group));
        }

        if (GUILayout.Button("掷色子"))
        {
            StartCoroutine(GetTest(CardTest.diceRoll));
        }

        if (GUILayout.Button("移除色子"))
        {
            StartCoroutine(GetTest(CardTest.displayDice));
        }

        if (GUILayout.Button("清空"))
        {
            GameAct.Reset();
        }
        GUILayout.EndVertical();
        #endregion

        #region 玩家牌测试 所有玩家测试完成 2016/12/28
        GUILayout.BeginVertical();
        if (GUILayout.Button("发牌"))
        {
            MahjongPrefab tran = new MahjongPrefab();
            if (GameAct.hostUser.handCard.IsNotFull)
            {
                tran = GameAct.group_H.GetMahjongCard(6);
            }
            if (tran.transform != null)
            {
                StartCoroutine(GetTest(CardTest.handCard, tran));
            }
        }

        if (GUILayout.Button("获取手牌"))
        {
            StartCoroutine(GetTest(CardTest.getCard));
        }

        if (GUILayout.Button("从最后获取手牌"))
        {
            MahjongPrefab tran = new MahjongPrefab();
            if (GameAct.hostUser.handCard.IsNotFull)
            {
                tran = GameAct.group_H.GetMahjongCard(5, 0);
            }
            if (tran.transform != null)
            {
                StartCoroutine(GetTest(CardTest.getCard, tran));
            }
            //mGameClientAction.GetCard(mGameClientAction.hostUser, tran);
        }

        if (GUILayout.Button("加入手牌"))
        {
            StartCoroutine(GetTest(CardTest.insertCard));
        }

        if (GUILayout.Button("打出第一张牌"))
        {
            MahjongPrefab tran = GameAct.hostUser.handCard.GetMahjongCard();
            StartCoroutine(GetTest(CardTest.outCard, tran));
        }

        if (GUILayout.Button("打出最后一张牌"))
        {
            MahjongPrefab tran = GameAct.hostUser.handCard.GetMahjongCard(0, 0);
            StartCoroutine(GetTest(CardTest.outCard, tran));
        }

        if (GUILayout.Button("明杠"))
        {
            //左边第2个开始 杠四个
            MahjongPrefab tran1 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            MahjongPrefab tran2 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            MahjongPrefab tran3 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            MahjongPrefab tran4 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            StartCoroutine(GameAct.AddGang(GameAct.hostUser, CardActType.MingGang, tran1, tran2, tran3, tran4, () => {
                GameAct.hostUser.handCard.ReSort();
            }));
        }

        if (GUILayout.Button("补杠"))
        {
            //左边第2个开始 杠四个
            MahjongPrefab tran1 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            StartCoroutine(GameAct.InsertToAddGangCard(GameAct.hostUser, index, tran1));
        }

        if (GUILayout.Button("resort"))
        {
        }

        if (GUILayout.Button("暗杠"))
        {
            //左边第2个开始 杠四个
            MahjongPrefab tran1 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            MahjongPrefab tran2 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            MahjongPrefab tran3 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            MahjongPrefab tran4 = GameAct.hostUser.handCard.GetMahjongCard(2, 0, false);
            StartCoroutine(GameAct.AddGang(GameAct.hostUser, CardActType.AnGang, tran1, tran2, tran3, tran4, () => {
                GameAct.hostUser.handCard.ReSort();
            }));
        }

        if (GUILayout.Button("碰"))
        {
            //出牌最后一个
            MahjongPrefab tran1 = GameAct.hostUser.outCardPoint.GetMahjongCard();
            //左边第1个开始  碰两个
            MahjongPrefab tran2 = GameAct.hostUser.handCard.GetMahjongCard(1, 0, false);
            MahjongPrefab tran3 = GameAct.hostUser.handCard.GetMahjongCard(1, 0, false);
            StartCoroutine(GameAct.AddPengChi(GameAct.hostUser, CardActType.Peng, tran1, tran2, tran3, () =>
            {
                GameAct.hostUser.handCard.ReSort();
            }));
        }

        if (GUILayout.Button("吃"))
        {
            //出牌最后一个
            MahjongPrefab tran1 = GameAct.hostUser.outCardPoint.GetMahjongCard();
            //左边第1个开始  手牌两个
            MahjongPrefab tran2 = GameAct.hostUser.handCard.GetMahjongCard(1, 0, false);
            MahjongPrefab tran3 = GameAct.hostUser.handCard.GetMahjongCard(1, 0, false);
            StartCoroutine(GameAct.AddPengChi(GameAct.hostUser, CardActType.Chi, tran1, tran2, tran3, () =>
            {
                GameAct.hostUser.handCard.ReSort();
            }));
        }

        if (GUILayout.Button("重排出牌区域"))
        {
            GameAct.hostUser.outCardPoint.ReSort();
        }

        if (GUILayout.Button("胡"))
        {
            StartCoroutine(GameAct.TurnOverCard(GameAct.hostUser));
        }

        if (GUILayout.Button("功能牌"))
        {
            MahjongPrefab tran = GameAct.hostUser.handCard.GetMahjongCard();
            StartCoroutine(GetTest(CardTest.spacialCard, tran));
        }

        GUILayout.EndVertical();
        GUILayout.BeginVertical();
        if (GUILayout.Button("洗牌"))
        {
            test = processorModel.RandCardData();
            string s = "[ ";
            foreach (byte item in test)
            {
                s += item + " : ";
            }
            s += " ]";
            Debug.Log(s);
        }
        if (GUILayout.Button("排序"))
        {
            processorModel.SelectSort(ref test);
            string s = "[ ";
            foreach (byte item in test)
            {
                s += item + " : ";
            }
            s += " ]";
            Debug.Log(s);
        }
        if (GUILayout.Button("插入"))
        {
            byte item = 10;
            Debug.Log(item);
            int index = processorModel.GetInsert(ref test, item);
            Debug.Log(index);
            string s = "[ ";
            foreach (byte it in test)
            {
                s += it + " : ";
            }
            s += " ]";
            Debug.Log(s);
        }
        GUILayout.EndVertical();
        #endregion
        GUILayout.EndHorizontal();
    }