Ejemplo n.º 1
0
        public void setText(Engine.Winner winner, List <int> sequence)
        {
            string seq = "wygrany ciąg: ";

            switch (winner)
            {
            case Engine.Winner.Player:
                winnerLabel.Text = "WYGRANA!";
                break;

            case Engine.Winner.Computer:
                winnerLabel.Text = "PRZEGRANA";
                break;

            case Engine.Winner.Tie:
                winnerLabel.Text = "REMIS";
                break;

            case Engine.Winner.None:
                winnerLabel.Text = "IMPAS";
                break;
            }
            if (sequence != null && sequence.Count > 0)
            {
                foreach (int i in sequence)
                {
                    seq = seq + " " + i.ToString();
                }
                sequenceLabel.Text = seq;
            }
            else
            {
                sequenceLabel.Text = String.Empty;
            }
        }
Ejemplo n.º 2
0
 public static void GameOver(Engine.Winner winner, List <int> sequence = null)
 {
     gameControl.Enabled = false;
     gameControl.Visible = false;
     gameOverControl.setText(winner, sequence);
     gameOverControl.Enabled = true;
     gameOverControl.Visible = true;
 }
Ejemplo n.º 3
0
        private void colourNumber(Button chosenButton)
        {
            if (chosenButton != firstNumberButton && chosenButton != secondNumberButton)
            {
                return;
            }

            Color      firstColor = Color.Empty;
            Color      secondColor = Color.Empty;
            int        number1 = 0, number2 = 0;
            List <int> sequence = new List <int>();

            if (GameState.Instance.currentMove == GameState.Movement.PlayerColouring)
            {
                firstColor  = GameState.Instance.playerColor;
                secondColor = GameState.Instance.computerColor;
            }
            else if (GameState.Instance.currentMove == GameState.Movement.ComputerColouring)
            {
                firstColor  = GameState.Instance.computerColor;
                secondColor = GameState.Instance.playerColor;
            }

            if (chosenButton == firstNumberButton)
            {
                firstNumberButton.BackColor  = firstColor;
                secondNumberButton.BackColor = secondColor;
                number1 = int.Parse(firstNumberButton.Text);
                number2 = int.Parse(secondNumberButton.Text);
            }
            else if (chosenButton == secondNumberButton)
            {
                secondNumberButton.BackColor = firstColor;
                firstNumberButton.BackColor  = secondColor;
                number1 = int.Parse(secondNumberButton.Text);
                number2 = int.Parse(firstNumberButton.Text);
            }

            if (GameState.Instance.currentMove == GameState.Movement.PlayerColouring)
            {
                GameState.Instance.currentMove = GameState.Movement.PlayersChoice;
                AddNumbers(number1, number2);
            }
            else if (GameState.Instance.currentMove == GameState.Movement.ComputerColouring)
            {
                GameState.Instance.currentMove = GameState.Movement.ComputersChoice;
                AddNumbers(number2, number1);
            }

            firstNumberButton.Enabled  = false;
            secondNumberButton.Enabled = false;
            updateNumbersLabels();
            Engine.Winner winner = Engine.CheckWinner(out sequence);
            if (winner != Engine.Winner.None)
            {
                Form1.GameOver(winner, sequence);
                GameState.Instance.gameOver = true;
                return;
            }
            nextRound();
        }