コード例 #1
0
    bool addNewMinaret()
    {
        Edge     curEdge      = freeEdges[Randomiser.intBetween(0, freeEdges.Count / 2)];
        Junction junction     = new Junction(Randomiser.pointOnEdge(curEdge), curEdge.axisDirection);
        Vector3  measurePoint = junction.position + 0.2f * curEdge.axisDirection;

        if (!checkJunction(measurePoint))
        {
            return(false);
        }
        int distanceAlongEdge = Mathf.Min(
            Randomiser.measureDistance(measurePoint, GenericUtils.rotateClockwise(curEdge.axisDirection), maxLengthR / 2),
            Randomiser.measureDistance(measurePoint, -1 * GenericUtils.rotateClockwise(curEdge.axisDirection), maxLengthR / 2)
            );

        if (distanceAlongEdge < minLengthS)
        {
            return(false);
        }
        int distanceAlongAxis = Randomiser.measureDistance(measurePoint, curEdge.axisDirection, minaretSize);

        if (distanceAlongAxis * 2 < minaretSize)
        {
            return(false);
        }
        distanceAlongAxis = Randomiser.clampInRange(distanceAlongAxis, minaretSize, (int)(distanceAlongEdge * 2));
        MinaretFoundation minaret = minaretFromJunction(junction, curEdge.axisDirection, Mathf.Min(distanceAlongEdge * 2, distanceAlongAxis));

        if (!checkMinaretConsistency(minaret))
        {
            minaret.delete();
            return(false);
        }
        if (!checkOverlaps(minaret))
        {
            minaret.delete();
            return(false);
        }
        minarets.Add(minaret);
        freeEdges.Remove(curEdge);
        usedEdges.Add(curEdge);
        return(true);
    }
コード例 #2
0
    bool addNewSquare()
    {
        Edge     curEdge      = freeEdges[Randomiser.intBetween(0, freeEdges.Count / 2)];
        Junction junction     = new Junction(Randomiser.pointOnEdge(curEdge), curEdge.axisDirection);
        Vector3  measurePoint = junction.position + 0.2f * curEdge.axisDirection;

        if (!checkJunction(measurePoint))
        {
            return(false);
        }
        int distanceAlongEdge = Mathf.Min(
            Randomiser.measureDistance(measurePoint, GenericUtils.rotateClockwise(curEdge.axisDirection), maxLengthR / 2),
            Randomiser.measureDistance(measurePoint, -1 * GenericUtils.rotateClockwise(curEdge.axisDirection), maxLengthR / 2)
            );

        if (distanceAlongEdge < minLengthS)
        {
            return(false);
        }
        int distanceAlongAxis = Randomiser.measureDistance(measurePoint, curEdge.axisDirection, maxLengthR);

        if (distanceAlongAxis * 2 < minLengthS)
        {
            return(false);
        }
        distanceAlongAxis = Randomiser.clampInRange(distanceAlongAxis, minLengthR, (int)(distanceAlongEdge * 2));
        SquareFoundation square = SquareFromJunction(junction, curEdge.axisDirection, Mathf.Min(distanceAlongEdge * 2, distanceAlongAxis));

        if (!checkSquareConsistency(square))
        {
            square.delete();
            return(false);
        }
        if (!checkOverlaps(square))
        {
            square.delete();
            return(false);
        }
        updateLists(square, curEdge, junction, squares, true, false);
        return(true);
    }