コード例 #1
0
ファイル: CEForm.cs プロジェクト: KAITOVM00/CardGames
        /// <summary>
        /// Loads and displays the pictureboxes into the player table layout
        /// panel
        /// </summary>
        private void DisplayPHand()
        {
            PlayerPanel.Controls.Clear();
            Hand pHand    = Crazy_Eights_Game.GetPlayerHand();
            int  handSize = pHand.GetCount();

            for (int i = 0; i < handSize; i++)
            {
                PlayerPanel.Controls.Add(playerPBox[i]);
            }
        }
コード例 #2
0
ファイル: CEForm.cs プロジェクト: KAITOVM00/CardGames
        /// <summary>
        /// Updates the pictureboxes for the player with images for current
        /// players hand
        /// </summary>
        private void UpdatePHand()
        {
            PictureBox pBox;
            Hand       pHand    = Crazy_Eights_Game.GetPlayerHand();
            int        handSize = pHand.GetCount();

            for (int i = 0; i < handSize; i++)
            {
                Card card = pHand.GetCard(i);
                pBox                 = new PictureBox();
                pBox.SizeMode        = PictureBoxSizeMode.AutoSize;
                pBox.Dock            = DockStyle.Fill;
                pBox.Image           = Images.GetCardImage(card);
                playerPBox[i]        = pBox;
                playerPBox[i].Click += new EventHandler(PlayerPBox_Click);
                playerPBox[i].Tag    = Crazy_Eights_Game.GetPlayerHand().GetCard(i);
            }
        }
コード例 #3
0
ファイル: CEForm.cs プロジェクト: KAITOVM00/CardGames
        private void PlayerPBox_Click(object sender, EventArgs e)
        {
            //Get the selected card from the picture box
            int        whichCard;
            PictureBox whichClicked = (PictureBox)sender;

            whichCard = Crazy_Eights_Game.WhichCard((Card)whichClicked.Tag);
            Card Selected = Crazy_Eights_Game.GetPlayerHand().GetCard(whichCard);

            if (Crazy_Eights_Game.IsEight(Selected)) //If the selected card is an eight, load suit selection form
            {
                SuitSelection suitSelection = new SuitSelection();
                DialogResult  result        = suitSelection.ShowDialog();
                Card          card          = new Card();
                if (result == DialogResult.OK)
                {
                    card = suitSelection.GetSelection();
                }
                Crazy_Eights_Game.PlayerTurn(Selected, card);
                Crazy_Eights_Game.ComputerTurn();
                InstructionText.Text = yourTurnText;
            }
            else
            {
                bool check = Crazy_Eights_Game.PlayerTurn(Selected);
                if (check)
                {
                    Crazy_Eights_Game.ComputerTurn();
                    InstructionText.Text = yourTurnText;
                }
                else //If no card is played, change instruction text
                {
                    InstructionText.Text = wrongCard;
                }
            }
            RefreshScreen();
        }