private void UpdateUi() { var nameLabel = (Label)this.Controls.Find("nameLabel", true).First(); nameLabel.Text = CardName; _globalToolTip.SetToolTip(nameLabel, CardName); var pointsLabel = (Label)this.Controls.Find("pointsLabel", true).First(); pointsLabel.Text = CardPoints.ToString(); this.BackColor = CardTypesUtilities.GetColor(CardType); }
// Use this for initialization public void AssignCard(CardInfoType cardInfoType, CardPoints cardPoints) { this.cardInfoType = cardInfoType; this.cardPoints = cardPoints; string[] cardInfo = cardInfoType.ToString().Split('_'); cardType = (CardType)System.Enum.Parse(typeof(CardType), cardInfo[0], true); switch (cardPoints) { case CardPoints.One: points = 1; break; case CardPoints.Two: points = 2; break; case CardPoints.Three: points = 3; break; case CardPoints.Four: points = 4; break; case CardPoints.Five: points = 5; break; case CardPoints.Six: points = 6; break; case CardPoints.Seven: points = 7; break; case CardPoints.Eight: points = 8; break; case CardPoints.Nine: points = 9; break; default: points = 10; break; } Sprite sprite = null; switch (cardType) { case CardType.Club: sprite = CardsManager.instance.cardsClub[(int)cardPoints]; break; case CardType.Diamond: sprite = CardsManager.instance.cardsDiamond[(int)cardPoints]; break; case CardType.Heart: sprite = CardsManager.instance.cardsHeart[(int)cardPoints]; break; case CardType.Spade: sprite = CardsManager.instance.cardsSpade[(int)cardPoints]; break; } if (imgIcon != null) { imgIcon.sprite = sprite; } }
private void GenerateDeck() { for (int suit = 0, cardID = 0; suit < Enum.GetValues(typeof(CardSuit)).Length; suit++) { for (int name = 0; name < Enum.GetValues(typeof(CardName)).Length; name++) { CardSuit cardSuit = (CardSuit)Enum.GetValues(typeof(CardSuit)).GetValue(suit); CardName cardName = (CardName)Enum.GetValues(typeof(CardName)).GetValue(name); CardPoints cardPoints = GetPoints(cardName); Card card = new Card(cardSuit, cardName, cardPoints); card.Identifier = new IDType(cardID); deck.Add(new IDType(cardID), card); cardID++; } } }
public void GetPoints() { CardPoints.GetPoints(); }
public Card(Suits suit, CardPoints point) { Suit = suit; CardPoint = point; }
public Card(CardSuit cardSuit, CardName cardName, CardPoints cardPoints) { Suit = cardSuit; Name = cardName; Points = cardPoints; }
private void BuildCard(CardTypes cardType) { BuildMenu(); var cardBodyLayout = new FlowLayoutPanel { FlowDirection = FlowDirection.TopDown, Dock = DockStyle.Fill, ContextMenuStrip = contextMenu, }; cardBodyLayout.MouseDown += CardBodyLayout_MouseDown; this.BorderStyle = BorderStyle.FixedSingle; SetBackColor(this, cardType); this.Margin = new Padding(10, 20, 10, 10); this.Width = 240; this.Height = 120; //Id var IdLabel = new Label() { Text = CardId.ToString(), Width = 25, BorderStyle = BorderStyle.None }; cardBodyLayout.Controls.Add(IdLabel); //Name row var nameLabel = new Label { Text = CardName, Width = 200, BorderStyle = BorderStyle.None, Name = "nameLabel", }; _globalToolTip.SetToolTip(nameLabel, CardName); cardBodyLayout.Controls.Add(nameLabel); var propertiesLayout = new FlowLayoutPanel() { FlowDirection = FlowDirection.LeftToRight, Size = new Size(200, 30) }; var pointsLabel = new Label() { Text = "Points: ", Width = 40 }; propertiesLayout.Controls.Add(pointsLabel); var pointsValue = new Label() { Text = CardPoints.ToString(), Width = 25, Name = "pointsLabel" }; propertiesLayout.Controls.Add(pointsValue); var controlsLayout = new FlowLayoutPanel { Size = new Size(235, 30), FlowDirection = FlowDirection.RightToLeft }; var editButton = new Button() { Text = "Edit" }; editButton.Click += EditButton_Click; var viewButton = new Button() { Text = "View" }; viewButton.Click += ViewButton_Click; controlsLayout.Controls.Add(editButton); controlsLayout.Controls.Add(viewButton); cardBodyLayout.Controls.Add(propertiesLayout); cardBodyLayout.Controls.Add(controlsLayout); this.Controls.Add(cardBodyLayout); }