示例#1
0
    private void initialize()
    {
        board = GetComponent <Board>();

        Vector3 minCamPos, maxCamPos;

        CameraUtils.GetCameraLimitPointsAtZ(boardPositionInZ, out minCamPos, out maxCamPos);

        float screenWidthAtZ  = maxCamPos.x - minCamPos.x;
        float screenHeightAtZ = maxCamPos.y - minCamPos.y;

        float boardMinPosInX = minCamPos.x + screenWidthAtZ * boardStartInScreenWidthProportion;
        float boardMaxPosInX = minCamPos.x + screenWidthAtZ * boardEndInScreenWidthProportion;
        float boardMinPosInY = minCamPos.y + screenHeightAtZ * boardStartInScreenHeightProportion;
        float boardMaxPosInY = minCamPos.y + screenHeightAtZ * boardEndInScreenHeightProportion;

        boardStartPosition  = new Vector3(boardMinPosInX, boardMaxPosInY, boardPositionInZ);
        boardWidth          = boardMaxPosInX - boardMinPosInX;
        boardHeight         = boardMaxPosInY - boardMinPosInY;
        verticalLineScale   = new Vector3(1, boardHeight, 1);
        horizontalLineScale = new Vector3(boardWidth, 1, 1);

        spaceBetweenColumns = boardWidth / (nbColumns + 1);
        spaceBetweenRows    = boardHeight / (nbRows + 1);
        boardCellScale      = new Vector3(spaceBetweenColumns, spaceBetweenRows, boardCellPrefab.transform.localScale.z);
    }