AssemblyCSharp.RX_CardType.IsFeijidai C# (CSharp) Méthode

IsFeijidai() public static méthode

Determines if is feijidai the specified sender.
public static IsFeijidai ( RX_CardSet sender ) : bool
sender RX_CardSet Sender.
Résultat bool
		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;
		}

Usage Example

Exemple #1
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);
            }
        }