Ejemplo n.º 1
0
        private void CardBackClickHandler(object Sender, MouseButton Button)
        {
            ShownCard NewCard;

            if ((cDeckShuffleIndex >= cDeckShuffleList.Count) || (cDeckShuffleIndex < 0))
            {
                ShuffleCompleteDeck(false, true);
            }
            else
            {
                NewCard = new ShownCard();

                NewCard.DrawRegion   = new Rectangle(0, 0, 100, 100);
                NewCard.TextureIndex = cDeckShuffleList[cDeckShuffleIndex];
                cCardsShownList.Add(NewCard);

                cDeckShuffleIndex += 1;
                HasChanged         = true;

                while ((cCardsShownList.Count > MaxCardsShown) && (MaxCardsShown > 0))
                {
                    cCardsShownList.RemoveAt(0);
                }
            }

            if (cDeckShuffleIndex >= cDeckShuffleList.Count)
            {
                cCardBackCtrl.Text = "Shuffle";
            }
            else if (cDeckShuffleIndex == -1)
            {
                cCardBackCtrl.Text = "No Cards";
            }
            else
            {
                cCardBackCtrl.Text = "";
            }

            HasChanged = true;
        }
Ejemplo n.º 2
0
		private void CardBackClickHandler(object Sender, MouseButton Button) {
			ShownCard NewCard;

			if ((cDeckShuffleIndex >= cDeckShuffleList.Count) || (cDeckShuffleIndex < 0)) {
				ShuffleCompleteDeck(false, true);
			} else {
				NewCard = new ShownCard();

				NewCard.DrawRegion = new Rectangle(0, 0, 100, 100);
				NewCard.TextureIndex = cDeckShuffleList[cDeckShuffleIndex];
				cCardsShownList.Add(NewCard);

				cDeckShuffleIndex += 1;
				HasChanged = true;

				while ((cCardsShownList.Count > MaxCardsShown) && (MaxCardsShown > 0)) {
					cCardsShownList.RemoveAt(0);
				}
			}

			if (cDeckShuffleIndex >= cDeckShuffleList.Count) {
				cCardBackCtrl.Text = "Shuffle";
			} else if (cDeckShuffleIndex == -1) {
				cCardBackCtrl.Text = "No Cards";
			} else {
				cCardBackCtrl.Text = "";
			}

			HasChanged = true;
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Update all information use by this control in response to time passage or user input
        /// </summary>
        /// <param name="CurrTime">Current time information of the game</param>
        /// <param name="CurrKeyboard">Current state of the keyboard</param>
        /// <param name="CurrMouse">Current state of the mouse</param>
        protected override void UpdateContents(GameTime CurrTime, KeyboardState CurrKeyboard, MouseState CurrMouse, bool ProcessMouseEvent)
        {
            int       MarginVert, MarginHoriz, CardHeight, CardWidth, FontHeight;
            Rectangle CurrCardRegion;

            MarginVert  = (int)(ClientRegion.Width * MarginPercent);
            MarginHoriz = (int)(ClientRegion.Height * MarginPercent);
            CardWidth   = (int)(ClientRegion.Width * CardWidthPercent);
            CardHeight  = (int)(CardWidth / CardRatio);
            FontHeight  = (int)(CardHeight * DEFAULT_FONTPERCENT);

            //Update the card back, draw deck, control
            if (cCardBackCtrl.Top != MarginVert)
            {
                cCardBackCtrl.Top  = MarginVert;
                cCardBackCtrl.Left = MarginHoriz;
                HasChanged         = true;
            }

            if (cCardBackCtrl.Width != CardWidth)
            {
                cCardBackCtrl.Width  = CardWidth;
                cCardBackCtrl.Height = CardHeight;
                HasChanged           = true;
            }

            if (cCardBackCtrl.Font.CharacterHeight != FontHeight)
            {
                cCardBackCtrl.FontSize = FontHeight;
            }

            cCardBackCtrl.Update(CurrTime, CurrKeyboard, CurrMouse, !SelectedCardIsZoomed);

            if (cCardsShownList.Count > 0)
            {
                //Update all of the face card, shown cards, controls
                CurrCardRegion.Y      = MarginVert;
                CurrCardRegion.X      = CardWidth + (MarginHoriz * 2);
                CurrCardRegion.Height = CardHeight;
                CurrCardRegion.Width  = CardWidth;

                //Determine spacing between cards

                if (cCardsShownList.Count > 1)
                {
                    CardHeight  = ClientRegion.Height - ((MarginHoriz * 2) + CardHeight);
                    CardHeight /= cCardsShownList.Count - 1;
                }
                else
                {
                    CardHeight = MarginHoriz + CurrCardRegion.Height;
                }

                if (CardHeight > MarginHoriz + CurrCardRegion.Height)
                {
                    CardHeight = MarginHoriz + CurrCardRegion.Height;
                }

                for (int Ctr = 0; Ctr < cCardsShownList.Count; Ctr++)
                {
                    ShownCard CurrCard = cCardsShownList[Ctr];

                    if ((Ctr == SelectedCardIndex) && ((cZoomAnimPercent < 100) || (SelectedCardIsZoomed == true)))
                    {
                        CurrCard.DrawRegion = DetermineZoomCardRegion(CurrTime.ElapsedGameTime.Milliseconds, CurrCardRegion);
                        HasChanged          = true;
                    }
                    else
                    {
                        CurrCard.DrawRegion.Y      = CurrCardRegion.Y;
                        CurrCard.DrawRegion.X      = CurrCardRegion.X;
                        CurrCard.DrawRegion.Height = CurrCardRegion.Height;
                        CurrCard.DrawRegion.Width  = CurrCardRegion.Width;
                    }

                    cCardsShownList[Ctr] = CurrCard;

                    CurrCardRegion.Y += CardHeight;
                }

                if (cCardRemoved == true)
                {
                    HasChanged   = true;
                    cCardRemoved = false;
                }
            }
        }