Пример #1
0
 private void GuessSpotFormatter(GuessSpot gs, int x, int y, int xPos, int yPos)
 {
     gs.Row      = y;
     gs.Col      = x;
     gs.Width    = this.SquareSize;
     gs.Height   = this.SquareSize;
     gs.Location = new Point(xPos, yPos);
 }
Пример #2
0
        /// <summary>
        /// Draws Player 2's board.
        /// </summary>
        private void DrawP2CrackingBoard()
        {
            // Define an array of GuessSpots
            this.attemptsArrayP2 = new GuessSpot[this.GameControl.CodeLength, this.GameControl.AttemptsAllowed];

            // Declare a temporary results label.
            LabelResults labelOutputResults;

            // Make a name label.
            Label p2nameLabel = new Label();

            p2nameLabel.Location = new Point(this.SquareSize * this.gameControl.CodeLength * 2, this.SquareSize);
            p2nameLabel.Text     = this.gameControl.P2.Name;
            NameLabelFormatter(p2nameLabel);
            this.Controls.Add(p2nameLabel);

            // Label parts of the board.
            Label p2guessesLabel = new Label();

            p2guessesLabel.Location = new Point((this.SquareSize * this.gameControl.CodeLength) * 2, (this.SquareSize * 2) * 3 / 4);
            GuessesLabelFormatter(p2guessesLabel);
            this.Controls.Add(p2guessesLabel);

            Label p2resultsHeaderLabel = new Label();

            p2resultsHeaderLabel.Location = new Point(this.SquareSize * this.gameControl.CodeLength * 3, (this.SquareSize * 2) * 3 / 4);
            ResultsHeaderLabelFormatter(p2resultsHeaderLabel);
            this.Controls.Add(p2resultsHeaderLabel);

            int xPos = (this.SquareSize * this.GameControl.CodeLength * 2);
            int yPos = (this.SquareSize * this.GameControl.AttemptsAllowed) + this.SquareSize;

            for (int y = 0; y < this.GameControl.AttemptsAllowed; y++)
            {
                GuessSpot gs;

                for (int x = 0; x < this.GameControl.CodeLength; x++)
                {
                    gs = new GuessSpot(this.GameControl, this);
                    GuessSpotFormatter(gs, x, y, xPos, yPos);
                    xPos = xPos + this.SquareSize;
                    this.Controls.Add(gs);
                    this.attemptsArrayP2[x, y] = gs;
                }

                labelOutputResults = new LabelResults(this);
                this.listOfResultsP2.Add(labelOutputResults);
                labelOutputResults.Location = new Point(xPos, yPos);
                this.Controls.Add(labelOutputResults);
                labelOutputResults.Name = labelOutputResults.Name + y;

                xPos = (this.SquareSize * this.GameControl.CodeLength * 2);
                yPos = yPos - this.SquareSize;
            }

            foreach (GuessSpot gs in this.attemptsArrayP2)
            {
                if (gs.Row != this.GameControl.ActivePlayer.AttemptsUsed)
                {
                    gs.Enabled = false;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Draws Player 1's board.
        /// </summary>
        private void DrawP1CrackingBoard()
        {
            // Define an array of GuessSpots
            this.attemptsArrayP1 = new GuessSpot[this.GameControl.CodeLength, this.GameControl.AttemptsAllowed];

            // Declare a temporary results label.
            LabelResults labelOutputResults;

            // Make a name label.
            Label p1nameLabel = new Label();

            p1nameLabel.Location = new Point(this.SquareSize * 1 / 4, this.SquareSize);
            p1nameLabel.Text     = this.gameControl.P1.Name;
            NameLabelFormatter(p1nameLabel);
            this.Controls.Add(p1nameLabel);

            // Label parts of the board.
            Label p1guessesLabel = new Label();

            p1guessesLabel.Location = new Point(this.SquareSize * 1 / 4, (this.SquareSize * 2) * 3 / 4);
            GuessesLabelFormatter(p1guessesLabel);
            this.Controls.Add(p1guessesLabel);

            Label p1resultsHeaderLabel = new Label();

            p1resultsHeaderLabel.Location = new Point((this.SquareSize * this.gameControl.CodeLength) + (this.SquareSize * 1 / 4), (this.SquareSize * 2) * 3 / 4);
            ResultsHeaderLabelFormatter(p1resultsHeaderLabel);
            this.Controls.Add(p1resultsHeaderLabel);

            int xPos = this.SquareSize * 1 / 4;
            int yPos = (this.SquareSize * this.GameControl.AttemptsAllowed) + this.SquareSize;

            for (int y = 0; y < this.GameControl.AttemptsAllowed; y++)
            {
                GuessSpot gs;

                for (int x = 0; x < this.GameControl.CodeLength; x++)
                {
                    gs = new GuessSpot(this.GameControl, this);
                    GuessSpotFormatter(gs, x, y, xPos, yPos);
                    xPos = xPos + this.SquareSize;
                    this.Controls.Add(gs);
                    this.attemptsArrayP1[x, y] = gs;
                }

                // Player-specific value assignments.
                labelOutputResults = new LabelResults(this);
                this.listOfResultsP1.Add(labelOutputResults);
                labelOutputResults.Location = new Point(xPos, yPos);
                this.Controls.Add(labelOutputResults);
                labelOutputResults.Name = labelOutputResults.Name + y;

                // Player-specific coordinate incrementing.
                xPos = this.SquareSize * 1 / 4;
                yPos = yPos - this.SquareSize;
            }

            foreach (GuessSpot gs in this.attemptsArrayP1)
            {
                if (gs.Row != this.GameControl.ActivePlayer.AttemptsUsed)
                {
                    gs.Enabled = false;
                }
            }
        }