Exemplo n.º 1
0
    public WinInfo EvaluateBoard(TileMB[] board, int lastSelection)
    {
        curBoard             = board;
        winResult.winPresent = false;
        winResult.winTiles   = new Vector3[boardSize];
        TileMB.TileState selectedState = board[lastSelection].SelectedState;
        int tileRow = lastSelection / boardSize;
        int tileCol = lastSelection % boardSize;

        //Check the Collumn and Row of The Last Selection
        if (CheckCollumnWin(tileCol, selectedState))
        {
            return(winResult);
        }
        else if (CheckRowWin(tileRow, selectedState))
        {
            return(winResult);
        }
        //Always Check Diagonals
        else if (CheckDiagonalWinLeft(selectedState))
        {
            return(winResult);
        }
        else if (CheckDiagonalWinRight(selectedState))
        {
            return(winResult);
        }

        return(winResult);
    }
Exemplo n.º 2
0
    private void WaitForPick(Message msg)
    {
        TileSelectedMsg tileSelected = msg as TileSelectedMsg;

        lastSelectedTile = tileSelected.SelectedIndex;
        TileMB.TileState tileOwner = playerOne ? TileMB.TileState.PLAYER1 : TileMB.TileState.PLAYER2;
        gameBoard.SelectTile(lastSelectedTile, tileOwner);

        Debug.Log(string.Format("Tile {0} Was Selected", lastSelectedTile));
        SwitchState("Evaluate");

        gameBoard.EnablePicks(false);
    }
Exemplo n.º 3
0
    private bool CheckDiagonalWinLeft(TileMB.TileState evalState)
    {
        int tileIndex;

        for (int i = 0; i < boardSize; i++)
        {
            tileIndex = i + (i * boardSize);
            if (curBoard[tileIndex].SelectedState != evalState)
            {
                return(false);
            }
            winResult.winTiles[i] = curBoard[tileIndex].GetCenter();
        }

        winResult.winPresent = true;
        return(true);
    }
Exemplo n.º 4
0
    private bool CheckDiagonalWinRight(TileMB.TileState evalState)
    {
        int tileIndex;
        int largestIndex = boardSize * boardSize - 1;
        int listIndex    = 0;

        //Start Eval At TopRight Tile And Move Down and Right Until i is Beyond the Board Bounds
        for (int i = boardSize - 1; i < largestIndex; i += boardSize - 1)
        {
            tileIndex = i;
            if (curBoard[tileIndex].SelectedState != evalState)
            {
                return(false);
            }
            winResult.winTiles[listIndex] = curBoard[tileIndex].GetCenter();
            listIndex++;
        }

        winResult.winPresent = true;
        return(true);
    }
Exemplo n.º 5
0
 public void SelectTile(int index, TileMB.TileState tileOwner)
 {
     board[index].SetSelectedStatus(tileOwner);
     openTiles.Remove(index);
 }