/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // create the deck object and shuffle Deck deck = new Deck(Content, 0, 0); deck.Shuffle(); // create the player hands and fully deal the deck into the hands for(int i = 0; i < 3;i ++ )/*while (deck.Empty != true)*/ { player1.AddCard(deck.TakeTopCard()); if (deck.Empty != true) { player2.AddCard(deck.TakeTopCard()); } } // create the player battle piles wbp1 = new WarBattlePile(400, 200); wbp2 = new WarBattlePile(400, 400); // create the player winner messages wmessage1 = new WinnerMessage(Content, 600, 100); wmessage2 = new WinnerMessage(Content,600,500); // create the menu buttons quitbutton = new MenuButton(Content, "quitbutton", 180, 450,GameState.Quit); flipbutton = new MenuButton(Content, "flipbutton", 180, 150,GameState.Flip); collectwinningsbutton = new MenuButton(Content, "collectwinningsbutton", 180, 300, GameState.CollectWinnings); // initialized the menu buttons collectwinningsbutton.Visible = false; flipbutton.Visible = true; quitbutton.Visible = true; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // create the deck object and shuffle Deck deck = new Deck(Content, 100, 100); deck.Shuffle(); // create the player hands and fully deal the deck into the hands playerOneHand = new WarHand(WINDOW_WIDTH / 2, 100); playerTwoHand = new WarHand(WINDOW_WIDTH / 2, WINDOW_HEIGHT - 100); for (int i = 0; i < 2; i++) { playerOneHand.AddCard(deck.TakeTopCard()); playerTwoHand.AddCard(deck.TakeTopCard()); } // create the player battle piles playerOneBP = new WarBattlePile(WINDOW_WIDTH / 2, 200); playerTwoBP = new WarBattlePile(WINDOW_WIDTH / 2, WINDOW_HEIGHT - 200); // create the player winner messages playerOneWM = new WinnerMessage(Content, WINDOW_WIDTH / 2 + 150, 100); playerTwoWM = new WinnerMessage(Content, WINDOW_WIDTH / 2 + 150, WINDOW_HEIGHT - 100); // create the menu buttons flipButton = new MenuButton(Content, "flipbutton", 150, 150, GameState.Flip); quitButton = new MenuButton(Content, "quitbutton", 150, 450, GameState.Quit); collectWinnings = new MenuButton(Content, "collectwinningsbutton", 150, 300, GameState.CollectWinnings); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // create and shuffle deck deck = new Deck(Content, 0, 0); deck.Shuffle(); // first player card playerHand.Add(deck.TakeTopCard()); playerHand.ElementAt(0).X = HORIZONTAL_CARD_OFFSET; playerHand.ElementAt(0).Y = TOP_CARD_OFFSET; playerHand.ElementAt(0).FlipOver(); // first dealer card dealerHand.Add(deck.TakeTopCard()); dealerHand.ElementAt(0).X = WINDOW_WIDTH - HORIZONTAL_CARD_OFFSET; dealerHand.ElementAt(0).Y = TOP_CARD_OFFSET; // second player card playerHand.Add(deck.TakeTopCard()); playerHand.ElementAt(1).X = HORIZONTAL_CARD_OFFSET; playerHand.ElementAt(1).Y = TOP_CARD_OFFSET + VERTICAL_CARD_SPACING; playerHand.ElementAt(1).FlipOver(); // second dealer card dealerHand.Add(deck.TakeTopCard()); dealerHand.ElementAt(1).X = WINDOW_WIDTH - HORIZONTAL_CARD_OFFSET; dealerHand.ElementAt(1).Y = TOP_CARD_OFFSET + VERTICAL_CARD_SPACING; dealerHand.ElementAt(1).FlipOver(); // load sprite font, create message for player score and add to list messageFont = Content.Load<SpriteFont>("Arial24"); playerScoreMessage = new Message(SCORE_MESSAGE_PREFIX + GetBlackjackScore(playerHand).ToString(), messageFont, new Vector2(HORIZONTAL_MESSAGE_OFFSET, SCORE_MESSAGE_TOP_OFFSET)); messages.Add(playerScoreMessage); // load quit button sprite for later use quitButtonSprite = Content.Load<Texture2D>("quitbutton"); // create hit button and add to list Texture2D hitButtonSprite = Content.Load<Texture2D>("hitbutton"); menuButtons.Add(new MenuButton(hitButtonSprite, new Vector2(HORIZONTAL_MENU_BUTTON_OFFSET, TOP_MENU_BUTTON_OFFSET), GameState.PlayerHitting)); // create stand button and add to list Texture2D standButtonSprite = Content.Load<Texture2D>("standbutton"); menuButtons.Add(new MenuButton(standButtonSprite, new Vector2(HORIZONTAL_MENU_BUTTON_OFFSET, TOP_MENU_BUTTON_OFFSET + VERTICAL_MENU_BUTTON_SPACING), GameState.WaitingForDealer)); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // create and shuffle deck deck = new Deck(Content, 0, 0); deck.Shuffle(); // first player card addCardToPlayer(); // first dealer card Card card = deck.TakeTopCard(); card.X = WindowWidth - HorizontalCardOffset; card.Y = TopCardOffset; dealerHand.Add(card); // second player card addCardToPlayer(); // second dealer card addCardToDealer(); // load sprite font, create message for player score and add to list messageFont = Content.Load<SpriteFont>(@"fonts\Arial24"); playerScoreMessage = new Message(ScoreMessagePrefix + GetBlockjuckScore(playerHand).ToString(), messageFont, new Vector2(HorizontalMessageOffset, ScoreMessageTopOffset)); messages.Add(playerScoreMessage); // load quit button sprite for later use quitButtonSprite = Content.Load<Texture2D>("quitbutton"); // create hit button and add to list hitButtonSprite = Content.Load<Texture2D>("hitbutton"); hitButton = new MenuButton(hitButtonSprite, new Vector2(HorizontalMenuButtonOffset, TopMenuButtonOffset), GameState.PlayerHitting); menuButtons.Add(hitButton); // create stand button and add to list standButtonSprite = Content.Load<Texture2D>("standbutton"); standButton = new MenuButton(standButtonSprite, new Vector2(HorizontalMenuButtonOffset, TopMenuButtonOffset + VerticalMenuButtonSpacing), GameState.WaitingForDealer); menuButtons.Add(standButton); }