コード例 #1
0
ファイル: CatwalkGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genFootballPosts(VoxelTheme voxelTheme, IntVector3 destination, int width, int addedHeight)
    {
        int cageHeight=5;
        int[,,] newData = genMapDataFromPoint (destination, width,addedHeight+cageHeight);

        int iSize = newData.GetLength (0);
        int jSize = newData.GetLength (1);
        if (iSize < 3 || width<3 || jSize/iSize>1)
            return genBasic (voxelTheme, destination, width);

        IntVector3 lastHopPoint = new IntVector3 (0, 0, -1);
        int stepSpacing=5;
        foreach (IntVector3 hopPoint in getHopArray(iSize,jSize-addedHeight,stepSpacing)) {
            IntVector3 offset = new IntVector3 (hopPoint.x, hopPoint.y+addedHeight-1, 0);
            int[,,] cageData=new int[1,cageHeight-1,width];
            cageData=MDController.combine(cageData,GreebleGenerator.genCage(voxelTheme,1,cageHeight,width));
            newData = MDController.combine (newData, cageData, offset);
            if (lastHopPoint.z != -1) {
                offset = new IntVector3 (lastHopPoint.x,0,width/2);
                int underhangAddedHeight=Mathf.Min (hopPoint.y,lastHopPoint.y)+addedHeight;
                int[,,] underhangData=ShapeGenerator.genUnderhang(voxelTheme, hopPoint,lastHopPoint,underhangAddedHeight);
                newData = MDController.combine (newData, underhangData, offset);
            }
            lastHopPoint = hopPoint;
        }

        return rotateMapData (newData, destination);
    }
コード例 #2
0
ファイル: PlatformGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] gen(VoxelTheme voxelTheme, IntVector3 size)
    {
        int [,,] mapData = new int[size.x, size.y, size.z];

        int maxPercent = 30;
        int engineCount = 0;
        int percent = Random.Range (0, maxPercent);
        int iSquare = size.x * percent / 100;
        int kSquare = size.z * (maxPercent - percent - 1) / 100;

        Square baseSquare = new Square (iSquare, kSquare, size.x - 2 * iSquare, size.z - 2 * kSquare);
        mapData = MDController.combine (mapData, genPlatformBase (voxelTheme, size.x, size.z, baseSquare), 0, 0, 0);
        mapData = MDController.combine (mapData, genPlatformPlate (voxelTheme, baseSquare.width, baseSquare.height), baseSquare.x, 1, baseSquare.y);

        int minFractalSpacing = 1;
        foreach (Square square in ZTools.getFractalSquares(new Square( 0,0,baseSquare.width ,baseSquare.height),minFractalSpacing)) {
            int i = square.x + baseSquare.x;
            int k = square.y + baseSquare.y;
            int j = 1 + MDView.getMapHeight (mapData, i + square.width / 2, k + square.height / 2);
            mapData = MDController.combine (mapData, GreebleGenerator.gen (voxelTheme, square.width, size.y - j, square.height), i, j, k);
            if (Random.Range (0, engineCount / 3 + 1) == 0) {
                if (mapData.GetLength (1) > j)
                    mapData [i + square.width / 2, j, k + square.height / 2] = voxelTheme.getCode ("engine");
                engineCount++;
            }
        }

        return mapData;
    }
コード例 #3
0
ファイル: PlatformGenerator.cs プロジェクト: Zulban/viroid
    private static int[,,] genPlatformPlate(VoxelTheme voxelTheme, int width, int depth)
    {
        //Debug.Log("genPlatformPlate "+width+" "+depth);
        int maxHeight = 3;
        int [,,] mapData = new int[width, maxHeight, depth];

        int temp = (int)Mathf.Sqrt (width * depth);
        int plateCount = Random .Range (temp / 2 + 1, temp * 2 + 1);

        for (int i=0; i<plateCount; i++) {
            int itemWidth = Random.Range (2, (int)Mathf.Sqrt (width) + 1);
            int itemHeight = Random.Range (1, maxHeight + 1);
            int itemDepth = Random.Range (2, (int)Mathf.Sqrt (depth) + 1);

            int iOffset = Random.Range (0, width - itemWidth);
            int kOffset = Random.Range (0, depth - itemDepth);

            int plateType = Random .Range (0, 7);

            if (plateType == 0)
                //prism
                mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelTheme.getCode ("hull"), itemWidth, itemHeight, itemDepth), iOffset, 0, kOffset);
            if (plateType == 1) {
                //cylinder
                for (int h=0; h<itemHeight; h++)
                    mapData = MDController.combine (mapData, ShapeGenerator.genCircle (voxelTheme.getCode ("hull"), itemWidth), iOffset, h, kOffset);
            }
            if (plateType == 2)
                //hollow square
                mapData = MDController.combine (mapData, GreebleGenerator.genCage (voxelTheme, itemWidth, 1, itemDepth), iOffset, 0, kOffset);
            if (plateType == 3) {
                //rounded prism
                mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelTheme.getCode ("hull"), itemWidth, 1, itemDepth), iOffset, 0, kOffset);
                if (itemWidth > 2 && itemDepth > 2)
                    mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelTheme.getCode ("hull"), itemWidth - 2, 1, itemDepth - 2), iOffset + 1, 1, kOffset + 1);
            }
            if (plateType == 4)
                //perimeter fence
                mapData = MDController.combine (mapData, GreebleGenerator.genCage (voxelTheme, width, 1, depth), 0, 0, 0);
            if (plateType == 5 && itemWidth > 3) {
                //tunnel prism
                mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelTheme.getCode ("hull"), itemWidth / 2, itemHeight, itemDepth), iOffset, 0, kOffset);
                mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelTheme.getCode ("hull"), itemWidth / 2 - 1, itemHeight, itemDepth), iOffset + itemWidth / 2 + 1, 0, kOffset);
            }
            if (plateType == 6) {
                //partial perimeter fence
                int side = Random .Range (0, 2);
                if (Random .Range (0, 2) == 0) {
                    mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelTheme.getCode ("hull"), width, itemHeight * 2, 1), 0, 0, depth * side);
                } else {
                    mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelTheme.getCode ("hull"), 1, itemHeight * 2, depth), width * side, 0, 0);
                }
            }
        }

        return mapData;
    }
コード例 #4
0
ファイル: StationGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genDebug(VoxelTheme voxelTheme)
    {
        int width=60;
        int height=30;
        int depth=60;
        int[,,] mapData = new int[width, height, depth];
        int voxelCode = voxelTheme.getCode ("default");
        mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelCode, width, 1, depth));

        mapData=MDController.combine(mapData,genFloor(voxelTheme,60),0,1,0);

        return mapData;
    }
コード例 #5
0
ファイル: JunkGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] gen(VoxelTheme voxelTheme, IntVector3 junkSize)
    {
        size=junkSize;

        junkTheme = voxelTheme;

        int [,,] mapData = new int[size.x, size.y, size.z];

        int junkMax = (int)Mathf.Sqrt (Mathf.Min (size.x, size.y, size.z)) + 1;
        for (int i=0; i<junkMax; i++)
            addRandomJunk (mapData);

        return MDController.trim (mapData);
    }
コード例 #6
0
ファイル: StationGenerator.cs プロジェクト: Zulban/viroid
    private static int[,,] genFloor(VoxelTheme voxelTheme, int diameter)
    {
        int floorHeight=diameter/4;
        int floorCode=voxelTheme.getCode("hull");
        int[,,] newData = new int[diameter,floorHeight,diameter];

        int catwalkWidth=3;
        int offset=diameter/2-catwalkWidth/2;
        newData=MDController.combine(newData,ShapeGenerator.genPrism(floorCode,diameter,1,catwalkWidth),0,0,offset);
        newData=MDController.combine(newData,ShapeGenerator.genPrism(floorCode,catwalkWidth,1,diameter),offset,0,0);

        int innerDiameter=diameter/4;
        offset=diameter/2-innerDiameter/2;
        newData=MDController.subtract(newData,ShapeGenerator.genCircle(floorCode,innerDiameter),offset,0,offset);
        newData=MDController.combine(newData,ShapeGenerator.genDonut(floorCode,innerDiameter),offset,0,offset);

        return newData;
    }
コード例 #7
0
ファイル: PlatformGenerator.cs プロジェクト: Zulban/viroid
    private static int[,,] genPlatformBase(VoxelTheme voxelTheme, int width, int depth, Square square)
    {
        int [,,] newData = new int[width, 1, depth];

        int gravityCode = voxelTheme.getCode ("gravity plate");
        int [,,] prismData = ShapeGenerator.genPrism (gravityCode, square.width, 1, square.height);
        MDController.combine (newData, prismData, square.x, 0, square.y);

        for (int side=0; side<2; side++) {
            int [,,] spikeData = genPlatformSpikes (voxelTheme.getCode ("hull"), square.width, square.y);
            int angle = (1 - side) * 180;
            int kOffset = side * (square.y + square.height);
            MDController.combine (newData, MDController.jRotate (spikeData, angle), square.x, 0, kOffset);
        }

        for (int side=0; side<2; side++) {
            int [,,] spikeData = genPlatformSpikes (voxelTheme.getCode ("hull"), square.height, square.x);
            int angle = (1 - side) * 180 + 90;
            int iOffset = side * (square.x + square.width);
            MDController.combine (newData, MDController.jRotate (spikeData, angle), iOffset, 0, square.y);
        }

        return newData;
    }
コード例 #8
0
ファイル: GreebleGenerator.cs プロジェクト: Zulban/viroid
 public static int[,,] gen(VoxelTheme voxelTheme, IntVector3 size)
 {
     return gen (voxelTheme,size.x,size.y,size.z);
 }
コード例 #9
0
ファイル: GreebleGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genCage(VoxelTheme voxelTheme, int width, int height, int depth)
    {
        //Debug.Log ("genCage " + width + " " + height + " " + depth);
        int[,,] newData = ShapeGenerator.genPrism (voxelTheme.getCode ("side"), width, height, depth);

        if (height > 2)
            newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("up"), width, height - 2, depth), 0, 1, 0);

        for (int iOffset=0; iOffset<2; iOffset++) {
            for (int jOffset=0; jOffset<2; jOffset++) {
                for (int kOffset=0; kOffset<2; kOffset++) {
                    IntVector3 point=new IntVector3(iOffset * (width - 1),
                    jOffset * (height - 1),
                    kOffset * (depth - 1));

                    if (MDView.isInsideMapData (newData, point))
                        newData [point.x,point.y,point.z] = voxelTheme.getCode ("block");
                }
            }
        }

        if (width > 2 && height > 2)
            newData = MDController.subtract (newData, ShapeGenerator.genPrism (1, width - 2, height - 2, depth), 1, 1, 0);

        if (width > 2 && depth > 2)
            newData = MDController.subtract (newData, ShapeGenerator.genPrism (1, width - 2, height, depth - 2), 1, 0, 1);

        if (height > 2 && depth > 2)
            newData = MDController.subtract (newData, ShapeGenerator.genPrism (1, width, height - 2, depth - 2), 0, 1, 1);

        return newData;
    }
コード例 #10
0
ファイル: GreebleGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] gen(VoxelTheme voxelTheme, int width, int height, int depth)
    {
        //the culmination of this entire module, packaged into one glorious function!
        int greebleTypeCount = 11;
        int smallestSize = width;
        int biggestSize = width;
        if (width < depth) {
            biggestSize = depth;
        } else {
            smallestSize = depth;
        }

        //Debug.Log("soft code:"+softCode+" upCode:" +upCode);

        int maxAttempts = 100;

        for (int attemptCount=0; attemptCount<maxAttempts; attemptCount++) {
            int greebleIndex = Random.Range (0, greebleTypeCount);
            if (greebleIndex == 0) {
                if (biggestSize > 4)
                    continue;

                int greebleHeight = Random.Range (smallestSize, smallestSize * 2);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genBattery (voxelTheme.getCode ("up"), voxelTheme.getCode ("plate"), width, greebleHeight, depth);
            }

            if (greebleIndex == 1) {
                if (smallestSize < 4)
                    continue;

                int greebleHeight = Random.Range (smallestSize * 2, smallestSize * 5);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genCageAntenna (voxelTheme, width, greebleHeight, depth);
            }

            if (greebleIndex == 2) {
                if (biggestSize > 4)
                    continue;

                int greebleHeight = Random.Range (smallestSize, smallestSize * 2);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genCapacitor (voxelTheme.getCode ("up"), voxelTheme.getCode ("plate"), width, greebleHeight, depth);
            }

            if (greebleIndex == 3) {
                if (smallestSize < 3)
                    continue;

                int greebleHeight = Random.Range (smallestSize * 2, smallestSize * 5);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genCoilTower (voxelTheme, width, greebleHeight, depth);
            }

            if (greebleIndex == 4) {
                if (smallestSize < 6)
                    continue;

                int greebleHeight = Random.Range (smallestSize / 3, smallestSize * 3 / 2);
                if (greebleHeight < 3)
                    greebleHeight = 3;
                if (greebleHeight > height)
                    greebleHeight = height;
                return genMushroom (voxelTheme.getCode ("plate"), voxelTheme.getCode ("block"), voxelTheme.getCode ("soft"), width, greebleHeight, depth);
            }

            if (greebleIndex == 5) {
                int greebleHeight = Random.Range (biggestSize / 2, biggestSize * 3);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genRingAntenna (voxelTheme, width, greebleHeight, depth);
            }

            if (greebleIndex == 6) {
                int greebleHeight = Random.Range (biggestSize / 2, biggestSize * 5);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genTwisty (voxelTheme, width, greebleHeight, depth);
            }

            if (greebleIndex == 7) {
                if (smallestSize < 3 || height < 3)
                    continue;

                int greebleHeight = Random.Range (biggestSize, biggestSize * 3);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genWillow (voxelTheme, width, greebleHeight, depth);
            }

            if (greebleIndex == 8) {
                int greebleHeight = Random.Range (smallestSize / 2, smallestSize * 2);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genComb (voxelTheme.getCode ("block"), width, greebleHeight, depth);
            }

            if (greebleIndex == 9) {
                int greebleHeight = Random.Range (smallestSize / 2, smallestSize * 2);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genCircleComb (voxelTheme.getCode ("block"), width, greebleHeight, depth);
            }

            if (greebleIndex == 10) {
                int greebleHeight = Random.Range (smallestSize * 3, smallestSize * 9);
                if (greebleHeight > height)
                    greebleHeight = height;
                return genSatellite (voxelTheme.getCode ("up"), voxelTheme.getCode ("soft"), width, greebleHeight, depth);
            }

        }

        Debug.Log ("genGreeble failed after " + maxAttempts + " attempts.");
        return new int[width, height, depth];
    }
コード例 #11
0
ファイル: GreebleGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genCageAntenna(VoxelTheme voxelTheme, int width, int height, int depth)
    {
        int[,,] newData = new int[width, height, depth];
        newData = MDController.combine (newData, genCage (voxelTheme, width, height + 1, depth));

        int stepMax = (int)Mathf.Sqrt (height);
        int jOffset = 0;
        int bodyHeight = Random.Range (height / 2, height * 5 / 6);

        while (jOffset<bodyHeight) {
            int cageHeight = Random.Range (3, stepMax + 3);
            newData = MDController.combine (newData, genCage (voxelTheme, width, cageHeight, depth), 0, jOffset, 0);
            jOffset += cageHeight - 1;
        }

        return newData;
    }
コード例 #12
0
ファイル: CatwalkGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genDebug(VoxelTheme voxelTheme, int width, int height, int depth)
    {
        /*
        a series of unit tests for CatwalkGenerator
        */

        int[,,] mapData = new int[width, height, depth];
        int voxelCode = voxelTheme.getCode ("default");
        mapData = MDController.combine (mapData, ShapeGenerator.genPrism (voxelCode, width, 1, depth));

        IntVector3 destination = new IntVector3 (0, 0, 0);
        IntVector3 offset = new IntVector3 (0, 0, 0);
        int jOffset=1;

        /*
        destination=new IntVector3(5,2,0);
        offset=new IntVector3(5,jOffset,5);
        mapData=MDController.combine(mapData,genBasic(voxelTheme,destination,3),offset);

        destination=new IntVector3(-5,2,0);
        offset=new IntVector3(15,jOffset,5);
        mapData=MDController.combine(mapData,genBasic(voxelTheme,destination,3),offset);

        destination=new IntVector3(0,2,5);
        offset=new IntVector3(25,jOffset,5);
        mapData=MDController.combine(mapData,genBasic(voxelTheme,destination,3),offset);
        */

        /*
        destination = new IntVector3 (8, 5, 0);
        offset = new IntVector3 (5, jOffset, 5);
        mapData = MDController.combine (mapData, genPillarSteps (voxelTheme, destination,3), offset);

        destination = new IntVector3 (14, -8, 0);
        offset = new IntVector3 (5, jOffset, 10);
        mapData = MDController.combine (mapData, genPillarSteps (voxelTheme, destination, 3), offset);

        destination = new IntVector3 (0, 2, 5);
        offset = new IntVector3 (5, jOffset, 15);
        mapData = MDController.combine (mapData, genPillarSteps (voxelTheme, destination, 3), offset);
        */

        /*
        destination = new IntVector3 (8, 5, 0);
        offset = new IntVector3 (5, jOffset, 5);
        mapData = MDController.combine (mapData, genLilypads (voxelTheme, destination, 1), offset);

        destination = new IntVector3 (14, -4, 0);
        offset = new IntVector3 (5, jOffset, 10);
        mapData = MDController.combine (mapData, genLilypads (voxelTheme, destination, 2), offset);

        destination = new IntVector3 (0, 2, 5);
        offset = new IntVector3 (5, jOffset, 15);
        mapData = MDController.combine (mapData, genLilypads (voxelTheme, destination, 3), offset);
        */

        destination = new IntVector3 (8, 5, 0);
        offset = new IntVector3 (5, jOffset, 5);
        mapData = MDController.combine (mapData, genFootballPosts (voxelTheme, destination,5,2), offset);

        destination = new IntVector3 (14, -4, 0);
        offset = new IntVector3 (5, jOffset, 10);
        mapData = MDController.combine (mapData, genFootballPosts (voxelTheme, destination, 6,3), offset);

        destination = new IntVector3 (0, 2, 5);
        offset = new IntVector3 (5, jOffset, 15);
        mapData = MDController.combine (mapData, genFootballPosts (voxelTheme, destination, 9,1), offset);

        return mapData;
    }
コード例 #13
0
ファイル: CatwalkGenerator.cs プロジェクト: Zulban/viroid
 private static int[,,] genBasic(VoxelTheme voxelTheme, IntVector3 destination, int width)
 {
     return genBasic (voxelTheme, destination, width, true);
 }
コード例 #14
0
ファイル: CatwalkGenerator.cs プロジェクト: Zulban/viroid
    private static int[,,] genBasic(VoxelTheme voxelTheme, IntVector3 destination, int width, bool rotate)
    {
        //generally used when size requirements are not met but a catwalk must be made.
        int[,,] newData = genMapDataFromPoint (destination, width);
        int voxelCode = voxelTheme.getCode ("block");

        Prism prism = new Prism (0, 0, 0, 1, newData.GetLength (1), newData.GetLength (2));
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelCode, prism));

        prism = new Prism (0, 0, 0, newData.GetLength (0), 1, newData.GetLength (2));
        IntVector3 offset = new IntVector3 (0, 0, 0);
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelCode, prism), offset);

        if (rotate)
            return rotateMapData (newData, destination);
        return newData;
    }
コード例 #15
0
ファイル: CatwalkGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genPillarSteps(VoxelTheme voxelTheme, IntVector3 destination, int width)
    {
        int[,,] newData = genBasic (voxelTheme, destination, width, false);

        int iSize = newData.GetLength (0);
        int jSize = newData.GetLength (1);
        if (iSize < 4)
            return genBasic (voxelTheme, destination, width);

        int stepCode = voxelTheme.getCode ("up");
        int kOffset = width / 2;

        int stepSpacing=3;
        foreach (IntVector3 hopPoint in getHopArray(iSize,jSize,stepSpacing)) {
            int stepHeight = hopPoint.y+1;
            IntVector3 offset = new IntVector3 (hopPoint.x, 0, kOffset);
            newData = MDController.combine (newData, ShapeGenerator.genPrism (stepCode, 1, stepHeight, 1), offset);
        }

        return rotateMapData (newData, destination);
    }
コード例 #16
0
ファイル: GreebleGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genCoilTower(VoxelTheme voxelTheme, int width, int height, int depth)
    {
        //Debug.Log("genCoilTower "+width+" "+height+" "+depth);
        int[,,] newData = new int[width, height, depth];

        int diameter = width >= depth ? depth : width;

        int stemWidth = Mathf.CeilToInt ((float)diameter / 2);
        int center = diameter / 2 - stemWidth / 2;
        int stemOffset = 0;
        if (diameter % 2 == 0 && stemWidth % 2 == 1)
            stemOffset = 1;

        if ((diameter % 2 == 1) ^ (stemWidth % 2 == 1)) {
            //stemWidth++;
        }

        int stepSize = Random.Range (2 + height / 10, (int)Mathf.Sqrt (height) + 1);
        stepSize = stepSize < 2 + height / 10 ? 2 + height / 10 : stepSize;

        for (int kOffset=stepSize; kOffset<height; kOffset+=stepSize) {
            newData = MDController.combine (newData, ShapeGenerator.genDonut (voxelTheme.getCode ("plate"), diameter, stemWidth), 0, kOffset, 0);
        }
        newData = MDController.combine (newData, genCage (voxelTheme, stemWidth - stemOffset, height + 2, stemWidth - stemOffset), center, -1, center);

        return newData;
    }
コード例 #17
0
ファイル: GreebleGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genRingAntenna(VoxelTheme voxelTheme, int width, int height, int depth)
    {
        //Debug.Log("genRingAntenna "+width+" "+height+" "+depth);
        int[,,] newData = new int[width, height, depth];

        int ringWidth = Random.Range (1, (int)Mathf .Sqrt (width + depth));
        int stemWidth = ringWidth < 3 ? ringWidth : 2;

        for (int offset=0; offset<ringWidth; offset++) {
            newData = MDController.combine (newData, genCage (voxelTheme, width - offset * 2, 1, depth - offset * 2), offset, height - 1, offset);
        }
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("block"), stemWidth, height - 1, stemWidth), width / 2 - stemWidth / 2, 0, 0);
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("techno"), stemWidth, 1, stemWidth), width / 2 - stemWidth / 2, height / 3, 0);
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("techno"), stemWidth, 1, stemWidth), width / 2 - stemWidth / 2, height * 2 / 3, 0);

        if (width == depth) {
            newData = MDController .jRotate (newData, Random .Range (0, 4) * 90);
        } else {
            newData = MDController .jRotate (newData, Random .Range (0, 2) * 180);
        }

        return newData;
    }
コード例 #18
0
ファイル: GreebleGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genWillow(VoxelTheme voxelTheme, int width, int height, int depth)
    {
        int[,,] newData = new int[width, height, depth];

        int iCenter = width / 2;
        int kCenter = depth / 2;

        int trunkWidth = (int)Mathf .Sqrt (width + height) / 4 + 1;

        int canopyWidth = width > 3 ? width - 2 : 1;
        int canopyDepth = depth > 3 ? depth - 2 : 1;

        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("block"), trunkWidth, height, trunkWidth), iCenter, 0, kCenter);
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("soft"), trunkWidth, height / 5 + 1, trunkWidth), iCenter, height * 4 / 5 - 1, kCenter);
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("plate"), canopyWidth, 1, canopyDepth), 1, height - 1, 1);

        int branchHeight = Random.Range (height / 3, height * 3 / 4);

        for (int swap=0; swap<2; swap++) {
            for (int full=0; full<2; full++) {
                float iRatio = full;
                float kRatio = 1f / 2f;

                if (swap == 1) {
                    float temp = iRatio;
                    iRatio = kRatio;
                    kRatio = temp;
                }

                int i = Mathf.FloorToInt ((width-1) * iRatio);
                int k = Mathf.FloorToInt ((depth-1) * kRatio);

                newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("block"), 1, branchHeight, 1), i, height - branchHeight, k);
            }
        }

        return newData;
    }
コード例 #19
0
ファイル: GreebleGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genTwisty(VoxelTheme voxelTheme, int width, int height, int depth)
    {
        //Debug.Log("genTwisty "+width+" "+height+" "+depth);
        int[,,] newData = new int[width, height, depth];
        if (width==0||height==0||depth==0)
            return newData;

        int maxStep = Random.Range (3, (int)Mathf.Sqrt (height) + 3);

        IntVector3 point = new IntVector3 (width / 2, 0, depth / 2);
        IntVector3 lastPoint = new IntVector3 (0, 0, 0);

        int iterCount = 0;
        int side = 0;
        int directionCount = 0;
        int randomCase = 10;
        int voxelCode = voxelTheme.getCode ("block");

        newData [point.x, point.y, point.z] = voxelCode;
        while (iterCount<200) {
            iterCount ++;
            directionCount ++;

            //newData [point.i, point.j, point.k] = voxelCode;

            if (randomCase < 2) {
                point.x += side;
                voxelCode = voxelTheme.getCode ("side");
            }
            if (randomCase >= 2 && randomCase < 4) {
                point.z += side;
                voxelCode = voxelTheme.getCode ("side");
            }
            if (randomCase == 4) {
                point.y -= 1;
                voxelCode = voxelTheme.getCode ("soft");
                ;
            }
            if (randomCase > 4) {
                point.y += 1;
                voxelCode = voxelTheme.getCode ("up");
            }

            if (directionCount > maxStep || Random.Range (0, 10) > directionCount) {
                randomCase = Random.Range (0, 10);
                directionCount = 0;
                side = Random.Range (0, 2) * 2 - 1;
            }

            if (MDView.isInsideMapData (newData, point)) {
                newData [point.x, point.y, point.z] = voxelCode;
                lastPoint = point;
            } else {
                if (point.y >= height - 1)
                    break;
                point = lastPoint;
                directionCount = 100;
            }
        }
        //Debug.Log (iterCount);
        return newData;
    }
コード例 #20
0
ファイル: CatwalkGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genLilypads(VoxelTheme voxelTheme, IntVector3 destination, int addedHeight)
    {
        int kSize = 3;
        int[,,] newData = genMapDataFromPoint (destination, kSize,addedHeight);

        int iSize = newData.GetLength (0);
        int jSize = newData.GetLength (1);
        if (iSize < 6 || jSize < 2)
            return genBasic (voxelTheme, destination, 1);

        int padCode = voxelTheme.getCode ("plate");

        IntVector3 lastHopPoint = new IntVector3 (0, 0, -1);
        int stepSpacing=5;
        foreach (IntVector3 hopPoint in getHopArray(iSize,jSize-addedHeight,stepSpacing)) {
            IntVector3 offset = new IntVector3 (hopPoint.x - 1, hopPoint.y+addedHeight-1, 0);
            newData = MDController.combine (newData, ShapeGenerator.genPrism (padCode, 3, 1, 3), offset);
            if (lastHopPoint.z != -1) {
                offset = new IntVector3 (lastHopPoint.x,0,kSize/2);
                int underhangAddedHeight=Mathf.Min (hopPoint.y,lastHopPoint.y)+addedHeight;
                int[,,] underhangData=ShapeGenerator.genUnderhang(voxelTheme, hopPoint,lastHopPoint,underhangAddedHeight);
                newData = MDController.combine (newData, underhangData, offset);
            }
            lastHopPoint = hopPoint;
        }

        return rotateMapData (newData, destination);
    }
コード例 #21
0
ファイル: ShapeGenerator.cs プロジェクト: Zulban/viroid
    public static int[,,] genUnderhang(VoxelTheme voxelTheme, IntVector3 point1, IntVector3 point2, int addedHeight)
    {
        Prism prism = ZTools.getPrismFromPoints (point1, point2);
        prism.height += addedHeight;
        int[,,] newData = new int[prism.width, prism.height, prism.depth];

        IntVector3 offset = new IntVector3 (point1.x - prism.x, 0, point1.z - prism.z);
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("block"), 1, point1.y-prism.y+addedHeight, 1), offset);
        offset = new IntVector3 (point2.x - prism.x, 0, point2.z - prism.z);
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelTheme.getCode ("block"), 1, point2.y-prism.y+addedHeight, 1), offset);

        newData = MDController.combine (newData, GreebleGenerator.genCage (voxelTheme, prism.width, 1, prism.depth));

        return newData;
    }