Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     game              = new XoXGame();
     game.GameStarted += new xoxGameHandler(game_Started);
     game.TurnChanged += new xoxGameHandler(turn_Changed);
     game.GameOver    += new xoxGameOverHandler(game_Over);
     game.StartGame();
 }
Ejemplo n.º 2
0
 private void game_Over(XoXGame game, List <List <int> > winningConditions)
 {
     game.ActivePlayer.WinTheGame();
     label1.Text = game.Player1.Name + ":" + game.Player1.Score;
     label2.Text = game.Player2.Name + ":" + game.Player2.Score;
     foreach (var condition in winningConditions)
     {
         groupBox1.Controls[condition[0]].BackColor = Color.GreenYellow;
         groupBox1.Controls[condition[1]].BackColor = Color.GreenYellow;
         groupBox1.Controls[condition[2]].BackColor = Color.GreenYellow;
     }
 }
Ejemplo n.º 3
0
        private void game_Started(XoXGame game)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Button btn = new Button();
                    btn.Size     = new Size(100, 100);
                    btn.Location = new Point(105 * j + 10, 105 * i + 10);
                    btn.Tag      = 3 * i + j;
                    btn.Click   += Btn_Click;
                    this.groupBox1.Controls.Add(btn);
                }
            }

            label1.Text = game.Player1.Name + ":" + game.Player1.Score;
            label2.Text = game.Player2.Name + ":" + game.Player2.Score;
            changeActiveLabel();
        }
Ejemplo n.º 4
0
 private void turn_Changed(XoXGame game)
 {
     changeActiveLabel();
 }