Exemplo n.º 1
0
    public GameBoardState CreateGameBoardState()
    {
        IGameBoardState igbs = this;

        GameBoardState newGbs = new GameBoardState(igbs.GetNumLevels(), igbs.GetNumRows(), igbs.GetNumCols());

        for (int lvl = 0; lvl < (igbs.GetNumLevels()); lvl++)
        {
            for (int row = 0; row < (igbs.GetNumRows()); row++)
            {
                for (int col = 0; col < (igbs.GetNumCols()); col++)
                {
                    ISpaceState iss = igbs.GetSpaceState(lvl, row, col);
                    newGbs.spaces[lvl][row][col].occupied = iss.IsOccupied();
                    IPieceState ips = iss.Occupier();
                    if (ips != null)
                    {
                        PieceState ps = ips.CreatePieceState();
                        newGbs.spaces[lvl][row][col].occupier = ps;
                        newGbs.AlivePieces.Add(ps);
                        ps.space = newGbs.spaces[lvl][row][col];
                    }
                }
            }
        }

        foreach (IPieceState piece in DeadPieces)
        {
            newGbs.DeadPieces.Add(piece.CreatePieceState());
        }

        return(newGbs);
    }
Exemplo n.º 2
0
    private static int GetPawnStartRow(IGameBoardState gameBoard, IPieceState piece)
    {
        int pawnStartRow;

        if (piece.GetPlayer() == Player.PlayerNumber.Player1)
        {
            pawnStartRow = 1;
        }
        else
        {
            pawnStartRow = gameBoard.GetNumRows() - 2;
        }

        return(pawnStartRow);
    }
Exemplo n.º 3
0
    public void RenderBoard(IGameBoardState gameBoard)
    {
        int levels = gameBoard.GetNumLevels();
        int rows   = gameBoard.GetNumRows();
        int cols   = gameBoard.GetNumCols();

        for (int i = 0; i < levels; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                for (int k = 0; k < cols; k++)
                {
                    Image img = squareLookup[i][j][k];

                    if (img != null)
                    {
                        if (gameBoard.GetSpaceState(i, j, k).IsOccupied())
                        {
                            Piece.PieceType pieceType = gameBoard.GetSpaceState(i, j, k).Occupier().GetPieceType();
                            img.sprite = PieceSprites[pieceType];

                            img.color = gameBoard.GetSpaceState(i, j, k).Occupier().GetPieceTint();
                            img.Desaturate();
                        }
                        else
                        {
                            img.sprite = BlankSprite;
                            img.color  = Color.white;
                        }
                    }
                    else
                    {
                        Debug.Log("Error: image not found at index " + i + " " + j + " " + k);
                    }
                }
            }
        }
    }