コード例 #1
0
        public void OnGetCaiGang(RequestData requeset)
        {
            GetToken();
            CpghBehavior.SetBehavior(EnumCpgType.CaiGang);
            Facade.Instance <MusicManager>().Play(GameTools.GetOperationVoice(UserInfo.Sex, ConstantData.VoiceGang,
                                                                              Random.Range(0, 2)));

            MahjongGroupData groupData = new MahjongGroupData(GroupType.CaiGang);

            foreach (int card in requeset.Cards)
            {
                if (card > 0)
                {
                    groupData.AddValue(card);
                }
            }

            List <MahjongItem> needItems = new List <MahjongItem>();

            needItems.AddRange(GetCardsFromHand(groupData.values.ToList(), IsOther));
            foreach (var item in needItems)
            {
                GameTools.DestroyUserContorl(item);
            }
            MahjongEnv.AddGroup(groupData, needItems, IsOther);
            GroupItems.Add(groupData);
            SortHandCard();
        }
コード例 #2
0
ファイル: MahjongPlayerCtrl.cs プロジェクト: da1fanshu/yizhe
        public override MahjongItem OnThrowCard(int value, AsyncCallback finishCall = null)
        {
            MahjongItem item = base.OnThrowCard(value, finishCall);

            item.SetColor(Color.white);
            GameTools.DestroyUserContorl(item);
            SortCardOnSureLaizZi();
            return(item);
        }
コード例 #3
0
        public void SetHandCardsInvalid()
        {
            List <Transform> trans = _handPile.GetList();

            SetItemsColor(Color.gray, trans);
            foreach (Transform tran in trans)
            {
                GameTools.DestroyUserContorl(tran);
            }
            if (LastGetInMahjong != null)
            {
                LastGetInMahjong.SetColor(Color.gray);
                GameTools.DestroyUserContorl(LastGetInMahjong);
            }
        }
コード例 #4
0
        public virtual void OnGetXFGang(RequestData requeset)
        {
            EnumCpgType fengGangBehavior = EnumCpgType.MingGang;
            string      fengGangInfo     = GameTools.GetOperationVoice(UserInfo.Sex, ConstantData.VoiceGang, Random.Range(0, 2));

            GetToken();
            MahjongGroupData groupData = new MahjongGroupData(GroupType.FengGang);

            if (requeset.Cards.Length == 3)
            {
                if (ShowFengGangByNum)
                {
                    fengGangBehavior = EnumCpgType.ThreeFengGang;
                    fengGangInfo     = GameTools.GetOperationVoice(UserInfo.Sex, ConstantData.VoiceThreeFengGang, 0);
                }
                groupData.values = new int[3];
            }
            else
            {
                if (ShowFengGangByNum)
                {
                    fengGangBehavior = EnumCpgType.FourFengGang;
                    fengGangInfo     = GameTools.GetOperationVoice(UserInfo.Sex, ConstantData.VoiceFourFengGang, 0);
                }
            }
            Facade.Instance <MusicManager>().Play(fengGangInfo);
            CpghBehavior.SetBehavior(fengGangBehavior);
            foreach (int card in requeset.Cards)
            {
                if (card > 0)
                {
                    groupData.AddValue(card);
                }
            }

            List <MahjongItem> needItems = new List <MahjongItem>();

            needItems.AddRange(GetCardsFromHand(groupData.values.ToList(), IsOther));
            foreach (var item in needItems)
            {
                GameTools.DestroyUserContorl(item);
            }
            MahjongEnv.AddGroup(groupData, needItems, IsOther);
            GroupItems.Add(groupData);
            SortHandCard();
            RecheckLastGetIn();
        }
コード例 #5
0
        public void SetHandCardsColor(Color color, bool removeControl)
        {
            var trans = _handPile.GetList();

            foreach (var tran in trans)
            {
                var item = tran.GetComponent <MahjongItem>();
                if (item != null)
                {
                    item.SetColor(color);
                    if (removeControl)
                    {
                        GameTools.DestroyUserContorl(item);
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// 吃碰杠回包
        /// </summary>
        /// <param name="request"></param>
        /// <param name="showBehavior"></param>
        public virtual void  AllowRequest(RequestData request, bool showBehavior)
        {
            GetToken();
            int    tType;
            int    dealCard;
            int    randomNum = 0;
            string voiceName = "";
            bool   isOk;
            bool   isGangBao;

            dealCard = request.Card;
            var data = request.Data;

            GameTools.TryGetValueWitheKey(data, out tType, RequestKey.KeyTypeType);
            GameTools.TryGetValueWitheKey(data, out isOk, RequestKey.KeyOk);
            isGangBao = data.ContainsKey(RequestKey.KeyGangBao);
            List <MahjongItem> needItems = new List <MahjongItem>();
            MahjongGroupData   groupData = new MahjongGroupData((GroupType)tType);
            List <int>         dealCards = new List <int>();

            if (isGangBao)
            {
                AddHandCard(dealCard, false, false);
                dealCard = request.OpCard;
                if (request.Cards.Length == 0)
                {
                    switch ((GroupType)tType)
                    {
                    case GroupType.ZhuaGang:
                        request.Cards = new[] { dealCard, dealCard, dealCard, dealCard };
                        break;

                    case GroupType.AnGang:
                        request.Cards = new [] { dealCard };
                        break;
                    }
                }
            }
            if (isOk)
            {
                YxDebug.Log("这个回包中的ok标识是true,不执行操作,因为false时已经执行过了");
                return;
            }
            for (int i = 0, lenth = request.Cards.Length; i < lenth; i++)
            {
                YxDebug.Log((EnumMahjongValue)request.Cards[i]);
            }
            bool fromHand = true;

            switch ((EnumCpgType)tType)
            {
            case EnumCpgType.None:
                return;

            case EnumCpgType.Chi:
                groupData.AddValue(request.Cards[0]);
                groupData.AddValue(dealCard);
                groupData.AddValue(request.Cards[1]);
                for (int i = 0, lenth = request.Cards.Length; i < lenth; i++)
                {
                    dealCards.Add(request.Cards[i]);
                }
                voiceName = ConstantData.VoiceChi;
                randomNum = Random.Range(0, 3);
                break;

            case EnumCpgType.Peng:
                if (dealCard.Equals(App.GetGameManager <Mahjong2DGameManager>().FanNum) && Data.IsGangSelect)
                {
                    voiceName = ConstantData.VoiceGang;
                    randomNum = Random.Range(0, 2);
                    tType     = (int)EnumCpgType.ZhuaGang;
                }
                else
                {
                    voiceName = ConstantData.VoicePeng;
                    randomNum = Random.Range(0, 3);
                }
                dealCards = CreateListWithValue(2, dealCard);
                break;

            case EnumCpgType.ZhuaGang:
                voiceName = ConstantData.VoiceGang;
                randomNum = Random.Range(0, 2);
                fromHand  = false;
                dealCards = CreateListWithValue(1, dealCard);
                break;

            case EnumCpgType.PengGang:
            case EnumCpgType.MingGang:
                dealCards = CreateListWithValue(3, dealCard);
                voiceName = ConstantData.VoiceGang;
                randomNum = Random.Range(0, 2);
                break;

            case EnumCpgType.AnGang:
                dealCards = CreateListWithValue(4, dealCard);
                voiceName = ConstantData.VoiceGang;
                randomNum = Random.Range(0, 2);
                break;

            case EnumCpgType.LaiZiGang:
                break;
            }
            if (!tType.Equals((int)EnumCpgType.Chi))
            {
                for (int i = 0, lenth = request.Cards.Length; i < lenth; i++)
                {
                    groupData.AddValue(dealCard);
                }
            }
            MahjongItem lastItem = Manager.GetLastOutCardItem(dealCard);

            if (lastItem != null)
            {
                YxDebug.Log(string.Format("最后打出的一张牌是:{0}", (EnumMahjongValue)lastItem.Value));
                needItems.Add(lastItem);
                if (!tType.Equals((int)EnumCpgType.Chi))
                {
                    groupData.AddValue(dealCard);
                }
            }
            if (fromHand)
            {
                needItems.AddRange(GetCardsFromHand(dealCards, IsOther));
                foreach (var item in needItems)
                {
                    GameTools.DestroyUserContorl(item);
                }
                MahjongEnv.AddGroup(groupData, needItems, IsOther);
                GroupItems.Add(groupData);
            }
            else//抓杠特殊处理
            {
                MahjongItem item = GetHandCard(dealCard);
                if (item != null)
                {
                    GameTools.DestroyUserContorl(item);
                    MahjongEnv.ChangeGroup(dealCard, item);
                    if (IsOther)
                    {
                        HandCardList.Remove(0);
                    }
                    else
                    {
                        HandCardList.Remove(dealCard);
                    }
                }
                else
                {
                    if (!isGangBao)
                    {
                        YxDebug.LogError("抓杠时,找不到那张手牌" + (EnumMahjongValue)dealCard);
                    }
                    else
                    {
                        YxDebug.LogError("杠宝时,找不到那张手牌" + (EnumMahjongValue)dealCard);
                    }
                }
            }
            if (showBehavior)
            {
                CpghBehavior.SetBehavior((EnumCpgType)tType);
            }
            Facade.Instance <MusicManager>().Play(GameTools.GetOperationVoice(UserInfo.Sex, voiceName, randomNum));
            SortHandCard();
            RecheckLastGetIn();
        }