Ejemplo n.º 1
0
    //This function gives us a Y depending on the node position to the other
    private int GetYForNeighbor(Vector2Int leftNodeUp, Vector2Int leftNodeDown, Vector2Int rightNodeUp, Vector2Int rightNodeDown)
    {
        if (rightNodeUp.y >= leftNodeUp.y && leftNodeDown.y >= rightNodeDown.y)
        {
            return(StructureHelper.CalculateCenter(rightNodeDown + new Vector2Int(0, wallDistanceModifier),
                                                   rightNodeUp - new Vector2Int(0, wallDistanceModifier + this.corridorWidth)).y);
        }

        if (rightNodeUp.y <= leftNodeUp.y && leftNodeDown.y <= rightNodeDown.y)
        {
            return(StructureHelper.CalculateCenter(leftNodeDown + new Vector2Int(0, wallDistanceModifier),
                                                   leftNodeUp - new Vector2Int(0, wallDistanceModifier + this.corridorWidth)).y);
        }

        if (leftNodeUp.y >= rightNodeDown.y && leftNodeUp.y <= rightNodeUp.y)
        {
            return(StructureHelper.CalculateCenter(rightNodeDown + new Vector2Int(0, wallDistanceModifier),
                                                   leftNodeUp - new Vector2Int(0, wallDistanceModifier + this.corridorWidth)).y);
        }

        if (leftNodeDown.y >= rightNodeDown.y && leftNodeDown.y <= rightNodeUp.y)
        {
            return(StructureHelper.CalculateCenter(leftNodeDown + new Vector2Int(0, wallDistanceModifier),
                                                   rightNodeUp - new Vector2Int(0, wallDistanceModifier + this.corridorWidth)).y);
        }

        return(checkValue);
    }
Ejemplo n.º 2
0
    private int GetXForNeighbor(Vector2Int bottomNodeLeft, Vector2Int bottomNodeRight, Vector2Int topNodeLeft, Vector2Int topNodeRight)
    {
        if (topNodeLeft.x < bottomNodeLeft.x && bottomNodeRight.x < topNodeRight.x)
        {
            return(StructureHelper.CalculateCenter(bottomNodeLeft + new Vector2Int(wallDistanceModifier, 0), bottomNodeRight - new Vector2Int(this.corridorWidth + wallDistanceModifier, 0)).x);
        }

        if (topNodeLeft.x >= bottomNodeLeft.x && bottomNodeRight.x >= topNodeRight.x)
        {
            return(StructureHelper.CalculateCenter(topNodeLeft + new Vector2Int(wallDistanceModifier, 0), topNodeRight - new Vector2Int(this.corridorWidth + wallDistanceModifier, 0)).x);
        }

        if (bottomNodeLeft.x >= topNodeLeft.x && bottomNodeLeft.x <= topNodeRight.x)
        {
            return(StructureHelper.CalculateCenter(bottomNodeLeft + new Vector2Int(wallDistanceModifier, 0), topNodeRight - new Vector2Int(this.corridorWidth + wallDistanceModifier, 0)).x);
        }

        if (bottomNodeRight.x <= topNodeRight.x && bottomNodeRight.x >= topNodeLeft.x)
        {
            return(StructureHelper.CalculateCenter(topNodeLeft + new Vector2Int(wallDistanceModifier, 0), bottomNodeRight - new Vector2Int(this.corridorWidth + wallDistanceModifier, 0)).x);
        }

        return(checkValue);
    }