Пример #1
0
        public GraKomputerForm(Rundy runda, Profile profile, GraKomputer gra, Boolean nastepnyGracz)
        {
            poleKomp = new int[2];
            FormBorderStyle = FormBorderStyle.None;
            WindowState = FormWindowState.Maximized;

            this.DoubleBuffered = true;

            InitializeComponent();

            this.runda = runda;
            this.gra = gra;
            this.nastepnyGracz = nastepnyGracz;
            this.profile = profile;
            pola = new Kontrolka[3, 3];

            logo = new PictureBox();
            pngLogo = new Bitmap(@"Drawable\logoMsg.png");
            logo.BackColor = Color.Transparent;
            logo.Image = pngLogo;
            logo.Width = pngLogo.Width;
            logo.Height = pngLogo.Height;
            logo.Location = new Point(250, 20);

            pola[0, 0] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 540, 150, "Pole00Tag");
            pola[0, 1] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 604, 150, "Pole01Tag");
            pola[0, 1] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 604, 150, "Pole01Tag");
            pola[0, 1] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 604, 150, "Pole01Tag");
            pola[0, 2] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 668, 150, "Pole02Tag");
            pola[1, 0] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 540, 214, "Pole10Tag");
            pola[1, 1] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 604, 214, "Pole11Tag");
            pola[1, 2] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 668, 214, "Pole12Tag");
            pola[2, 0] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 540, 278, "Pole20Tag");
            pola[2, 1] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 604, 278, "Pole21Tag");
            pola[2, 2] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 668, 278, "Pole22Tag");
            pola[2, 2] = new Kontrolka(@"Buttons\GameButtons\LeftNormal.png", @"Buttons\GameButtons\LeftPress.png", @"Buttons\GameButtons\LeftFocus.png", 668, 278, "Pole22Tag");
            kontrolkaMenu = new Kontrolka(@"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitPress.png", @"Buttons\MenuButtons\ExitFocus.png", 540, 500, "MenuTag");
            kontrolkaExit = new Kontrolka(@"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitPress.png", @"Buttons\MenuButtons\ExitFocus.png", 540, 600, "ExitTag");

            for (int i = 0; i < 3; i++)
                for (int j = 0; j < 3; j++)
                    this.Controls.Add(pola[i, j]);
            this.Controls.Add(logo);
            this.Controls.Add(kontrolkaMenu);
            this.Controls.Add(kontrolkaExit);
            this.BackgroundImage = new Bitmap(@"Drawable\Wall_Beige.png");

            for (int i = 0; i < 3; i++)
                for (int j = 0; j < 3; j++)
                    pola[i, j].MouseClick += new MouseEventHandler(mouseClick);
            kontrolkaMenu.MouseClick += new MouseEventHandler(mouseClick);
            kontrolkaExit.MouseClick += new MouseEventHandler(mouseClick);
        }
Пример #2
0
        public CzyNastepnaRundaForm(Rundy runda, Profile profile, Gra gra, bool nastepnyGracz)
        {
            FormBorderStyle = FormBorderStyle.None;
            WindowState = FormWindowState.Maximized;

            this.DoubleBuffered = true;

            InitializeComponent();

            // TODO: Complete member initialization
            this.runda = runda;
            this.profile = profile;
            this.gra = gra;
            this.nastepnyGracz = nastepnyGracz;

            logo = new PictureBox();
            pngLogo = new Bitmap(@"Drawable\logoMsg.png");
            logo.BackColor = Color.Transparent;
            logo.Image = pngLogo;
            logo.Width = pngLogo.Width;
            logo.Height = pngLogo.Height;
            logo.Location = new Point(250, 20);

            kontrolkaRunda = new Kontrolka(@"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitNormal.png", 200, 150, "RundaTag");
            kontrolkaGraczKolko = new Kontrolka(@"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitNormal.png", 200, 250, "GraczKolkoTag");
            kontrolkaGraczKrzyzyk = new Kontrolka(@"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitNormal.png", 200, 350, "GraczKrzyzykTag");
            kontrolkaNastepnaRunda = new Kontrolka(@"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitPress.png", @"Buttons\MenuButtons\ExitFocus.png", 540, 450, "NastepnaRundaTag");
            kontrolkaMenu = new Kontrolka(@"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitPress.png", @"Buttons\MenuButtons\ExitFocus.png", 540, 550, "MenuTag");
            kontrolkaExit = new Kontrolka(@"Buttons\MenuButtons\ExitNormal.png", @"Buttons\MenuButtons\ExitPress.png", @"Buttons\MenuButtons\ExitFocus.png", 540, 650, "ExitTag");

            rundaBox = new TextBox();
            rundaBox.Location = new Point(540, 150);
            rundaBox.AutoSize = false;
            rundaBox.Size = new Size(600, kontrolkaRunda.Height);
            rundaBox.Font = new Font(rundaBox.Font.FontFamily, 32);
            rundaBox.AppendText(runda.getLicznikRund().ToString());

            kolkoBox = new TextBox();
            kolkoBox.Location = new Point(540, 250);
            kolkoBox.AutoSize = false;
            kolkoBox.Size = new Size(600, kontrolkaRunda.Height);
            kolkoBox.Font = new Font(kolkoBox.Font.FontFamily, 32);
            kolkoBox.AppendText(profile.getGracz2().ToString() + " " + runda.getLicznikKolko());

            krzyzykBox = new TextBox();
            krzyzykBox.Location = new Point(540, 350);
            krzyzykBox.AutoSize = false;
            krzyzykBox.Size = new Size(600, kontrolkaRunda.Height);
            krzyzykBox.Font = new Font(rundaBox.Font.FontFamily, 32);
            krzyzykBox.AppendText(profile.getGracz1().ToString() + " " + runda.getLicznikKrzyzyk());

            this.Controls.Add(rundaBox);
            this.Controls.Add(kolkoBox);
            this.Controls.Add(krzyzykBox);
            this.Controls.Add(kontrolkaRunda);
            this.Controls.Add(kontrolkaGraczKolko);
            this.Controls.Add(kontrolkaGraczKrzyzyk);
            this.Controls.Add(kontrolkaNastepnaRunda);
            this.Controls.Add(kontrolkaMenu);
            this.Controls.Add(kontrolkaExit);
            this.Controls.Add(logo);
            this.BackgroundImage = new Bitmap(@"Drawable\Wall_Beige.png");

            kontrolkaRunda.MouseClick += new MouseEventHandler(mouseClick);
            kontrolkaGraczKolko.MouseClick += new MouseEventHandler(mouseClick);
            kontrolkaGraczKrzyzyk.MouseClick += new MouseEventHandler(mouseClick);
            kontrolkaNastepnaRunda.MouseClick += new MouseEventHandler(mouseClick);
            kontrolkaMenu.MouseClick += new MouseEventHandler(mouseClick);
            kontrolkaExit.MouseClick += new MouseEventHandler(mouseClick);
        }
Пример #3
0
        public void StartGAME()
        {
            char odp;
            int rodzajGry; //był char rodzajGry;
            bool nastepnyGracz;
            bool komputer;
            int ruchGracza;
            int wynik;
            Profile pro = new Profile();
            //GraKomputer gra = new GraKomputer();
            //Rundy run = new Rundy();
            Console.WriteLine("Gra w kolko i krzyzyk - Nowa Gra");
            Console.WriteLine("Gra dla dwoch graczy - 1, gra z komputerem - 2");
            nastepnyGracz = false;

            rodzajGry = int.Parse(Console.ReadLine());
            Console.WriteLine(rodzajGry.GetType());

            if (rodzajGry == 1)
            {
                pro.podajProfil1();
                pro.podajProfil2();
            }
            if (rodzajGry == 2)
            {
                pro.podajProfil1();
            }

            Rundy run = new Rundy();
            do
            {
                Console.WriteLine("Jak grac: ");
                Console.WriteLine(" ");
                Console.WriteLine("1   |  2  |  3  ");
                Console.WriteLine("----+-----+-----");
                Console.WriteLine(" 4  |  5  |  6  ");
                Console.WriteLine("----+-----+-----");
                Console.WriteLine(" 7  |  8  |  9  ");
                GraKomputer gra = new GraKomputer();
                Console.WriteLine("Runda" + run.licznikRund + 1);
                Console.WriteLine("START!");

                do
                {
                    gra.p1.rysujPlansze();
                    if (rodzajGry == 1)
                    {
                        if (nastepnyGracz == true)
                        {
                            Console.WriteLine("Ruch gracza " + pro.gracz2 + ":");
                        }
                        else
                        {
                            Console.WriteLine("Ruch gracza " + pro.gracz1 + ":");
                        }
                        do
                        {
                            ruchGracza = int.Parse(Console.ReadLine());

                        } while (gra.ruchGracza(nastepnyGracz, ruchGracza));

                    }
                    else
                    {
                        if (nastepnyGracz == true)
                        {
                            Console.WriteLine("Ruch komputera");
                            gra.ruchKomputera(nastepnyGracz);
                        }
                        else
                        {
                            Console.WriteLine("Ruch gracza " + pro.gracz1 + ":");

                            do
                            {
                                ruchGracza = int.Parse(Console.ReadLine()); ;

                            } while (gra.ruchGracza(nastepnyGracz, ruchGracza));

                        }
                    }

                    nastepnyGracz = !nastepnyGracz;

                } while (gra.wygrana() == 0);

                gra.p1.rysujPlansze();

                wynik = gra.wygrana();

                if (wynik == 2)
                {
                    Console.WriteLine("REMIS");
                }
                else
                {
                    if (wynik == -1) Console.WriteLine("Wygral gracz KOLKO");

                    else Console.WriteLine("Wygral gracz KRZYZYK");
                }

                run.runda(wynik);
                Console.WriteLine("Kolejna runda? (t=TAK) ");
                odp = Console.ReadKey().KeyChar;

                Console.Clear();
                Console.WriteLine("KRZYZYK - " + pro.gracz1);
                if (rodzajGry == 1)
                    Console.WriteLine("KOLKO - " + pro.gracz2);

            } while (odp == 'T' || odp == 't');
            Console.Clear();
        }