示例#1
0
        public void CourseToCard(CardSprite card)
        {
            Vector2 p1 = new Vector2(this.position.X + this.sprite.Width / 2, this.position.Y + this.sprite.Height / 2);
            Vector2 p2 = new Vector2(card.position.X + card.sprite.Width / 2, card.position.Y + card.sprite.Height / 2);

            direction = Vector2.Normalize(new Vector2(p2.X - p1.X, p2.Y - p1.Y));
            double distance = Vector2.Distance(p1, p2);

            time = distance / speed * 1000;
        }
示例#2
0
 public override bool Equals(object obj)
 {
     if (obj is CardSprite)
     {
         CardSprite card = (CardSprite)obj;
         return(card == this);
     }
     else
     {
         throw new ArgumentException("obj is not type CardSprite.");
     }
 }
示例#3
0
 public DeckPile(CardSprite deck, CardSprite cardBack, SoundEffect shuffleEffect,
                 SoundEffect drawEffect, SoundEffect setEffect)
 {
     deckPile = new List <CardSprite>()
     {
         deck, cardBack.Clone(deck.Position), cardBack.Clone(deck.Position)
     };
     this.drawEffect    = drawEffect;
     this.shuffleEffect = shuffleEffect;
     this.setEffect     = setEffect;
     elapsedTime        = 0.0;
     isPlayer1          = false;
     this.shuffleMove   = false;
     this.numShuffles   = 0;
 }
示例#4
0
        public bool ShuffleDeck(DiscardPile discardPile)
        {
            if (deckPile.Count == 3 && (SSEngine.VersionStage != MenuStage.LAN || SSEngine.VersionStage != MenuStage.Online ||
                                        SSEngine.Player1 != SSEngine.Player1First))
            {
                Random            random       = new Random();
                List <CardSprite> shuffledDeck = new List <CardSprite>();

                while (discardPile.Count > 1)
                {
                    CardSprite card = discardPile[random.Next(0, discardPile.Count - 1)];
                    discardPile.Remove(card);
                    shuffledDeck.Add(card);
                }

                deckPile.AddRange(shuffledDeck);

                if (SSEngine.VersionStage == MenuStage.LAN)
                {
                    byte[] data = new byte[2 * (deckPile.Count - 3) + 1];
                    data[0] = (byte)NetGame.Shuffle;
                    for (int i = 3, j = 1; j < data.Length - 1; i++, j += 2)
                    {
                        data[j]     = (byte)deckPile[i].Rank;
                        data[j + 1] = (byte)deckPile[i].CardSuit;
                    }
                    SSEngine.LANClient.Send(data);
                }
                else if (SSEngine.VersionStage == MenuStage.Online)
                {
                    NetOutgoingMessage msg = SSEngine.Peer.CreateMessage();
                    msg.Write((byte)NetGame.Shuffle);
                    msg.Write((byte)(2 * (deckPile.Count - 3)));
                    byte[] data = new byte[2 * (deckPile.Count - 3)];
                    for (int i = 3, j = 0; j < data.Length - 1; i++, j += 2)
                    {
                        data[j]     = (byte)deckPile[i].Rank;
                        data[j + 1] = (byte)deckPile[i].CardSuit;
                    }
                    msg.Write(data);
                    SSEngine.Peer.SendMessage(msg, SSEngine.Peer.Connections[0], NetDeliveryMethod.ReliableOrdered);
                }
                return(true);
            }
            return(false);
        }
示例#5
0
        private void ability(CardSprite card)
        {
            if (numHaveSet == 1 && card.Rank == RankValue.Three &&
                discardPile[discardPile.Count - 2].Rank == RankValue.Three)
            {
                changedSuit = card.CardSuit;
                cardAblities(card);
                numTotalSets++;
                numExtraDraws++;
                return;
            }

            if (card.Rank == discardPile[discardPile.Count - 2].Rank)
            {
                if (discardPile.Count > 3 &&
                    card.Rank == discardPile[discardPile.Count - 4].Rank &&
                    card.Rank == discardPile[discardPile.Count - 3].Rank)
                {
                    numSameRank = 3;
                }
                else if (discardPile.Count > 2 &&
                         card.Rank == discardPile[discardPile.Count - 3].Rank)
                {
                    numSameRank = 2;
                }
                else
                {
                    numSameRank = 1;
                }

                changedSuit = card.CardSuit;
                cardAblities(card);
            }

            else if (card.CardSuit == changedSuit ||
                     card.Rank == RankValue.Eight)
            {
                numSameRank = 0;
                cardAblities(card);
            }
        }
示例#6
0
        private void cardAblities(CardSprite cardPrint)
        {
            if (cardPrint.Rank == RankValue.Ace)
            {
                rankRules();
                if (cardPrint.CardSuit == Suit.Club)
                {
                    changedSuit = Suit.Spades;
                }
                else if (cardPrint.CardSuit == Suit.Spades)
                {
                    changedSuit = Suit.Club;
                }
                else if (cardPrint.CardSuit == Suit.Hearts)
                {
                    changedSuit = Suit.Diamond;
                }
                else if (cardPrint.CardSuit == Suit.Diamond)
                {
                    changedSuit = Suit.Hearts;
                }
            }
            else if (cardPrint.Rank == RankValue.Deuce)
            {
                if (discardPile.DiscardList.Count > 1)
                {
                    if (discardPile[discardPile.Count - 2] == SSEngine.DeckSprites["QueenSpades"] &&
                        cardPrint.CardSuit == Suit.Spades)
                    {
                        rankSpade2Rules();
                    }
                    else if (discardPile[discardPile.Count - 2].Rank != RankValue.Three)
                    {
                        rank2Rules();
                    }
                    else if (discardPile[discardPile.Count - 2].Rank == RankValue.Three &&
                             SSEngine.Player1First != SSEngine.Player1SetThree)
                    {
                        rank2Rules();
                        SSEngine.Player1SetThree = null;
                    }

                    // Your deuce card ablity is negated if none of these statements are true.
                }
                else
                {
                    rank2Rules();
                }
            }

            else if (cardPrint.Rank == RankValue.Three)
            {
                if (discardPile.Count > 3 && discardPile[discardPile.Count - 3].Rank == RankValue.Three &&
                    discardPile[discardPile.Count - 4].Rank == RankValue.Three)
                {
                    numTotalSets++;
                    numExtraDraws++;
                }
                else if (discardPile.Count > 2 && discardPile[discardPile.Count - 2].Rank == RankValue.Three &&
                         discardPile[discardPile.Count - 3].Rank == RankValue.Three)
                {
                    numTotalSets++;
                    numExtraDraws++;
                }
                else if (discardPile.Count > 1 && discardPile[discardPile.Count - 1].Rank == RankValue.Three &&
                         discardPile[discardPile.Count - 2].Rank == RankValue.Three)
                {
                    numTotalSets++;
                    numExtraDraws++;
                }
                else
                {
                    numTotalSets  += 2;
                    numExtraDraws += 2;
                }
                SSEngine.Player1SetThree = SSEngine.Player1First;
            }
            else if (cardPrint.Rank == RankValue.Four)
            {
                if (discardPile.Count > 1)
                {
                    if (discardPile[discardPile.Count - 2].Rank != RankValue.Three)
                    {
                        numTotalSets++;
                        numExtraDraws++;
                    }
                    else if (discardPile[discardPile.Count - 2].Rank == RankValue.Three &&
                             SSEngine.Player1First != SSEngine.Player1SetThree)
                    {
                        numTotalSets++;
                        numExtraDraws++;
                        SSEngine.Player1SetThree = null;
                    }
                    // If none of these statements are true Card 4 ability negated.
                }
                else
                {
                    numTotalSets++;
                    numExtraDraws++;
                }
            }
            else if (cardPrint.Rank == RankValue.Five)
            {
                rankRules();
            }
            else if (cardPrint.Rank == RankValue.Six)
            {
                rankRules();
            }
            else if (cardPrint.Rank == RankValue.Seven)
            {
                rankRules();
            }
            else if (cardPrint.Rank == RankValue.Eight)
            {
                rankRules();
                gameState = GameStage.EightAbility;
            }
            else if (cardPrint.Rank == RankValue.Nine)
            {
                rankRules();
            }
            else if (cardPrint.Rank == RankValue.Ten)
            {
                rankRules();
            }
            else if (cardPrint.Rank == RankValue.Jack)
            {
                rankRules();
            }
            else if (cardPrint.Rank == RankValue.Queen)
            {
                rankRules();
                bool queenNeg = false;
                if (discardPile.Count > 1 && discardPile[discardPile.Count - 2].Rank == RankValue.Three &&
                    cardPrint.CardSuit == Suit.Spades && SSEngine.Player1First == SSEngine.Player1SetThree)
                {
                    // The Queen Of Spades is negated.
                    queenNeg = true;
                    SSEngine.Player1SetThree = null;
                }
                if (cardPrint.CardSuit == Suit.Spades && !queenNeg)
                {
                    numDraws  = 5;
                    gameState = GameStage.Draw;
                }
            }
            else if (cardPrint.Rank == RankValue.King)
            {
                rankRules();
            }
        }
示例#7
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            SSEngine.DeckSprites["AceClub"]      = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/AceClub"), RankValue.Ace, Suit.Club);
            SSEngine.DeckSprites["AceDiamond"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/AceDiamond"), RankValue.Ace, Suit.Diamond);
            SSEngine.DeckSprites["AceHearts"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/AceHearts"), RankValue.Ace, Suit.Hearts);
            SSEngine.DeckSprites["AceSpades"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/AceSpades"), RankValue.Ace, Suit.Spades);
            SSEngine.DeckSprites["DeuceClub"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/DeuceClub"), RankValue.Deuce, Suit.Club);
            SSEngine.DeckSprites["DeuceDiamond"] = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/DeuceDiamond"), RankValue.Deuce, Suit.Diamond);
            SSEngine.DeckSprites["DeuceHearts"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/DeuceHearts"), RankValue.Deuce, Suit.Hearts);
            SSEngine.DeckSprites["DeuceSpades"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/DeuceSpades"), RankValue.Deuce, Suit.Spades);
            SSEngine.DeckSprites["ThreeClub"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/ThreeClub"), RankValue.Three, Suit.Club);
            SSEngine.DeckSprites["ThreeDiamond"] = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/ThreeDiamond"), RankValue.Three, Suit.Diamond);
            SSEngine.DeckSprites["ThreeHearts"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/ThreeHearts"), RankValue.Three, Suit.Hearts);
            SSEngine.DeckSprites["ThreeSpades"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/ThreeSpades"), RankValue.Three, Suit.Spades);
            SSEngine.DeckSprites["FourClub"]     = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/FourClub"), RankValue.Four, Suit.Club);
            SSEngine.DeckSprites["FourDiamond"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/FourDiamond"), RankValue.Four, Suit.Diamond);
            SSEngine.DeckSprites["FourHearts"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/FourHearts"), RankValue.Four, Suit.Hearts);
            SSEngine.DeckSprites["FourSpades"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/FourSpades"), RankValue.Four, Suit.Spades);
            SSEngine.DeckSprites["FiveClub"]     = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/FiveClub"), RankValue.Five, Suit.Club);
            SSEngine.DeckSprites["FiveDiamond"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/FiveDiamond"), RankValue.Five, Suit.Diamond);
            SSEngine.DeckSprites["FiveHearts"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/FiveHearts"), RankValue.Five, Suit.Hearts);
            SSEngine.DeckSprites["FiveSpades"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/FiveSpades"), RankValue.Five, Suit.Spades);
            SSEngine.DeckSprites["SixClub"]      = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/SixClub"), RankValue.Six, Suit.Club);
            SSEngine.DeckSprites["SixDiamond"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/SixDiamond"), RankValue.Six, Suit.Diamond);
            SSEngine.DeckSprites["SixHearts"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/SixHearts"), RankValue.Six, Suit.Hearts);
            SSEngine.DeckSprites["SixSpades"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/SixSpades"), RankValue.Six, Suit.Spades);
            SSEngine.DeckSprites["SevenClub"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/SevenClub"), RankValue.Seven, Suit.Club);
            SSEngine.DeckSprites["SevenDiamond"] = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/SevenDiamond"), RankValue.Seven, Suit.Diamond);
            SSEngine.DeckSprites["SevenHearts"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/SevenHearts"), RankValue.Seven, Suit.Hearts);
            SSEngine.DeckSprites["SevenSpades"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/SevenSpades"), RankValue.Seven, Suit.Spades);
            SSEngine.DeckSprites["EightClub"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/EightClub"), RankValue.Eight, Suit.Club);
            SSEngine.DeckSprites["EightDiamond"] = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/EightDiamond"), RankValue.Eight, Suit.Diamond);
            SSEngine.DeckSprites["EightHearts"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/EightHearts"), RankValue.Eight, Suit.Hearts);
            SSEngine.DeckSprites["EightSpades"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/EightSpades"), RankValue.Eight, Suit.Spades);
            SSEngine.DeckSprites["NineClub"]     = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/NineClub"), RankValue.Nine, Suit.Club);
            SSEngine.DeckSprites["NineDiamond"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/NineDiamond"), RankValue.Nine, Suit.Diamond);
            SSEngine.DeckSprites["NineHearts"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/NineHearts"), RankValue.Nine, Suit.Hearts);
            SSEngine.DeckSprites["NineSpades"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/NineSpades"), RankValue.Nine, Suit.Spades);
            SSEngine.DeckSprites["TenClub"]      = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/TenClub"), RankValue.Ten, Suit.Club);
            SSEngine.DeckSprites["TenDiamond"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/TenDiamond"), RankValue.Ten, Suit.Diamond);
            SSEngine.DeckSprites["TenHearts"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/TenHearts"), RankValue.Ten, Suit.Hearts);
            SSEngine.DeckSprites["TenSpades"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/TenSpades"), RankValue.Ten, Suit.Spades);
            SSEngine.DeckSprites["JackClub"]     = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/JackClub"), RankValue.Jack, Suit.Club);
            SSEngine.DeckSprites["JackDiamond"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/JackDiamond"), RankValue.Jack, Suit.Diamond);
            SSEngine.DeckSprites["JackHearts"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/JackHearts"), RankValue.Jack, Suit.Hearts);
            SSEngine.DeckSprites["JackSpades"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/JackSpades"), RankValue.Jack, Suit.Spades);
            SSEngine.DeckSprites["QueenClub"]    = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/QueenClub"), RankValue.Queen, Suit.Club);
            SSEngine.DeckSprites["QueenDiamond"] = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/QueenDiamond"), RankValue.Queen, Suit.Diamond);
            SSEngine.DeckSprites["QueenHearts"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/QueenHearts"), RankValue.Queen, Suit.Hearts);
            SSEngine.DeckSprites["QueenSpades"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/QueenSpades"), RankValue.Queen, Suit.Spades);
            SSEngine.DeckSprites["KingClub"]     = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/KingClub"), RankValue.King, Suit.Club);
            SSEngine.DeckSprites["KingDiamond"]  = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/KingDiamond"), RankValue.King, Suit.Diamond);
            SSEngine.DeckSprites["KingHearts"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/KingHearts"), RankValue.King, Suit.Hearts);
            SSEngine.DeckSprites["KingSpades"]   = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/KingSpades"), RankValue.King, Suit.Spades);

            CardSprite cardBack        = new CardSprite(Game.Content.Load <Texture2D>(@"DeckOfCards/CardBack"));
            Vector2    discardPosition = new Vector2(3 * SSEngine.QuarterSceenWidth - 2 * cardBack.Texture.Width,
                                                     2 * SSEngine.QuarterSceenHeight - cardBack.Texture.Height / 2);
            CardSprite discardpileSprite = new CardSprite(Game.Content.Load <Texture2D>("DiscardPile"), discardPosition);

            discardPile  = new DiscardPile(discardpileSprite);
            deckPosition = new Vector2(3 * SSEngine.QuarterSceenWidth - discardpileSprite.Texture.Width / 2,
                                       2 * SSEngine.QuarterSceenHeight - discardpileSprite.Texture.Height / 2);
            CardSprite  deckSprite = new CardSprite(Game.Content.Load <Texture2D>("DeckPile"), deckPosition);
            SoundEffect setSound   = Game.Content.Load <SoundEffect>(@"Audio\CardSet");

            deckPile = new DeckPile(deckSprite, cardBack, Game.Content.Load <SoundEffect>(@"Audio\CardShuffle"),
                                    Game.Content.Load <SoundEffect>(@"Audio\DrawCard"), setSound);
            deckPile.ShuffleDeck();
            playerCards1 = new PlayerHand(Game.Content.Load <Texture2D>(@"Hand\ArrowButtonL"),
                                          Game.Content.Load <Texture2D>(@"Hand\ArrowButtonCoverL"), Game.Content.Load <Texture2D>(@"Hand\ArrowButtonR"),
                                          Game.Content.Load <Texture2D>(@"Hand\ArrowButtonCoverR"), cardBack.Texture, setSound);
            playerCards2 = new AIHand(cardBack.Texture, setSound);
            font         = Game.Content.Load <SpriteFont>(@"Fonts\GameFont");
            Texture2D overlay = Game.Content.Load <Texture2D>(@"Buttons\backBtnCover");

            backButton    = new SSButton(Game.Content.Load <Texture2D>(@"Buttons\SuitBackButton"), new Vector2(20f, 20f), overlay, MenuStage.Play);
            overlay       = Game.Content.Load <Texture2D>(@"Buttons\ButtonCover");
            endTurnButton = new Button(Game.Content.Load <Texture2D>(@"Buttons\SuitEndTurnButton"),
                                       new Vector2(3 * SSEngine.QuarterSceenWidth + discardpileSprite.Texture.Width,
                                                   2 * SSEngine.QuarterSceenHeight - overlay.Height / 2), overlay);
            panel = new SelectPanel(Game.Content, "Change To");
            base.LoadContent();
        }
示例#8
0
 public void Remove(CardSprite card)
 {
     discardPile.Remove(card);
 }
示例#9
0
 public DiscardPile(CardSprite sprite)
 {
     discardPile  = new List <CardSprite>();
     discardPanel = sprite;
 }