/// <summary> /// Draws the component /// </summary> /// <param name="gameTime">Time passed since the last call to /// this method.</param> public override void Draw(GameTime gameTime) { spriteBatch.Begin(); // Draws the chips for (int chipIndex = 0; chipIndex < chipsAssets.Count; chipIndex++) { spriteBatch.Draw(chipsAssets[assetNames[chipIndex]], positions[chipIndex], Color.White); } BlackjackPlayer player; // Draws the player balance and bet amount for (int playerIndex = 0; playerIndex < players.Count; playerIndex++) { BlackJackTable table = (BlackJackTable)cardGame.GameTable; Vector2 position = table[playerIndex] + table.RingOffset + new Vector2(table.RingTexture.Bounds.Width, 0); player = (BlackjackPlayer)players[playerIndex]; spriteBatch.DrawString(cardGame.Font, "$" + player.BetAmount.ToString(), position, Color.White); spriteBatch.DrawString(cardGame.Font, "$" + player.Balance.ToString(), position + new Vector2(0, 30), Color.White); } spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Gets the offset at which newly added chips should be placed. /// </summary> /// <param name="playerIndex">Index of the player to whom the chip /// is added.</param> /// <param name="secondHand">True if the chip is added to the player's second /// hand, false otherwise.</param> /// <returns>The offset from the player's position where chips should be /// placed.</returns> private Vector2 GetChipOffset(int playerIndex, bool secondHand) { Vector2 offset = Vector2.Zero; BlackJackTable table = ((BlackJackTable)cardGame.GameTable); offset = table.RingOffset + new Vector2(table.RingTexture.Bounds.Width - blankChip.Bounds.Width, table.RingTexture.Bounds.Height - blankChip.Bounds.Height) / 2f; if (secondHand == true) { offset += secondHandOffset; } return(offset); }