Пример #1
0
 /// <summary>
 /// 取消听选择
 /// </summary>
 public void OnClickTingCancel()
 {
     MahjongEnv.ClearHandFlag();
     AddHandCardsControl();
     ReShowMenu();
     Data.IsClickTing = false;
 }
Пример #2
0
 /// <summary>
 /// 获得一张牌
 /// </summary>
 /// <param name="direct">是否直接落下</param>
 public virtual void OutCardDown(bool direct = false)
 {
     if (LastOutCard != null)
     {
         MahjongEnv.ThrowOutCardToOutCard(direct, HasTing);
     }
 }
Пример #3
0
 public virtual void ShowLiangPaiAtGameEnd(List <int> ShowCards, bool zimo, int huCard = 0)
 {
     if (zimo)
     {
         ShowCards.Remove(huCard);
     }
     HandCardList = ShowCards.ToList();
     if (huCard > 0)
     {
         if (OnGetNewCard())
         {
             MahjongEnv.LastGetInMahjong.Value = huCard;
         }
         else
         {
             MahjongEnv.AddHandCard(huCard, true, false);
         }
         MahjongEnv.LastGetInMahjong.SetHuTag();
     }
     ShowCardList =
         GameTools.SortCardWithLaiZi(HandCardList, App.GetGameManager <Lyzz2DGameManager>().LaiZiNum).ToList();
     LostToken();
     RefresheShow(false);
     DoShowLiang();
 }
Пример #4
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();
        }
Пример #5
0
 public virtual void SetHandCardOnTing(bool hasTing)
 {
     if (PushHandOnTing)
     {
         MahjongEnv.SetHandCardPush(hasTing);
     }
 }
Пример #6
0
        protected virtual void ToSelectTingOut()
        {
            List <int> outList   = Manager.TingOutCards;
            var        tingCount = outList.Count;

            if (tingCount == 1)
            {
                var         tingValue  = outList[0];
                MahjongItem selectItem = GetHandCard(tingValue);
                if (selectItem)
                {
                    OnMahjongClick(selectItem.transform);
                }
            }
            else
            {
                MahjongEnv.SetHandCardsInvalid();
                InteraptMenu.Instance.Revert();
                InteraptMenu.Instance.ShowTing(true);
                for (int i = 0; i < tingCount; i++)
                {
                    int         checkValue = outList[i];
                    MahjongItem selectItem = GetHandCard(checkValue);
                    if (selectItem != null)
                    {
                        selectItem.SetColor(Color.white);
                        AddUserControl(selectItem);
                    }
                    else
                    {
                        YxDebug.LogError(string.Format("TingOut牌中的牌:{0}值是:{1},不存在于实际手牌中", (EnumMahjongValue)checkValue, checkValue));
                    }
                }
            }
        }
Пример #7
0
 public virtual void OnOtherGetCard()
 {
     if (LastOutCard != null)
     {
         YxDebug.Log(string.Format("玩家{0}的牌{1}落下", UserInfo.name, (EnumMahjongValue)LastOutCard.Value));
     }
     MahjongEnv.ThrowOutCardToOutCard();
 }
Пример #8
0
        /// <summary>
        /// 打出宝牌
        /// </summary>
        /// <param name="baoCard">宝牌</param>
        /// <param name="time">移动时间</param>
        public virtual void ThrowBaoCard(int baoCard, float time)
        {
            MahjongItem item = Manager.GetNextMahjong(false);

            item.Value                  = baoCard;
            item.SelfData.Action        = EnumMahJongAction.Lie;
            item.SelfData.Direction     = EnumMahJongDirection.Vertical;
            item.SelfData.ShowDirection = EnumShowDirection.Self;
            MahjongEnv.MoveCardToOutPile(item, time);
        }
Пример #9
0
        /// <summary>
        /// 获得一张手牌
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        protected override MahjongItem GetHandCard(int value)
        {
            MahjongItem item = MahjongEnv.GetHandCardByValue(value);

            if (item == null)
            {
                YxDebug.LogError(string.Format("玩家{0}要获得的手牌{1}不存在", UserInfo.name, (EnumMahjongValue)value));
            }
            return(item);
        }
Пример #10
0
        public virtual MahjongItem AddHandCard(int value, bool isSingle, bool needRefresh)
        {
            var item = MahjongEnv.AddHandCard(value, isSingle).GetComponent <MahjongItem>();

            if (item != null)
            {
                return(item);
            }
            YxDebug.LogError(string.Format("新增了一张牌,没有创建成功,牌是{0},值是:{1}", (EnumMahjongValue)value, value));
            return(null);
        }
Пример #11
0
 public virtual void TraAddLastGetInCard()
 {
     if (_mahJongEnv.LastGetInMahjong != null)
     {
         var item = _mahJongEnv.LastGetInMahjong;
         if (item != null)
         {
             MahjongEnv.AddHandCard(item);
             _mahJongEnv.LastGetInMahjong = null;
         }
     }
 }
Пример #12
0
        protected virtual List <Transform> SetHandCardsValid(Predicate <Transform> match)
        {
            MahjongEnv.SetHandCardsInvalid();
            var matchList = MahjongEnv.HandCards.FindAll(match);

            MahjongEnv.SetItemsColor(Color.white, matchList);
            foreach (var matchItem in matchList)
            {
                AddUserControl(matchItem);
            }
            return(matchList);
        }
Пример #13
0
        private void DoShowLiang(bool zimo)
        {
            MahjongEnv.ShowHandCard();
            MahjongItem item = MahjongEnv.LastGetInMahjong;

            if (item != null)
            {
                MahjongEnv.LastOutMahjong   = item;
                MahjongEnv.LastGetInMahjong = null;
                MahjongEnv.ThrowOutCard(item, !zimo);
            }
            Facade.Instance <MusicManager>().Play(ConstantData.VoiceLiangPai);
        }
Пример #14
0
 /// <summary>
 /// 刷新使用
 /// </summary>
 /// <param name="isOther">这个参数可以控制显示UI</param>
 protected virtual void RefresheShow(bool isOther)
 {
     if (HasToken && OnGetNewCard())
     {
         if (isOther)
         {
             ShowCardList.Remove(0);
         }
         else
         {
             ShowCardList.Remove(LastGetValue);
         }
     }
     MahjongEnv.RefreshHandList(ShowCardList);
 }
Пример #15
0
 /// <summary>
 ///     玩家重置操作
 /// </summary>
 public virtual void Reset()
 {
     _isZhuang = false;
     HasTing   = false;
     if (CurrentInfoPanel != null && UserInfo != null)
     {
         CurrentInfoPanel.SetGang(UserInfo.Piao);
         CurrentInfoPanel.Reset();
     }
     HandCardList.Clear();
     ShowCardList.Clear();
     ThrowOutCards.Clear();
     GroupItems.Clear();
     MahjongEnv.Reset(IsOther);
 }
Пример #16
0
 /// <summary>
 ///     刷新使用
 /// </summary>
 /// <param name="isOther">这个参数可以控制显示UI</param>
 protected virtual void RefresheShow(bool isOther)
 {
     if (HasToken && OnGetNewCard())
     {
         if (isOther)
         {
             ShowCardList.Remove(0);
         }
         else
         {
             ShowCardList.Remove(LastGetValue);
         }
         YxDebug.Log(string.Format("玩家{0},name{1}存在token,在打牌时删除一张牌", UserInfo.name, UserInfo.name));
     }
     MahjongEnv.RefreshHandList(ShowCardList);
 }
Пример #17
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();
        }
Пример #18
0
        public List <MahjongItem> GetCardsFromHand(List <int> list, bool isOther)
        {
            var needItems = new List <MahjongItem>();

            needItems.AddRange(MahjongEnv.GetHandItems(list.Count));
            for (int i = 0, lenth = list.Count; i < lenth; i++)
            {
                if (isOther)
                {
                    HandCardList.Remove(0);
                }
                else
                {
                    HandCardList.Remove(list[i]);
                }
            }
            return(needItems);
        }
Пример #19
0
        /// <summary>
        /// 打牌
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public virtual MahjongItem OnThrowCard(int value, AsyncCallback finishCall = null)
        {
            MahjongItem item;

            LostToken();
            item = GetHandCard(value);
            if (IsOther)
            {
                HandCardList.Remove(0);
            }
            else
            {
                HandCardList.Remove(value);
            }
            MahjongEnv.ThrowOutCard(item, false, HasTing || App.GetGameData <Mahjong2DGameData>().IsInRobot, 0, finishCall);
            SortHandCard();
            Facade.Instance <MusicManager>().Play(GameTools.GetOperationVoice(UserInfo.Sex, value.ToString(), 0));
            return(item);
        }
Пример #20
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
        }
Пример #21
0
        public virtual MahjongItem OnThrowCard(int value)
        {
            YxDebug.Log(string.Format("玩家{0}打出一张牌{1}", UserInfo.name, (EnumMahjongValue)value));
            LostToken();
            var item = GetHandCard(value);

            if (IsOther)
            {
                HandCardList.Remove(0);
            }
            else
            {
                HandCardList.Remove(value);
            }
            MahjongEnv.ThrowOutCard(item);
            SortHandCard();
            Facade.Instance <MusicManager>().Play(GameTools.GetOperationVoice(UserInfo.Sex, value.ToString(), 0));
            YxDebug.Log("打牌飞起状态");
            return(item);
        }
Пример #22
0
 /// <summary>
 /// 设置最后一张抓进手里的牌
 /// </summary>
 /// <param name="lastIn"></param>
 public override void SetLastInCardOnReJoin(int lastIn)
 {
     LastGetValue = lastIn;
     MahjongEnv.SetLastInCardOnReJoin(lastIn);
 }
Пример #23
0
 public override void ShowTingWithEffect(bool withEffect)
 {
     base.ShowTingWithEffect(withEffect);
     MahjongEnv.SetHandCardsInvalid();
 }
Пример #24
0
 public virtual void SetLastOutMahjongShow(int lastOtCdValue)
 {
     MahjongEnv.SetLastOutMahjongShow(lastOtCdValue);
 }
Пример #25
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();
        }
Пример #26
0
 public virtual void SetLastInCardOnReJoin(int lastIn)
 {
     MahjongEnv.SetLastInCardOnReJoin(0);
 }
Пример #27
0
 public virtual void Awake()
 {
     _isZhuang  = false;
     GroupItems = new List <MahjongGroupData>();
     MahjongEnv.GetComponent <DefEnvpanel>();
 }
Пример #28
0
 private void DoShowLiang()
 {
     MahjongEnv.ShowHandCard();
     Facade.Instance <MusicManager>().Play(ConstantData.Voice_LiangPai);
 }
Пример #29
0
 public override void ShowTingWithEffect(bool withEffect)
 {
     base.ShowTingWithEffect(withEffect);
     MahjongEnv.SetHandCardsColor(Color.grey, true);
 }