示例#1
0
        private void GenerateTiles()
        {
            GetSpotRect();

            int k = 0;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Spots[i, j]          = new TileSpot();
                    Spots[i, j].Location = SpotRect[i, j].Location;
                    Spots[i, j].Size     = SpotRect[i, j].Size;
                    Spots[i, j].Parent   = this;
                    Spots[i, j].Uid      = k++;
                }
            }
        }
示例#2
0
        public static void OnSpotClicked(TileSpot tileSpot)
        {
            if (WinnerChecker.CheckWin(BlackBoard.Spots) == GameResult.GAME_ON)
            {
                if (tileSpot.Owner == OwnerType.NONE)
                {
                    if (Turn % 2 == 0)
                    {
                        tileSpot.Owner = OwnerType.PLAYER;
                        Turn++;
                    }

                    if (WinnerChecker.CheckWin(BlackBoard.Spots) == GameResult.GAME_ON && Turn <= 7)
                    {
                        var bestMove = BrainAI.GetBestMoveAI(BlackBoard.Spots);

                        if (BlackBoard.Spots[bestMove.I, bestMove.J].Owner == OwnerType.NONE)
                        {
                            BlackBoard.Spots[bestMove.I, bestMove.J].Owner = OwnerType.AI;
                        }
                    }

                    if (Turn < 9)
                    {
                        Turn++;
                    }
                }
            }
            switch (WinnerChecker.CheckWin(BlackBoard.Spots))
            {
            case GameResult.AI_WIN:
                MessageBox.Show("AI Won");
                break;

            case GameResult.PLAYER_WIN:
                MessageBox.Show("Player Won");
                break;

            case GameResult.GAME_DRAW:
                MessageBox.Show("Draw");
                break;
            }
        }
示例#3
0
 private void TileSpot_OnTileClicked(TileSpot tileSpot)
 {
     GameManager.OnSpotClicked(tileSpot);
 }