Ejemplo n.º 1
0
        public void gameTurn(Point mouseLoc)
        {
            int x = 0;
            int y = 0;

            if (mouseLoc.Y <= 500)
            {
                if (mouseLoc.X < 167)
                {
                    x = 0;
                }
                else if (mouseLoc.X < 334)
                {
                    x = 1;
                }
                else
                {
                    x = 2;
                }
                if (mouseLoc.Y < 167)
                {
                    y = 0;
                }
                else if (mouseLoc.Y < 334)
                {
                    y = 1;
                }
                else if (mouseLoc.Y < 503)
                {
                    y = 2;
                }


                if (detectWin() == 0)
                {
                    if (holders[x, y].getLetter().Equals('X') || holders[x, y].getLetter().Equals('O'))
                    {
                    }
                    else
                    {
                        //Turn Logic:
                        if (movesMade % 2 == 0)
                        {
                            GFX.drawX(new Point(x, y));
                            holders[x, y].setValue(X);
                            holders[x, y].setLetter('X');
                            movesMade++;
                        }
                        else
                        {
                            GFX.drawO(new Point(x, y));
                            holders[x, y].setValue(O);
                            holders[x, y].setLetter('O');
                            movesMade++;
                        }

                        if (detectWin() == 1)
                        {
                            Console.WriteLine("Congratulations, player {0}, you Win!", holders[x, y].getLetter());
                        }
                        if (detectWin() == 2)
                        {
                            Console.WriteLine("I tawt I taw a puddycat; CAT.");
                        }
                    }
                }
            }
        }