Esempio n. 1
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);
        }
Esempio n. 2
0
        public static UISprite CreateSpriteBy(RX_Card card, UISprite parent, float x)
        {
            float y        = card.PositionY;
            int   depthNum = (int)x;

            if (parent.tag != "cbottom")
            {
                float temp = x;
                x = y;
                y = temp;

                depthNum = -depthNum;
            }

            //crate NGUI gameObject;	                    can create gameObject -----3
            UISprite sprite = NGUITools.AddChild <UISprite>(parent.gameObject);

            //add (widget size)'s collider
            //(if we want to add an interact function to the NGUI gameObjce,we must add collider fist!)
            NGUITools.AddWidgetCollider(sprite.gameObject);

            //only add Component(button) to interact,       not create gameObject -----1
            UIButton button = NGUITools.AddMissingComponent <UIButton>(sprite.gameObject);

            sprite.depth = depthNum + 300;
            sprite.atlas = RX_Resources.DefaultResources.Card_atlas;

            sprite.spriteName = card.ToString();

            sprite.SetRect(x, y, 52f, 70f);    //the card's size changed to original 's 25%

            button.onClick.Add(new EventDelegate(() =>
            {
                card.IsPop = !card.IsPop;
                if (parent.tag == "cleft")
                {
                    sprite.SetRect(card.PositionY, y, 52f, 70f);
                }
                else if (parent.tag == "cright")
                {
                    sprite.SetRect(card.PositionY * (-1), y, 52f, 70f);
                }
                else
                {
                    sprite.SetRect(x, card.PositionY, 52f, 70f);
                }
            }));

            sprite.name = card.ToString();

            //add to the sprite pool for destroy
            Sprite_pool.Add(sprite);
            return(sprite);
        }
Esempio n. 3
0
        public static UISprite CreateSpriteBy(RX_Card card, UISprite parent, float x)
        {
            float y = card.PositionY;
            int depthNum = (int)x;
            if (parent.tag != "cbottom")
            {
                float temp = x;
                x = y;
                y = temp;

                depthNum = -depthNum;
            }

            //crate NGUI gameObject;	                    can create gameObject -----3
            UISprite sprite = NGUITools.AddChild<UISprite>(parent.gameObject);
            
            //add (widget size)'s collider
            //(if we want to add an interact function to the NGUI gameObjce,we must add collider fist!)
            NGUITools.AddWidgetCollider(sprite.gameObject);

            //only add Component(button) to interact,       not create gameObject -----1
            UIButton button = NGUITools.AddMissingComponent<UIButton>(sprite.gameObject);

            sprite.depth = depthNum + 300;
            sprite.atlas = RX_Resources.DefaultResources.Card_atlas;

            sprite.spriteName = card.ToString();

            sprite.SetRect(x, y, 52f, 70f);    //the card's size changed to original 's 25%

            button.onClick.Add(new EventDelegate(() =>
            {
                card.IsPop = !card.IsPop;
                if (parent.tag == "cleft")
                {
                    sprite.SetRect(card.PositionY, y, 52f, 70f);
                }
                else if (parent.tag == "cright")
                {
                    sprite.SetRect(card.PositionY * (-1), y, 52f, 70f);
                }
                else
                {
                    sprite.SetRect(x, card.PositionY, 52f, 70f);
                }    
            }));

            sprite.name = card.ToString();

            //add to the sprite pool for destroy
            Sprite_pool.Add(sprite);
            return sprite;
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
		public static UISprite CreateSpriteBy(RX_Card card,UISprite parent,int pp,RX_SEAT_POSITION pos)
		{			
			//创建精灵对象,通过NGUITools.AddChild函数
			UISprite sprite = NGUITools.AddChild<UISprite> (parent.gameObject);

			//为图片对象添加碰撞器...
			NGUITools.AddWidgetCollider (sprite.gameObject);

			//为一个NGUI的游戏控件,添加缺失的组件
			UIButton button = NGUITools.AddMissingComponent<UIButton> (sprite.gameObject);
	
			sprite.depth = pp + 300;
			sprite.atlas = RX_Resources.DefaultResources.CardAtlas;
			sprite.spriteName = card.ToString ();

			Rect sprite_rect = GetRect (pp,card.PositionY, pos);
			//设置NGUI控件在屏幕上的显示位置和大小
			sprite.SetRect (sprite_rect.x, sprite_rect.y, sprite_rect.width, sprite_rect.heitht);

			button.onClick.Add (new EventDelegate (() => {

				card.IsPop = !card.IsPop;
				Rect sr = GetRect (pp,card.PositionY, pos);
				sprite.SetRect(sr.x,sr.y,sr.width,sr.heitht);
				
			}));

			return sprite;
		}
Esempio n. 7
0
		public bool Equals(RX_Card sender)
		{
			return ((int)this.Name == (int)sender.Name) && ((int)this.Level == (int)sender.Level);
		}