Ejemplo n.º 1
0
        public void OnGetJueGang(RequestData requeset)
        {
            CpghBehavior.SetBehavior(Enum_CPGType.MingGang);

            Facade.Instance <MusicManager>()
            .Play(GameTools.GetOperationVoice(UserInfo.Sex, ConstantData.Voice_Gang, Random.Range(0, 2)));
            var groupData = new MahjongGroupData(GroupType.JueGang);

            foreach (var card in requeset.Cards)
            {
                if (card > 0)
                {
                    groupData.AddValue(card);
                }
            }
            var needItems = new List <MahjongItem>();

            needItems.AddRange(GetCardsFromHand(groupData.values.ToList(), IsOther));
            foreach (var item in needItems)
            {
                DestroyUserContorl(item);
            }
            MahjongEnv.AddGroup(groupData, needItems, IsOther);
            GroupItems.Add(groupData);
            SortHandCard();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     重连
        /// </summary>
        /// <param name="data"></param>
        /// <param name="lastIn"></param>
        /// <param name="isCurrent"></param>
        public virtual void OnReJoin(ISFSObject data)
        {
            #region Data

            ISFSArray Groups;
            int[]     OutCards;
            int[]     HandCards;
            int       HandNum;
            bool      hasTing;
            GameTools.TryGetValueWitheKey(data, out Groups, RequestKey.KeyGroups);
            GameTools.TryGetValueWitheKey(data, out OutCards, RequestKey.KeyOutCards);
            GameTools.TryGetValueWitheKey(data, out HandCards, RequestKey.KeyHandCards);
            GameTools.TryGetValueWitheKey(data, out HandNum, RequestKey.KeyHandCardsNum);
            GameTools.TryGetValueWitheKey(data, out hasTing, RequestKey.KeyHasTing);
            HasTing       = hasTing;
            GroupItems    = new List <MahjongGroupData>();
            ThrowOutCards = new List <int>();
            GroupItems.AddRange(GameTools.GetGroupData(Groups));
            ThrowOutCards.AddRange(OutCards.ToList());
            if (HandCards.Length.Equals(0))
            {
                HandCards = new int[HandNum];
            }
            HandCardList = HandCards.ToList();

            #endregion

            #region UI

            MahjongEnv.AddOutCards(ThrowOutCards);
            for (int i = 0, lenth = GroupItems.Count; i < lenth; i++)
            {
                MahjongEnv.AddGroup(GroupItems[i], null, IsOther);
            }
            AddHandCards(HandCardList);
            if (hasTing)
            {
                ShowTingWithEffect(false);
            }

            #endregion
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     吃碰杠回包
        /// </summary>
        /// <param name="request"></param>
        /// <param name="data"></param>
        public void AllowRequest(RequestData request, ISFSObject data)
        {
            GetToken();
            int  tType;
            int  dealCard;
            var  randomNum = 0;
            var  voiceName = "";
            bool isOk;

            dealCard = request.Card;
            GameTools.TryGetValueWitheKey(data, out tType, RequestKey.KeyTypeType);
            GameTools.TryGetValueWitheKey(data, out isOk, RequestKey.KeyOk);
            if (isOk)
            {
                YxDebug.Log("这个回包中的ok标识是true,不执行操作,因为false时已经执行过了");
                return;
            }
            var needItems = new List <MahjongItem>();
            var groupData = new MahjongGroupData((GroupType)tType);
            var dealCards = new List <int>();

            for (int i = 0, lenth = request.Cards.Length; i < lenth; i++)
            {
                YxDebug.Log((EnumMahjongValue)request.Cards[i]);
            }
            var fromHand = true;

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

            case Enum_CPGType.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.Voice_Chi;
                randomNum = Random.Range(0, 3);
                break;

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

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

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

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

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

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