コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the animated hand component. This means
        /// setting the hand's position and initializing all animated cards and their
        /// respective positions. Also, registrations are performed to the associated
        /// <paramref name="hand"/> events to update the animated hand as cards are
        /// added or removed.
        /// </summary>
        /// <param name="place">The player's place index (-1 for the dealer).</param>
        /// <param name="hand">The hand represented by this instance.</param>
        /// <param name="cardGame">The associated card game.</param>
        public AnimatedHandGameComponent(int place, Hand hand, CardsGame cardGame)
            : base(cardGame, null)
        {
            Place = place;
            Hand = hand;
            hand.ReceivedCard += Hand_ReceivedCard;
            hand.LostCard += Hand_LostCard;

            // Set the component's position
            if (place == -1)
            {
                CurrentPosition = CardGame.GameTable.DealerPosition;
            }
            else
            {
                CurrentPosition = CardGame.GameTable[place];
            }

            // Create and initialize animated cards according to the cards in the 
            // associated hand
            for (int cardIndex = 0; cardIndex < hand.Count; cardIndex++)
            {
                AnimatedCardsGameComponent animatedCardGameComponent =
                    new AnimatedCardsGameComponent(hand[cardIndex], CardGame)
                    {
                        CurrentPosition = CurrentPosition + new Vector2(30 * cardIndex, 0)
                    };

                heldAnimatedCards.Add(animatedCardGameComponent);
                Game.Components.Add(animatedCardGameComponent);
            }

            Game.Components.ComponentRemoved += Components_ComponentRemoved;
        } 
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the animated hand component. This means
        /// setting the hand's position and initializing all animated cards and their
        /// respective positions. Also, registrations are performed to the associated
        /// <paramref name="hand"/> events to update the animated hand as cards are
        /// added or removed.
        /// </summary>
        /// <param name="place">The player's place index (-1 for the dealer).</param>
        /// <param name="hand">The hand represented by this instance.</param>
        /// <param name="cardGame">The associated card game.</param>
        public AnimatedHandGameComponent(int place, Hand hand, CardsGame cardGame)
            : base(cardGame, null)
        {
            Place              = place;
            Hand               = hand;
            hand.ReceivedCard += Hand_ReceivedCard;
            hand.LostCard     += Hand_LostCard;

            // Set the component's position
            if (place == -1)
            {
                CurrentPosition = CardGame.GameTable.DealerPosition;
            }
            else
            {
                CurrentPosition = CardGame.GameTable[place];
            }

            // Create and initialize animated cards according to the cards in the
            // associated hand
            for (int cardIndex = 0; cardIndex < hand.Count; cardIndex++)
            {
                AnimatedCardsGameComponent animatedCardGameComponent =
                    new AnimatedCardsGameComponent(hand[cardIndex], CardGame)
                {
                    CurrentPosition = CurrentPosition + new Vector2(30 * cardIndex, 0)
                };

                heldAnimatedCards.Add(animatedCardGameComponent);
                Game.Components.Add(animatedCardGameComponent);
            }

            Game.Components.ComponentRemoved += Components_ComponentRemoved;
        }
コード例 #3
0
ファイル: Button.cs プロジェクト: liwq-net/SilverSprite
 /// <summary>
 /// Creates a new instance of the <see cref="Button"/> class.
 /// </summary>
 /// <param name="regularTexture">The name of the button's texture.</param>
 /// <param name="pressedTexture">The name of the texture to display when the 
 /// button is pressed.</param>
 /// <param name="input">A <see cref="GameStateManagement.InputState"/> object
 /// which can be used to retrieve user input.</param>
 /// <param name="cardGame">The associated card game.</param>
 /// <remarks>Texture names are relative to the "Images" content 
 /// folder.</remarks>
 public Button(string regularTexture, string pressedTexture, InputState input,
     CardsGame cardGame)
     : base(cardGame, null)
 {
     this.input = input;
     this.regularTexture = regularTexture;
     this.pressedTexture = pressedTexture;
 }
コード例 #4
0
 /// <summary>
 /// Creates a new instance of the <see cref="BetGameComponent"/> class.
 /// </summary>
 /// <param name="players">A list of participating players.</param>
 /// <param name="input">An instance of
 /// <see cref="GameStateManagement.InputState"/> which can be used to
 /// check user input.</param>
 /// <param name="theme">The name of the selcted card theme.</param>
 /// <param name="cardGame">An instance of <see cref="CardsGame"/> which
 /// is the current game.</param>
 public BetGameComponent(List <Player> players, InputState input,
                         string theme, CardsGame cardGame)
     : base(cardGame.Game)
 {
     this.players  = players;
     this.theme    = theme;
     this.cardGame = cardGame;
     this.input    = input;
     chipsAssets   = new Dictionary <int, Texture2D>();
 }
コード例 #5
0
 /// <summary>
 /// Creates a new instance of the <see cref="BetGameComponent"/> class.
 /// </summary>
 /// <param name="players">A list of participating players.</param>
 /// <param name="input">An instance of 
 /// <see cref="GameStateManagement.InputState"/> which can be used to 
 /// check user input.</param>
 /// <param name="theme">The name of the selcted card theme.</param>
 /// <param name="cardGame">An instance of <see cref="CardsGame"/> which
 /// is the current game.</param>
 public BetGameComponent(List<Player> players, InputState input,
     string theme, CardsGame cardGame)
     : base(cardGame.Game)
 {
     this.players = players;
     this.theme = theme;
     this.cardGame = cardGame;
     this.input = input;
     chipsAssets = new Dictionary<int, Texture2D>();
 }
コード例 #6
0
        /// <summary>
        /// Calculates the value represented by a specified hand.
        /// </summary>
        /// <param name="hand">The hand for which to calculate the value.</param>
        /// <param name="game">The associated game.</param>
        /// <param name="value">Will contain the hand's value. If the hand has two
        /// possible values due to it containing an ace, this will be the lower
        /// value.</param>
        /// <param name="considerAce">Whether or not an ace can be considered to
        /// make the hand have an alternative value.</param>
        private static void CalulateValue(Hand hand, CardsFramework.CardsGame game,
                                          out int value, out bool considerAce)
        {
            value       = 0;
            considerAce = false;

            for (int cardIndex = 0; cardIndex < hand.Count; cardIndex++)
            {
                value += game.CardValue(hand[cardIndex]);

                if (hand[cardIndex].Value == CardValue.Ace)
                {
                    considerAce = true;
                }
            }

            if (considerAce && value + 10 > 21)
            {
                considerAce = false;
            }
        }
 /// <summary>
 /// Creates a new instance of the 
 /// <see cref="BlackjackAnimatedPlayerHandComponent"/> class.
 /// </summary>
 /// <param name="place">A number indicating the hand's position on the 
 /// game table.</param>
 /// <param name="hand">The player's hand.</param>
 /// <param name="cardGame">The associated game.</param>
 /// <param name="offset">An offset which will be added to all card locations
 /// returned by this component.</param>
 public BlackjackAnimatedPlayerHandComponent(int place, Vector2 offset, 
     Hand hand, CardsGame cardGame)
     : base(place, hand, cardGame)
 {
     this.offset = offset;
 }
コード例 #8
0
 /// <summary>
 /// Creates a new instance of the <see cref="BlackjackAIPlayer"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="game">The game.</param>
 public BlackjackAIPlayer(string name, CardsGame game)
     : base(name, game)
 {
 }
コード例 #9
0
ファイル: Player.cs プロジェクト: nusisschad/XNAGameStudio
 public Player(string name, CardsGame game)
 {
     Name = name;
     Game = game;
     Hand = new Hand();
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 /// <param name="card">The card associated with the animation component.</param>
 /// <param name="cardGame">The associated game.</param>
 public AnimatedCardsGameComponent(TraditionalCard card, CardsGame cardGame)
     : base(cardGame, null)
 {
     Card = card;
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the class, using black text color.
 /// </summary>
 /// <param name="cardGame">The associated card game.</param>
 /// <param name="currentFrame">The texture serving as the current frame
 /// to display as the component.</param>
 public AnimatedGameComponent(CardsGame cardGame, Texture2D currentFrame)
     : this(cardGame.Game)
 {
     CardGame     = cardGame;
     CurrentFrame = currentFrame;
 }
コード例 #12
0
 /// <summary>
 /// Creates a new instance of the 
 /// <see cref="BlackjackAnimatedDealerHandComponent"/> class.
 /// </summary>
 /// <param name="place">A number indicating the hand's position on the 
 /// game table.</param>
 /// <param name="hand">The dealer's hand.</param>
 /// <param name="cardGame">The associated game.</param>
 public BlackjackAnimatedDealerHandComponent(int place, Hand hand, 
     CardsGame cardGame) : base(place, hand, cardGame)
 {
 }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the class, using black text color.
 /// </summary>
 /// <param name="cardGame">The associated card game.</param>
 /// <param name="currentFrame">The texture serving as the current frame
 /// to display as the component.</param>
 public AnimatedGameComponent(CardsGame cardGame, Texture2D currentFrame)
     : this(cardGame.Game)
 {
     CardGame = cardGame;
     CurrentFrame = currentFrame;
 }
コード例 #14
0
 /// <summary>
 /// Creates a new blackjack player instance.
 /// </summary>
 /// <param name="name">The player's name.</param>
 /// <param name="game">The game associated with the player.</param>
 public BlackjackPlayer(string name, CardsFramework.CardsGame game)
     : base(name, game)
 {
     Balance         = 500;
     CurrentHandType = HandTypes.First;
 }
コード例 #15
0
ファイル: Player.cs プロジェクト: liwq-net/SilverSprite
 public Player(string name, CardsGame game)
 {
     Name = name;
     Game = game;
     Hand = new Hand();
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 /// <param name="card">The card associated with the animation component.</param>
 /// <param name="cardGame">The associated game.</param>
 public AnimatedCardsGameComponent(TraditionalCard card, CardsGame cardGame)
     : base(cardGame, null)
 {
     Card = card;
 }