Beispiel #1
0
        public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Green);

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
            backButton.Draw(spriteBatch);
            if (numExtraDraws == 0 && SSEngine.Player1First == SSEngine.Player1 && gameState == GameStage.Run)
            {
                endTurnButton.Draw(spriteBatch);
            }
            string  text     = "Suit: " + changedSuit.ToString();
            Vector2 position = new Vector2(SSEngine.QuarterSceenWidth / 2 - font.MeasureString(text).X / 2,
                                           2 * SSEngine.QuarterSceenHeight - font.MeasureString(text).Y / 2);

            spriteBatch.DrawString(font, text, position, Color.Black);
            text = "Turn: " + (SSEngine.Player1First ? "Player 1" : "Player 2");
            spriteBatch.DrawString(font, text, new Vector2(position.X, position.Y + font.MeasureString(text).Y), Color.Black);
            text = "Sets Left: " + numTotalSets;
            spriteBatch.DrawString(font, text, new Vector2(position.X, position.Y + 2 * font.MeasureString(text).Y), Color.Black);
            if (cardAbility != String.Empty)
            {
                spriteBatch.DrawString(font, cardAbility, new Vector2(position.X + 7 * font.MeasureString(text).X / 5,
                                                                      position.Y), Color.Black, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
            }
            discardPile.DrawDiscardPile(spriteBatch);
            if (gameState != GameStage.Shuffle && gameState != GameStage.ReShuffle)
            {
                deckPile.DrawDeckPile(spriteBatch);
                text = (deckPile.Deck.Count - 3).ToString();
                spriteBatch.DrawString(font, text,
                                       new Vector2(deckPile.Deck[0].Position.X + deckPile.Deck[0].Texture.Width / 2 - font.MeasureString(text).X / 2,
                                                   deckPile.Deck[0].Position.Y + deckPile.Deck[0].Texture.Height / 2 - font.MeasureString(text).Y / 2),
                                       Color.Black, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.75f);
            }
            else
            {
                deckPile.DrawShuffleDeck(spriteBatch);
            }
            playerCards1.DrawHand(spriteBatch);
            playerCards2.DrawHand(spriteBatch);
            if (gameState == GameStage.EightAbility && SSEngine.Player1First == SSEngine.Player1)
            {
                panel.DrawPanel(spriteBatch);
            }
            else if (gameState == GameStage.End)
            {
                text = "The Winner is: " + (playerCards1.Count <= 0 || SSEngine.Disconnected ? (SSEngine.Player1 == true
                    ? "Player1" : "Player2") : (SSEngine.Player1 == true ? "Player2" : "Player1")) + "\n(Press Enter)";
                spriteBatch.DrawString(font, text, new Vector2(2 * SSEngine.QuarterSceenWidth -
                                                               2 * font.MeasureString(text).X / 3, 2 * SSEngine.QuarterSceenHeight - font.MeasureString(text).Y / 2),
                                       Color.Black);
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
Beispiel #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();
            spriteBatch.Draw(menu,
                             new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), Color.White);
            spriteBatch.Draw(title, new Vector2(Window.ClientBounds.Width / 2 - title.Width / 2, 0), Color.White);

            switch (menuStage)
            {
            case MenuStage.SplashScreen:
                spriteBatch.Draw(splashScreen, new Rectangle(0, 0,
                                                             (int)(SSEngine.QuarterSceenWidth * 4), (int)(SSEngine.QuarterSceenHeight * 4)), Color.White);
                break;

            case MenuStage.MainMenu:
                DrawButtons(spriteBatch, mainButtons);
                spriteBatch.Draw(developed, new Vector2(0, 0), Color.White);
                break;

            case MenuStage.Play:
                DrawButtons(spriteBatch, playButtons); break;

            case MenuStage.TwoPlayer:
                DrawButtons(spriteBatch, twoPlayerBtns); break;

            case MenuStage.Connect:
                backButton.Draw(spriteBatch);
                string wait = "Waiting";
                spriteBatch.DrawString(spriteFont, wait,
                                       new Vector2(2 * quarterScreenW - spriteFont.MeasureString(wait).X / 2,
                                                   2 * quarterScreenH - spriteFont.MeasureString(wait).Y / 2), Color.Black);
                break;

            case MenuStage.RockPaperScissors:
                string player;
                Color  color;
                if (SSEngine.Player1.Value)
                {
                    player = "Player1";
                    color  = Color.Red;
                }
                else
                {
                    player = "Player2";
                    color  = Color.Blue;
                }
                DrawButtons(spriteBatch, rocPapSciBtns);
                spriteBatch.DrawString(spriteFont, player,
                                       new Vector2(2 * quarterScreenW - spriteFont.MeasureString(player).X / 2,
                                                   3 * quarterScreenH - spriteFont.MeasureString(player).Y / 2), color);
                break;

            case MenuStage.RockPaperScissorsWait:
                backButton.Draw(spriteBatch);
                string waitShot = "Waiting For Shot";
                spriteBatch.DrawString(spriteFont, waitShot,
                                       new Vector2(2 * quarterScreenW - spriteFont.MeasureString(waitShot).X / 2,
                                                   2 * quarterScreenH - spriteFont.MeasureString(waitShot).Y / 2), Color.Black);
                break;

            case MenuStage.RockPaperScissorsPlaced:
                Texture2D player1 = GetRockPaperScissorsImage(playerOne);
                Texture2D player2 = GetRockPaperScissorsImage(playerTwo);
                if (player1 != null && player2 != null)
                {
                    string  text = "Player1";
                    Vector2 pos  = new Vector2(quarterScreenW * 5 / 4 - spriteFont.MeasureString(text).X / 2,
                                               quarterScreenH / 2 - spriteFont.MeasureString(text).Y / 2);
                    spriteBatch.DrawString(spriteFont, text, pos, Color.Red);
                    spriteBatch.Draw(player1, new Vector2(pos.X, pos.Y + quarterScreenH / 2), Color.White);
                    text = "Player2";
                    pos  = new Vector2(pos.X + title.Width, pos.Y);
                    spriteBatch.DrawString(spriteFont, text, pos, Color.Blue);
                    spriteBatch.Draw(player2, new Vector2(pos.X, pos.Y + quarterScreenH / 2), Color.White);
                    if (playerOne == playerTwo)
                    {
                        text = "Draw, Press Enter to try again!";
                    }
                    else if (SSEngine.Player1First)
                    {
                        text = "Player1 goes first!\n(Press Enter to start the game).";
                    }
                    else
                    {
                        text = "Player2 goes first!\n(Press Enter to start the game).";
                    }
                    pos = new Vector2(quarterScreenW * 2 - spriteFont.MeasureString(text).X / 2, 2 * quarterScreenH);
                    spriteBatch.DrawString(spriteFont, text, pos, Color.Magenta);
                }
                else
                {
                    DrawButtons(spriteBatch, rocPapSciBtns);
                }
                break;

            case MenuStage.WaitToPlay:
                string waitToPlay = "Waiting For Other Player.";
                spriteBatch.DrawString(spriteFont, waitToPlay,
                                       new Vector2(2 * quarterScreenW - spriteFont.MeasureString(waitToPlay).X / 2,
                                                   2 * quarterScreenH - spriteFont.MeasureString(waitToPlay).Y / 2), Color.Black);
                break;

            case MenuStage.InGame:
                break;

            case MenuStage.GameRules:
                spriteBatch.Draw(rules, new Vector2(2 * quarterScreenW - rules.Width / 2,
                                                    2 * quarterScreenH - rules.Height * 0.45f), Color.White);
                DrawButtons(spriteBatch, gameRulesBtns); break;

            case MenuStage.Settings:
                DrawButtons(spriteBatch, settingsBtns); break;
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }