コード例 #1
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		private static void CardSetSort(RX_CardSet sender)
		{
			//从小到大的顺序..
			sender.Card_lister.Sort ((RX_Card x, RX_Card y) => {
				return (int)x.Level - (int)y.Level;	
			});
		}
コード例 #2
0
 private static void CardSetSort(RX_CardSet sender)
 {
     //从小到大的顺序..
     sender.Card_lister.Sort((RX_Card x, RX_Card y) => {
         return((int)x.Level - (int)y.Level);
     });
 }
コード例 #3
0
        /// <summary>
        /// Determines if is feijibudai the specified sender.
        /// </summary>
        /// <returns><c>true</c> if is feijibudai the specified sender; otherwise, <c>false</c>.</returns>
        /// <param name="sender">Sender.</param>
        public static bool IsFeijibudai(RX_CardSet sender)
        {
            CardSetSort(sender);
            if (NotNull(sender) && EffectiveNumber(sender, 6, 20) && CanBeDivided(sender, 3))
            {
                int n = sender.Card_lister.Count / 3;

                for (int i = 0; i < n; i++)
                {
                    //334555667
                    if (!AllIsTheSame(sender, i * 3, 3))
                    {
                        return(false);
                    }

                    //AAA222
                    if (!IsNormal(sender, i * 3))
                    {
                        return(false);
                    }

                    //333555
                    if (!IsJoined(sender, i * 3, i * 3 + 3))
                    {
                        return(false);
                    }
                }
                sender.Card_type  = RX_CARD_SET.RX_TYPE_FEI_BUDAI;
                sender.Card_level = sender.Card_lister[0].Level;
                return(true);
            }
            return(false);
        }
コード例 #4
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		private static bool IsJoined(RX_CardSet sender,int l,int r)
		{
			if (r >= sender.Card_lister.Count) 
			{
				return true;
			}
			return (int)sender.Card_lister [l].Level - (int)sender.Card_lister [r].Level == -1;
		}
コード例 #5
0
 private static bool IsJoined(RX_CardSet sender, int l, int r)
 {
     if (r >= sender.Card_lister.Count)
     {
         return(true);
     }
     return((int)sender.Card_lister [l].Level - (int)sender.Card_lister [r].Level == -1);
 }
コード例 #6
0
        private static bool IsNormal(RX_CardSet sender, int index)
        {
            RX_Card card = sender.Card_lister [index];

            return
                (card.Level != RX_CARD_LEVEL.RX_LEVEL_2 &&
                 card.Level != RX_CARD_LEVEL.RX_LEVEL_S &&
                 card.Level != RX_CARD_LEVEL.RX_LEVEL_B);
        }
コード例 #7
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		private static bool IsNormal(RX_CardSet sender,int index)
		{
			RX_Card card = sender.Card_lister [index];

			return 
				card.Level != RX_CARD_LEVEL.RX_LEVEL_2 &&
				card.Level != RX_CARD_LEVEL.RX_LEVEL_S &&
				card.Level != RX_CARD_LEVEL.RX_LEVEL_B;
		}
コード例 #8
0
 /// <summary>
 /// Determines if is san bu dai the specified sender.
 /// </summary>
 /// <returns><c>true</c> if is san bu dai the specified sender; otherwise, <c>false</c>.</returns>
 /// <param name="sender">Sender.</param>
 public static bool IsSanBuDai(RX_CardSet sender)
 {
     if (NotNull(sender) && EffectiveNumber(sender, 3) && AllIsTheSame(sender, 0, 3))
     {
         sender.Card_type  = RX_CARD_SET.RX_TYPE_SAN_BUDAI;
         sender.Card_level = sender.Card_lister [0].Level;
         return(true);
     }
     return(false);
 }
コード例 #9
0
 /// <summary>
 /// Determines if is boom the specified sender.
 /// </summary>
 /// <returns><c>true</c> if is boom the specified sender; otherwise, <c>false</c>.</returns>
 /// <param name="sender">Sender.</param>
 public static bool IsBoom(RX_CardSet sender)
 {
     if (NotNull(sender) && EffectiveNumber(sender, 4) && AllIsTheSame(sender, 0, 4))
     {
         sender.Card_type  = RX_CARD_SET.RX_TYPE_BOOM;
         sender.Card_level = sender.Card_lister [0].Level;
         return(true);
     }
     return(false);
 }
コード例 #10
0
        /// <summary>
        /// Determines if is sandaiyi the specified sender.
        /// </summary>
        /// <returns><c>true</c> if is sandaiyi the specified sender; otherwise, <c>false</c>.</returns>
        /// <param name="sender">Sender.</param>
        public static bool IsSandaiyi(RX_CardSet sender)
        {
            if (NotNull(sender) && EffectiveNumber(sender, 4))
            {
                //排序...
                CardSetSort(sender);

                if (AllIsTheSame(sender, 0, 4))
                {
                    return(false);
                }

                if (AllIsTheSame(sender, 0, 3))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SAN_DAI;
                    sender.Card_level = sender.Card_lister[0].Level;
                    return(true);
                }

                if (AllIsTheSame(sender, 1, 3))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SAN_DAI;
                    sender.Card_level = sender.Card_lister[1].Level;
                    return(true);
                }
            }

            if (NotNull(sender) && EffectiveNumber(sender, 5))
            {
                //排序...
                CardSetSort(sender);

                if (AllIsTheSame(sender, 0, 4) || AllIsTheSame(sender, 1, 4))
                {
                    return(false);
                }

                if (AllIsTheSame(sender, 0, 3) && AllIsTheSame(sender, 3, 2))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SAN_DAI;
                    sender.Card_level = sender.Card_lister[0].Level;
                    return(true);
                }

                if (AllIsTheSame(sender, 0, 2) && AllIsTheSame(sender, 2, 3))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SAN_DAI;
                    sender.Card_level = sender.Card_lister[2].Level;
                    return(true);
                }
            }

            return(false);
        }
コード例 #11
0
        /// <summary>
        /// 如果是单牌,则修改对象属性..
        /// </summary>
        /// <returns><c>true</c> if is dan the specified sender; otherwise, <c>false</c>.</returns>
        /// <param name="sender">Sender.</param>
        public static bool IsDan(RX_CardSet sender)
        {
            if (NotNull(sender) && EffectiveNumber(sender, 1))
            {
                sender.Card_type  = RX_CARD_SET.RX_TYPE_DAN;
                sender.Card_level = (sender.Card_lister [0]).Level;

                return(true);
            }

            return(false);
        }
コード例 #12
0
        /// <summary>
        /// Determines if is lian dui the specified sender.
        /// </summary>
        /// <returns><c>true</c> if is lian dui the specified sender; otherwise, <c>false</c>.</returns>
        /// <param name="sender">Sender.</param>
        public static bool IsLianDui(RX_CardSet sender)
        {
            if (NotNull(sender) && EffectiveNumber(sender, 6, 20) && CanBeDivided(sender, 2))
            {
                //将牌型进行排序..
                CardSetSort(sender);

                //33445566

                //34556677

                //33558899

                //KKAA22

                //计算出有n对..
                int n = sender.Card_lister.Count / 2;

                //遍历n对..
                for (int i = 0; i < n; i++)
                {
                    //34556677
                    if (!AllIsTheSame(sender, i * 2, 2))
                    {
                        return(false);
                    }

                    //KKAA22
                    if (!IsNormal(sender, i * 2))
                    {
                        return(false);
                    }

                    //01234567
                    //33558899
                    if (!IsJoined(sender, i * 2, i * 2 + 2))
                    {
                        return(false);
                    }
                }

                sender.Card_type  = RX_CARD_SET.RX_TYPE_LIANDUI;
                sender.Card_level = sender.Card_lister[0].Level;
                return(true);
            }

            return(false);
        }
コード例 #13
0
        /// <summary>
        /// Determines if is big boom the specified sender.
        /// </summary>
        /// <returns><c>true</c> if is big boom the specified sender; otherwise, <c>false</c>.</returns>
        /// <param name="sender">Sender.</param>
        public static bool IsBigBoom(RX_CardSet sender)
        {
            if (NotNull(sender) && EffectiveNumber(sender, 2))
            {
                //王炸的Card_level值...
                int target_Card_level = (int)RX_CARD_LEVEL.RX_LEVEL_B + (int)RX_CARD_LEVEL.RX_LEVEL_S;

                //当前牌型的Card_level值...
                int current_Card_level = (int)sender.Card_lister[0].Level + (int)sender.Card_lister[1].Level;

                if (target_Card_level == current_Card_level)
                {
                    sender.Card_type = RX_CARD_SET.RX_TYPE_WANGZHA;
                    return(true);
                }
            }

            return(false);
        }
コード例 #14
0
		private static bool CompareIn(RX_CardSet sender)
		{
			RX_PopCardSet pop = RX_PopCardSetManager.Last();

			if (pop.ListCardSet.Count == 0) {
				return true;
			}

			if (pop.ListCardSet.Count >= 1) 
			{

				RX_CardSet theCareSet = pop.Last();

				theCareSet = theCareSet.Typer == RX_CARD_SET.RX_TYPE_BUCHU ? pop.Last2(): theCareSet;

				if (theCareSet.Typer == RX_CARD_SET.RX_TYPE_BUCHU && sender.Typer != RX_CARD_SET.RX_TYPE_BUCHU) {
					return true;
				}

				if (sender.Typer == RX_CARD_SET.RX_TYPE_BUCHU) {
					return true;
				}

				if (sender.Typer == RX_CARD_SET.RX_TYPE_WANGZHA)
				{
					return true;
				}

				if (theCareSet.Typer != RX_CARD_SET.RX_TYPE_BOOM && sender.Typer == RX_CARD_SET.RX_TYPE_BOOM) {
					return true;
				}

				if (sender.Typer != theCareSet.Typer) {
					return false;
				}

				if ((int)sender.Level <= (int)theCareSet.Level) {
					return false;
				}
			}

			return true;
		}
コード例 #15
0
        /// <summary>
        /// Alls the is the same.
        /// </summary>
        /// <returns><c>true</c>, if is the same was alled, <c>false</c> otherwise.</returns>
        /// <param name="sender">Sender.</param>
        /// <param name="index">Index.</param>
        /// <param name="count">Count.</param>
        private static bool AllIsTheSame(RX_CardSet sender, int index, int count)
        {
            bool flag = true;

            for (int i = index; i < index + count - 1; i++)
            {
                RX_Card l = sender.Card_lister [i];
                RX_Card r = sender.Card_lister [i + 1];

                if (l.Level != r.Level)
                {
                    flag = false;
                    break;
                }
            }


            return(flag);
        }
コード例 #16
0
ファイル: RX_Manager.cs プロジェクト: applexiaohao/RXCardGame
	public void DontPop()
	{
		RX_CardSet cardset = new RX_CardSet();
		cardset.Typer = RX_CARD_SET.RX_TYPE_BUCHU;

		bool isSuccessed = true;
		RX_PopCardSetManager.AddCardSet(cardset,out isSuccessed);

//		if (seat == bottom_seat) 
//		{
//			bottom_pop_label.text = "Pass";
//
//			NGUITools.DestroyChildren(bottom_pop_pool.transform);
//
//			seat = this.right_seat;
//
//			return;
//		}
//		if (seat == this.right_seat) {
//
//			right_pop_label.text = "Pass";
//		
//			NGUITools.DestroyChildren(right_pop_pool.transform);
//
//			seat = this.left_seat;
//
//			return;
//		}
//
//		if (seat == this.left_seat) {
//
//			left_pop_label.text = "Pass";
//
//			NGUITools.DestroyChildren(left_pop_pool.transform);
//
//			seat = this.bottom_seat;
//		}
	}
コード例 #17
0
        //右边的写顺子和三带一..
        //中间的写飞机不带和四带二..
        //左边的写飞机带..

        //飞机带、四带二..

        /// <summary>
        /// Determines if is shunzi the specified sender.
        /// </summary>
        /// <returns><c>true</c> if is shunzi the specified sender; otherwise, <c>false</c>.</returns>
        /// <param name="sender">Sender.</param>
        public static bool IsShunzi(RX_CardSet sender)
        {
            if (NotNull(sender) && EffectiveNumber(sender, 5, 12))
            {
                int count = sender.Card_lister.Count;

                //根据级别进行拍讯..
                CardSetSort(sender);

                for (int i = 0; i < count - 1; i++)
                {
                    if (!IsNormal(sender, i) || !IsNormal(sender, i + 1) || !IsJoined(sender, i, i + 1))
                    {
                        return(false);
                    }
                }

                sender.Card_type  = RX_CARD_SET.RX_TYPE_SHUN;
                sender.Card_level = sender.Card_lister[0].Level;
                return(true);
            }

            return(false);
        }
コード例 #18
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		private static bool EffectiveNumber(RX_CardSet sender,int number)
		{
			return sender.Card_lister.Count == number;
		}
コード例 #19
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		//右边的写顺子和三带一..
		//中间的写飞机不带和四带二..
		//左边的写飞机带..

		//飞机带、四带二..

		/// <summary>
		/// Determines if is shunzi the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is shunzi the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsShunzi(RX_CardSet sender)
		{
			if (NotNull(sender) && EffectiveNumber(sender,5,12)) {

				int count = sender.Card_lister.Count;

				//根据级别进行拍讯..
				CardSetSort (sender);

				for (int i = 0; i < count - 1; i++) 
				{
					if (!IsNormal(sender, i) || !IsNormal(sender, i + 1) || !IsJoined(sender, i, i + 1)) 
					{
						return false;
					}
				}

				sender.Card_type = RX_CARD_SET.RX_TYPE_SHUN;
				sender.Card_level = sender.Card_lister[0].Level;
				return true;
			}

			return false;
		}
コード例 #20
0
        /// <summary>
        /// Determines if is feijidai the specified sender.
        /// </summary>
        /// <returns><c>true</c> if is feijidai the specified sender; otherwise, <c>false</c>..</returns>
        /// <param name="sender">Sender..</param>
        public static bool IsFeijidai(RX_CardSet sender)
        {
            if (NotNull(sender) && EffectiveNumber(sender, 8, 20))
            {
                Dictionary <RX_CARD_LEVEL, int> dictionary = new Dictionary <RX_CARD_LEVEL, int> ();

                //按大小给牌分组..
                for (int i = 0; i < sender.Card_lister.Count; i++)
                {
                    RX_Card card = sender.Card_lister [i];

                    int count = 0;
                    if (dictionary.ContainsKey(card.Level))
                    {
                        dictionary.TryGetValue(card.Level, out count);

                        count += 1;

                        //大于3时,直接失败..
                        if (count > 3)
                        {
                            return(false);
                        }

                        dictionary [card.Level] = count;
                    }
                    else
                    {
                        //如果在字典中还没有这个大小的牌,则新加入一个记录..
                        dictionary.Add(card.Level, 1);
                    }
                }

                //按三张和非三张给牌分组..
                List <RX_CARD_LEVEL> three_Card_level_list = new List <RX_CARD_LEVEL> ();
                List <int>           other_Card_level_list = new List <int> ();

                foreach (RX_CARD_LEVEL Card_level in dictionary.Keys)
                {
                    int count = 0;

                    dictionary.TryGetValue(Card_level, out count);

                    if (count == 3)
                    {
                        three_Card_level_list.Add(Card_level);
                    }
                    else
                    {
                        other_Card_level_list.Add(count);
                    }
                }

                //如果飞机中三张相同大小的牌的个数和要带的牌大小的个数不一样,直接返回false..
                //444555666 778899..
                if (three_Card_level_list.Count != dictionary.Keys.Count / 2)
                {
                    return(false);
                }

                //如果不同的牌的张数不一样,返回假..
                //情况444555666  ->(778899)<- 保证张数是 2 2 2 或 1 1 1..
                for (int i = 0; i < other_Card_level_list.Count - 1; i++)
                {
                    if (other_Card_level_list[i] != other_Card_level_list[i + 1])
                    {
                        return(false);
                    }
                }

                //保证三张相同的牌的各个是相连的..
                for (int i = 0; i < three_Card_level_list.Count - 1; i++)
                {
                    if ((int)three_Card_level_list[i] - (int)three_Card_level_list[i + 1] != -1)
                    {
                        return(false);
                    }
                }

                sender.Card_type  = RX_CARD_SET.RX_TYPE_FEI_DAI;
                sender.Card_level = three_Card_level_list[0];

                return(true);
            }

            return(false);
        }
コード例 #21
0
 private static bool NotNull(RX_CardSet sender)
 {
     return(sender != null && sender.Card_lister != null);
 }
コード例 #22
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if is san bu dai the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is san bu dai the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsSanBuDai(RX_CardSet sender)
		{
			if (NotNull (sender) && EffectiveNumber (sender, 3) && AllIsTheSame (sender, 0, 3)) {
				sender.Card_type = RX_CARD_SET.RX_TYPE_SAN_BUDAI;
				sender.Card_level = sender.Card_lister [0].Level;
				return true;
			}
			return false;

		}
コード例 #23
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// 如果是单牌,则修改对象属性..
		/// </summary>
		/// <returns><c>true</c> if is dan the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsDan (RX_CardSet sender)
		{
			if (NotNull (sender) && EffectiveNumber (sender, 1)) 
			{
				sender.Card_type = RX_CARD_SET.RX_TYPE_DAN;
				sender.Card_level = (sender.Card_lister [0]).Level;

				return true;
			}

			return false;
		}
コード例 #24
0
ファイル: RX_SeatInfo.cs プロジェクト: applexiaohao/CardGame
        public RX_CardSet PopCardSet()
        {
            //FindAll 需要传入一个谓词条件....
            List<RX_Card> list = this.Card_list.FindAll((RX_Card obj) => { return obj.IsPop; });
            //create a new cardSet,which player have selected
            RX_CardSet card_set = new RX_CardSet();
            card_set.Card_lister = list;

            //check the whether the cardSet is effect
            if (RX_CardType.IsBigBoom(card_set)||
                RX_CardType.IsBoom(card_set)||
                RX_CardType.IsDan(card_set)||
                RX_CardType.IsDui(card_set)||
                RX_CardType.IsFeijibudai(card_set)||
                RX_CardType.IsFeijidai(card_set)||
                RX_CardType.IsLianDui(card_set)||
                RX_CardType.IsSanBuDai(card_set)||
                RX_CardType.IsSandaiyi(card_set)||
                RX_CardType.IsShunzi(card_set)||
                RX_CardType.IsSidaier(card_set)
                )
            {

                //check can give a hand?
                if (RX_Manager.prevCardSet == null ||
                    (card_set.Card_lister.Count == RX_Manager.prevCardSet.Card_lister.Count && (int)card_set.Card_level > (int)RX_Manager.prevCardSet.Card_level && card_set.Card_type == RX_Manager.prevCardSet.Card_type)
                    || (card_set.Card_type == RX_CARD_SET.RX_TYPE_BOOM && RX_Manager.prevCardSet.Card_type != RX_CARD_SET.RX_TYPE_BOOM && RX_Manager.prevCardSet.Card_type != RX_CARD_SET.RX_TYPE_WANGZHA)
                    || card_set.Card_type == RX_CARD_SET.RX_TYPE_WANGZHA
                    )
                {
                    //clear previous spritePool and add the current cardsSprites to the pool
                    RX_CardManager.ClearPool();
                    UISprite[] sprites = seat_container.GetComponentsInChildren<UISprite>();
                    List<UISprite> param = new List<UISprite>();
                    for (int i = 0; i < sprites.Length ; i ++ )
                    {
                        foreach (RX_Card item in card_set.Card_lister)
                        {
                            if (item.ToString() == sprites[i].name)
                            {
                                //change the sprite's parent, prevent it been destroyed
                                sprites[i].transform.SetParent(GameObject.Find("Control - Handed").transform);
                                param.Add(sprites[i]);
                                sprites[i] = new UISprite();
                                break;
                            }
                        }
                    }
                    RX_CardManager.SetHandedSprites(seat_pos, param);
                    sprites[0] = null;
                    RX_CardManager.AddPool(sprites);

                    ////RemoveAll 需要传入一个谓词条件....instantiate new cards on the screen!
                    this.Card_list.RemoveAll((RX_Card obj) => { return obj.IsPop; });
                    //re layout after deleted the pop cards
                    this.LayoutCardList();
                    return card_set;
                }
                return null;
            }
            else
            {
                return null;
            }
        }
コード例 #25
0
		/// <summary>
		/// Determines if is feijidai the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is feijidai the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsFeijidai(RX_CardSet sender)
		{
			if (NotNull(sender) && EffectiveNumber(sender,8,20)) 
			{
				Dictionary<RX_CARD_LEVEL,int> dictionary= new Dictionary<RX_CARD_LEVEL, int> ();

				for (int i = 0;i < sender.Lister.Count; i++) 
				{
					RX_Card card = sender.Lister [i];

					int count = 0;
					if (dictionary.ContainsKey(card.Level)) 
					{
						dictionary.TryGetValue(card.Level,out count);

						count += 1;

						//大于3时,直接失败..
						if (count > 3) {
							return false;
						}

						dictionary [card.Level] = count;
					}
					else
					{
						dictionary.Add(card.Level,1);
					}
				}

				List<RX_CARD_LEVEL> three_level_list = new List<RX_CARD_LEVEL> ();
				List<int> other_level_list = new List<int> ();

				foreach (RX_CARD_LEVEL level in dictionary.Keys) 
				{
					int count = 0;

					dictionary.TryGetValue (level, out count);

					if (count == 3) {
						three_level_list.Add (level);
					} else {
						other_level_list.Add (count);
					}
				}

				if (three_level_list.Count != dictionary.Keys.Count / 2) 
				{
					return false;
				}

				for (int i = 0; i < other_level_list.Count - 1; i++) 
				{
					if (other_level_list[i] != other_level_list[i + 1]) {
						return false;
					}
				}

				for (int i = 0; i < three_level_list.Count - 1; i++) 
				{
					if ((int)three_level_list[i] - (int)three_level_list[i + 1] != -1) 
					{
						return false;
					}
				}

				sender.Typer = RX_CARD_SET.RX_TYPE_FEI_DAI;
				sender.Level = three_level_list[0];

				return true;
			}

			return false;
		}
コード例 #26
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if is feijidai the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is feijidai the specified sender; otherwise, <c>false</c>..</returns>
		/// <param name="sender">Sender..</param>
		public static bool IsFeijidai(RX_CardSet sender)
		{
			if (NotNull(sender) && EffectiveNumber(sender,8,20)) 
			{
				Dictionary<RX_CARD_LEVEL,int> dictionary= new Dictionary<RX_CARD_LEVEL, int> ();

				//按大小给牌分组..
				for (int i = 0;i < sender.Card_lister.Count; i++) 
				{
					RX_Card card = sender.Card_lister [i];

					int count = 0;
					if (dictionary.ContainsKey(card.Level)) 
					{
						dictionary.TryGetValue(card.Level,out count);

						count += 1;

						//大于3时,直接失败..
						if (count > 3) {
							return false;
						}

						dictionary [card.Level] = count;
					}
					else
					{
						//如果在字典中还没有这个大小的牌,则新加入一个记录..
						dictionary.Add(card.Level,1);
					}
				}

				//按三张和非三张给牌分组..
				List<RX_CARD_LEVEL> three_Card_level_list = new List<RX_CARD_LEVEL> ();
				List<int> other_Card_level_list = new List<int> ();

				foreach (RX_CARD_LEVEL Card_level in dictionary.Keys) 
				{
					int count = 0;

					dictionary.TryGetValue (Card_level, out count);

					if (count == 3) {
						three_Card_level_list.Add (Card_level);
					} else {
						other_Card_level_list.Add (count);
					}
				}

				//如果飞机中三张相同大小的牌的个数和要带的牌大小的个数不一样,直接返回false..
				//444555666 778899..
				if (three_Card_level_list.Count != dictionary.Keys.Count / 2) 
				{
					return false;
				}

				//如果不同的牌的张数不一样,返回假..
				//情况444555666  ->(778899)<- 保证张数是 2 2 2 或 1 1 1..
				for (int i = 0; i < other_Card_level_list.Count - 1; i++) 
				{
					if (other_Card_level_list[i] != other_Card_level_list[i + 1]) {
						return false;
					}
				}

				//保证三张相同的牌的各个是相连的..
				for (int i = 0; i < three_Card_level_list.Count - 1; i++) 
				{
					if ((int)three_Card_level_list[i] - (int)three_Card_level_list[i + 1] != -1) 
					{
						return false;
					}
				}

				sender.Card_type = RX_CARD_SET.RX_TYPE_FEI_DAI;
				sender.Card_level = three_Card_level_list[0];

				return true;
			}

			return false;
		}
コード例 #27
0
        /// <summary>
        /// Determines if is sidaier the specified sender.
        /// </summary>
        /// <returns><c>true</c> if is sidaier the specified sender; otherwise, <c>false</c>.</returns>
        /// <param name="sender">Sender.</param>
        public static bool IsSidaier(RX_CardSet sender)
        {
            if (NotNull(sender) && EffectiveNumber(sender, 6))
            {
                //paixu
                CardSetSort(sender);

                //四个不能带一对..
                if (AllIsTheSame(sender, 0, 4) && !AllIsTheSame(sender, 4, 2))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SIDAIER;
                    sender.Card_level = sender.Card_lister[0].Level;
                    return(true);
                }

                if (AllIsTheSame(sender, 1, 4))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SIDAIER;
                    sender.Card_level = sender.Card_lister[1].Level;
                    return(true);
                }

                if (!AllIsTheSame(sender, 0, 2) && AllIsTheSame(sender, 2, 4))
                {
                    sender.Card_type = RX_CARD_SET.RX_TYPE_SIDAIER;

                    sender.Card_level = sender.Card_lister[2].Level;
                    return(true);
                }

                return(false);
            }

            if (NotNull(sender) && EffectiveNumber(sender, 8))
            {
                CardSetSort(sender);

                //四张同牌在前面,	后四张不能全一样,必须是两队..
                if (AllIsTheSame(sender, 0, 4) && !AllIsTheSame(sender, 4, 4) && AllIsTheSame(sender, 4, 2) && AllIsTheSame(sender, 6, 2))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SIDAIER;
                    sender.Card_level = sender.Card_lister[0].Level;
                    return(true);
                }

                if (AllIsTheSame(sender, 0, 2) && AllIsTheSame(sender, 2, 2) && !AllIsTheSame(sender, 0, 4) && AllIsTheSame(sender, 4, 4))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SIDAIER;
                    sender.Card_level = sender.Card_lister[4].Level;
                    return(true);
                }

                if (AllIsTheSame(sender, 0, 2) && AllIsTheSame(sender, 2, 4) && AllIsTheSame(sender, 6, 2))
                {
                    sender.Card_type  = RX_CARD_SET.RX_TYPE_SIDAIER;
                    sender.Card_level = sender.Card_lister[2].Level;
                    return(true);
                }

                return(false);
            }

            return(false);
        }
コード例 #28
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if is feijibudai the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is feijibudai the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsFeijibudai(RX_CardSet sender)
		{
            CardSetSort(sender);
			if (NotNull(sender) && EffectiveNumber(sender,6,20) && CanBeDivided(sender,3)) 
			{
				int n = sender.Card_lister.Count / 3;

				for (int i = 0; i < n; i++) 
				{
					//334555667
					if (!AllIsTheSame(sender,i * 3,3)) 
					{
						return false;
					}

					//AAA222
					if (!IsNormal(sender,i * 3)) {
						return false;
					}

					//333555
					if (!IsJoined(sender,i * 3,i * 3 + 3)) {
						return false;
					}
				}
				sender.Card_type = RX_CARD_SET.RX_TYPE_FEI_BUDAI;
				sender.Card_level = sender.Card_lister[0].Level;
				return true;
			}
			return false;
		}
コード例 #29
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		private static bool NotNull(RX_CardSet sender)
		{
			return sender != null && sender.Card_lister != null;
		}
コード例 #30
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if is sandaiyi the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is sandaiyi the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsSandaiyi(RX_CardSet sender)
		{

			if (NotNull(sender) && EffectiveNumber(sender,4)) {

				//排序...
				CardSetSort (sender);

				if (AllIsTheSame(sender,0,4)) {
					return false;
				}

				if (AllIsTheSame(sender,0,3) ) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SAN_DAI;
					sender.Card_level = sender.Card_lister[0].Level;
					return true;
				}

				if (AllIsTheSame(sender,1,3)) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SAN_DAI;
					sender.Card_level = sender.Card_lister[1].Level;
					return true;
				}
			}

			if (NotNull(sender) && EffectiveNumber(sender,5)) {

				//排序...
				CardSetSort (sender);

				if (AllIsTheSame(sender,0,4) || AllIsTheSame(sender,1,4)) 
				{
					return false;
				}

				if (AllIsTheSame(sender,0,3) && AllIsTheSame(sender,3,2)) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SAN_DAI;
					sender.Card_level = sender.Card_lister[0].Level;
					return true;
				}

				if (AllIsTheSame(sender,0,2) && AllIsTheSame(sender,2,3)) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SAN_DAI;
					sender.Card_level = sender.Card_lister[2].Level;
					return true;
				}
			}

			return false;
		}
コード例 #31
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if is big boom the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is big boom the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsBigBoom(RX_CardSet sender)
		{
			if (NotNull(sender) && EffectiveNumber(sender,2)) {

				//王炸的Card_level值...
				int target_Card_level = (int)RX_CARD_LEVEL.RX_LEVEL_B + (int)RX_CARD_LEVEL.RX_LEVEL_S;

				//当前牌型的Card_level值...
				int current_Card_level = (int)sender.Card_lister[0].Level + (int)sender.Card_lister[1].Level;

				if (target_Card_level == current_Card_level) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_WANGZHA;
					return true;
				}
			}

			return false;
		}
コード例 #32
0
		public static string AddCardSet(RX_CardSet sender,out bool isSuccessed)
		{
			if (CompareIn(sender)) 
			{

				RX_PopCardSet pop = RX_PopCardSetManager.Last();

				pop.AddCardSet(sender);

				isSuccessed = true;
				RX_PopCardSetManager.SetNeedCreateCardSet();

				return sender.ToString() + ":success";
			}
			else
			{

				isSuccessed = false;

				return sender.ToString() + ":failed";
			}
		}
コード例 #33
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if is boom the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is boom the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsBoom(RX_CardSet sender)
		{
			if (NotNull (sender) && EffectiveNumber (sender, 4) && AllIsTheSame (sender, 0, 4)) 
			{
				sender.Card_type = RX_CARD_SET.RX_TYPE_BOOM;
				sender.Card_level = sender.Card_lister [0].Level;
				return true;
			}	
			return false;
		}
コード例 #34
0
		public void PopCardSet(RX_CardSet sender,PopCardSetDelegate block)
		{
			if (sender == null) {
				return;
			}
			if (block == null) {
				return;
			}

			this.PopBlock = block;
		}
コード例 #35
0
 private static bool EffectiveNumber(RX_CardSet sender, int number)
 {
     return(sender.Card_lister.Count == number);
 }
コード例 #36
0
		/// <summary>
		/// 属于RX_SeatInfo对象的弹出函数...
		/// </summary>
		/// <returns>The card set.</returns>
		public RX_CardSet PopCardSet()
		{
			//List对象有个FindAll函数
			//FindAll函数需要一个谓词Predicate条件,凡是复合该条件的所有List内的元素都会被添加
			//到一个新的List对象内
			List<RX_Card> list = this.CardList.FindAll ((RX_Card obj) => {
				return obj.IsPop;
			});

			//创建一个新的牌型集合...
			RX_CardSet card_set = new RX_CardSet ();
			//将选中的所有牌赋值给新的牌型集合对象
			card_set.Lister = list;



			//通过CardType的11种牌型函数判断,只要有一个为真
			//那么则为正确的牌型
			//当都为假的时候,说明牌型不正确,不能出牌..
			if (RX_CardType.IsDan (card_set) ||
			    RX_CardType.IsDui (card_set) ||
			    RX_CardType.IsShunzi (card_set) ||
			    RX_CardType.IsLianDui (card_set) ||
			    RX_CardType.IsBoom (card_set) ||
			    RX_CardType.IsBigBoom (card_set) ||
			    RX_CardType.IsFeijibudai (card_set) ||
			    RX_CardType.IsFeijidai (card_set) ||
			    RX_CardType.IsSanBuDai (card_set) ||
			    RX_CardType.IsSandaiyi (card_set) ||
			    RX_CardType.IsSidaier (card_set)) 
			{
				//将刚刚打出的牌型集合返回..
				return card_set;
			} else 
			{
				this.Reset ();
				return null;
			}
		}
コード例 #37
0
 private static bool EffectiveNumber(RX_CardSet sender, int minvalue, int maxvalue)
 {
     return(sender.Card_lister.Count >= minvalue && sender.Card_lister.Count <= maxvalue);
 }
コード例 #38
0
		public void RemoveCardSet(RX_CardSet sender,UISprite pool)
		{
			sender.Lister.ForEach((RX_Card item) =>{

				this.CardList.RemoveAll(((RX_Card obj) => {
					return obj.Equals(item);
				}));
			});

			this.LayoutCardList();


			int width 	= pool.width;
			int height	= pool.height;
			
			//每个人最多20张牌,计算出最小的间距
			int margin = 0;
			if (this.Position == RX_SEAT_POSITION.RX_SEAT_LEFT ||
			    this.Position == RX_SEAT_POSITION.RX_SEAT_RIGHT) {
				margin = height / 20;
			} else {
				margin = width / 20;
			}
			
			//求出现在剩余多少张牌
			int count = sender.Lister.Count;
			
			int min = 0 - count / 2 * margin;
			int temp = min;
			for (int i = 0; i < count; i++) 
			{
				RX_CardManager.CreateSpriteBy (sender.Lister [i], pool, temp,this.Position);
				temp += margin;
			}
		}
コード例 #39
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Alls the is the same.
		/// </summary>
		/// <returns><c>true</c>, if is the same was alled, <c>false</c> otherwise.</returns>
		/// <param name="sender">Sender.</param>
		/// <param name="index">Index.</param>
		/// <param name="count">Count.</param>
		private static bool AllIsTheSame(RX_CardSet sender,int index,int count)
		{
			bool flag = true;

			for (int i = index; i < index + count - 1; i++) 
			{
				RX_Card l = sender.Card_lister [i];
				RX_Card r = sender.Card_lister [i + 1];

				if (l.Level != r.Level) 
				{
					flag = false;
					break;
				}
			}


			return flag;
		}
コード例 #40
0
        public RX_CardSet PopCardSet()
        {
            //FindAll 需要传入一个谓词条件....
            List <RX_Card> list = this.Card_list.FindAll((RX_Card obj) => { return(obj.IsPop); });
            //create a new cardSet,which player have selected
            RX_CardSet card_set = new RX_CardSet();

            card_set.Card_lister = list;

            //check the whether the cardSet is effect
            if (RX_CardType.IsBigBoom(card_set) ||
                RX_CardType.IsBoom(card_set) ||
                RX_CardType.IsDan(card_set) ||
                RX_CardType.IsDui(card_set) ||
                RX_CardType.IsFeijibudai(card_set) ||
                RX_CardType.IsFeijidai(card_set) ||
                RX_CardType.IsLianDui(card_set) ||
                RX_CardType.IsSanBuDai(card_set) ||
                RX_CardType.IsSandaiyi(card_set) ||
                RX_CardType.IsShunzi(card_set) ||
                RX_CardType.IsSidaier(card_set)
                )
            {
                //check can give a hand?
                if (RX_Manager.prevCardSet == null ||
                    (card_set.Card_lister.Count == RX_Manager.prevCardSet.Card_lister.Count && (int)card_set.Card_level > (int)RX_Manager.prevCardSet.Card_level && card_set.Card_type == RX_Manager.prevCardSet.Card_type) ||
                    (card_set.Card_type == RX_CARD_SET.RX_TYPE_BOOM && RX_Manager.prevCardSet.Card_type != RX_CARD_SET.RX_TYPE_BOOM && RX_Manager.prevCardSet.Card_type != RX_CARD_SET.RX_TYPE_WANGZHA) ||
                    card_set.Card_type == RX_CARD_SET.RX_TYPE_WANGZHA
                    )
                {
                    //clear previous spritePool and add the current cardsSprites to the pool
                    RX_CardManager.ClearPool();
                    UISprite[]      sprites = seat_container.GetComponentsInChildren <UISprite>();
                    List <UISprite> param   = new List <UISprite>();
                    for (int i = 0; i < sprites.Length; i++)
                    {
                        foreach (RX_Card item in card_set.Card_lister)
                        {
                            if (item.ToString() == sprites[i].name)
                            {
                                //change the sprite's parent, prevent it been destroyed
                                sprites[i].transform.SetParent(GameObject.Find("Control - Handed").transform);
                                param.Add(sprites[i]);
                                sprites[i] = new UISprite();
                                break;
                            }
                        }
                    }
                    RX_CardManager.SetHandedSprites(seat_pos, param);
                    sprites[0] = null;
                    RX_CardManager.AddPool(sprites);

                    ////RemoveAll 需要传入一个谓词条件....instantiate new cards on the screen!
                    this.Card_list.RemoveAll((RX_Card obj) => { return(obj.IsPop); });
                    //re layout after deleted the pop cards
                    this.LayoutCardList();
                    return(card_set);
                }
                return(null);
            }
            else
            {
                return(null);
            }
        }
コード例 #41
0
		public void AddCardSet(RX_CardSet sender)  
		{
			this.ListCardSet.Add(sender);
		}
コード例 #42
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if is lian dui the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is lian dui the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsLianDui(RX_CardSet sender)
		{
			if (NotNull(sender) && EffectiveNumber(sender,6,20) && CanBeDivided(sender,2)) 
			{
				//将牌型进行排序..
				CardSetSort (sender);

				//33445566

				//34556677

				//33558899

				//KKAA22

				//计算出有n对..
				int n = sender.Card_lister.Count / 2;

				//遍历n对..
				for (int i = 0; i < n; i++) 
				{
					//34556677
					if (!AllIsTheSame(sender,i * 2,2)) 
					{
						return false;
					}

					//KKAA22
					if (!IsNormal(sender,i * 2)) 
					{
						return false;
					}

					//01234567
					//33558899
					if (!IsJoined(sender,i * 2,i * 2 + 2)) {
						return false;
					}
				}

				sender.Card_type = RX_CARD_SET.RX_TYPE_LIANDUI;
				sender.Card_level = sender.Card_lister[0].Level;
				return true;
			}

			return false;
		}
コード例 #43
0
		/// <summary>
		/// Determines if is sidaier the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is sidaier the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsSidaier(RX_CardSet sender)
		{
			if (NotNull(sender) && EffectiveNumber(sender,6)) 
			{
				//paixu
				CardSetSort(sender);

				if (AllIsTheSame(sender,0,4) && !AllIsTheSame(sender,4,2)) 
				{
					sender.Typer = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Level = sender.Lister[0].Level;
					return true;
				}

				if (AllIsTheSame(sender,1,4)) {
					sender.Typer = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Level = sender.Lister[1].Level;
					return true;
				}

				if (!AllIsTheSame(sender,0,2) && AllIsTheSame(sender,2,4)) 
				{
					sender.Typer = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Level = sender.Lister[2].Level;
					return true;
				}

				return false;
			}

			if (NotNull(sender) && EffectiveNumber(sender,8)) {

				CardSetSort(sender);

				if (AllIsTheSame(sender,0,4) && !AllIsTheSame(sender,4,4) && AllIsTheSame(sender,4,2) && AllIsTheSame(sender,6,2)) 
				{
					sender.Typer = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Level = sender.Lister[0].Level;
					return true;
				}

				if (AllIsTheSame(sender,0,2) && AllIsTheSame(sender,2,2) && !AllIsTheSame(sender,0,4) && AllIsTheSame(sender,4,4)) 
				{
					sender.Typer = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Level = sender.Lister[4].Level;
					return true;
				}

				if (AllIsTheSame(sender,0,2) && AllIsTheSame(sender,2,4) && AllIsTheSame(sender,6,2)) 
				{
					sender.Typer = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Level = sender.Lister[2].Level;
					return true;
				}

				return false;
			}

			return false;
		}
コード例 #44
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		private static bool EffectiveNumber(RX_CardSet sender,int minvalue,int maxvalue)
		{
			return sender.Card_lister.Count >= minvalue && sender.Card_lister.Count <= maxvalue;
		}
コード例 #45
0
 /// <summary>
 /// Determines if can be divided the specified sender divisor.
 /// </summary>
 /// <returns><c>true</c> if can be divided the specified sender divisor; otherwise, <c>false</c>.</returns>
 /// <param name="sender">Sender.</param>
 /// <param name="divisor">Divisor.</param>
 private static bool CanBeDivided(RX_CardSet sender, int divisor)
 {
     return(sender.Card_lister.Count % divisor == 0);
 }
コード例 #46
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if is sidaier the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is sidaier the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsSidaier(RX_CardSet sender)
		{
			if (NotNull(sender) && EffectiveNumber(sender,6)) 
			{
				//paixu
				CardSetSort(sender);

				//四个不能带一对..
				if (AllIsTheSame(sender,0,4) && !AllIsTheSame(sender,4,2)) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Card_level = sender.Card_lister[0].Level;
					return true;
				}

				if (AllIsTheSame(sender,1,4)) {
					sender.Card_type = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Card_level = sender.Card_lister[1].Level;
					return true;
				}

				if (!AllIsTheSame(sender,0,2) && AllIsTheSame(sender,2,4)) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SIDAIER;

					sender.Card_level = sender.Card_lister[2].Level;
					return true;
				}

				return false;
			}

			if (NotNull(sender) && EffectiveNumber(sender,8)) {

				CardSetSort(sender);

				//四张同牌在前面,	后四张不能全一样,必须是两队..
				if (AllIsTheSame(sender,0,4) && !AllIsTheSame(sender,4,4) && AllIsTheSame(sender,4,2) && AllIsTheSame(sender,6,2)) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Card_level = sender.Card_lister[0].Level;
					return true;
				}

				if (AllIsTheSame(sender,0,2) && AllIsTheSame(sender,2,2) && !AllIsTheSame(sender,0,4) && AllIsTheSame(sender,4,4)) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Card_level = sender.Card_lister[4].Level;
					return true;
				}

				if (AllIsTheSame(sender,0,2) && AllIsTheSame(sender,2,4) && AllIsTheSame(sender,6,2)) 
				{
					sender.Card_type = RX_CARD_SET.RX_TYPE_SIDAIER;
					sender.Card_level = sender.Card_lister[2].Level;
					return true;
				}

				return false;
			}

			return false;
		}
コード例 #47
0
ファイル: RX_CardType.cs プロジェクト: applexiaohao/CardGame
		/// <summary>
		/// Determines if can be divided the specified sender divisor.
		/// </summary>
		/// <returns><c>true</c> if can be divided the specified sender divisor; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		/// <param name="divisor">Divisor.</param>
		private static bool CanBeDivided(RX_CardSet sender,int divisor)
		{
			return sender.Card_lister.Count % divisor == 0;
		}
コード例 #48
0
		/// <summary>
		/// Determines if is dui the specified sender.
		/// </summary>
		/// <returns><c>true</c> if is dui the specified sender; otherwise, <c>false</c>.</returns>
		/// <param name="sender">Sender.</param>
		public static bool IsDui(RX_CardSet sender)
		{
			if (NotNull(sender) && EffectiveNumber(sender,2) && AllIsTheSame(sender,0,2)) 
			{
				sender.Typer = RX_CARD_SET.RX_TYPE_DUI;
				sender.Level = sender.Lister [0].Level;

				return true;
			}

			return false;
		}