Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Button polje = sender as Button;

            Igra.Stevec++;
            player.URL = "splash.wav";

            if (polje.Text == "")
            {
                if (Igra.Stevec % 2 != 0)
                {
                    polje.Text      = "X";
                    polje.ForeColor = Color.Black;
                    Igra.skupaj     = "";
                    Igra.gumbi.Clear();
                    label6.Text = "O";

                    if (Igra.Zmaga_X(panel1, polje) == true)
                    {
                        Klici_konec();
                        label6.Text = "X";
                    }

                    else
                    {
                        Igra.skupaj = "";
                        Igra.gumbi.Clear();

                        if (Igra.Zmaga_Y(panel1, polje) == true)
                        {
                            Klici_konec();
                            label6.Text = "X";
                        }

                        else
                        {
                            if (Igra.Preveri_Neodloceno(panel1) == true)
                            {
                                player.URL = "piano.wav";
                                DialogResult d = MessageBox.Show("NEODLOČENO! Bi poskusil/a še enkrat?", "Sonček sporoča", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                if (d == DialogResult.Yes)
                                {
                                    Igra.Stevec = 1;
                                    Igra.skupaj = "";
                                    Igra.Pocisti(panel1);
                                }

                                else
                                {
                                    Application.Exit();
                                }
                            }
                        }
                    }
                }

                else if (Igra.Stevec % 2 == 0)
                {
                    polje.Text      = "O";
                    polje.ForeColor = Color.Black;
                    Igra.skupaj     = "";
                    Igra.gumbi.Clear();
                    label6.Text = "X";

                    if (Igra.Zmaga_X(panel1, polje) == true)
                    {
                        Klici_konec();
                        label6.Text = "X";
                    }

                    else
                    {
                        Igra.skupaj = "";
                        Igra.gumbi.Clear();

                        if (Igra.Zmaga_Y(panel1, polje) == true)
                        {
                            Klici_konec();
                            label6.Text = "X";
                        }

                        else
                        {
                            if (Igra.Preveri_Neodloceno(panel1) == true)
                            {
                                player.URL = "piano.wav";
                                DialogResult d = MessageBox.Show("NEODLOČENO! Bi poskusil/a še enkrat?", "Sonček sporoča", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                if (d == DialogResult.Yes)
                                {
                                    Igra.Stevec = 1;
                                    Igra.skupaj = "";
                                    Igra.Pocisti(panel1);
                                }

                                else
                                {
                                    Application.Exit();
                                }
                            }
                        }
                    }
                }
            }

            else
            {
                MessageBox.Show("Polje je že zasedeno!", "Sonček sporoča", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }