public TerrainGenerator(Terrain terrain)
    {
        td = terrain.terrainData;
        terrain.detailObjectDistance = 2000;
        //Creates a new 2D array, the same size resolution as the heightmap.
        HeightMap = new float[td.heightmapWidth, td.heightmapHeight];
        //Sets the renderer as the texture
        //renderer.material.mainTexture = texture;


        td.splatPrototypes = initialiseSplatPrototypes();
        initialiseHills();
        Average(45, td.heightmapWidth, td.heightmapHeight);


        int[][] patchcoords = Cliff.setCliffPatch(200, 200, 240, 270, 0.7f, 0.71f);
        Cliff.setHillPatch(500, 700, -0.3f, 100);
        setPondPatch(800, 400, 0.3f, 100);
        //cliffCircleCutout (patchcoords, 25);

        int[] circlecoords = Cliff.setCircularCliffPatch(700, 400, 100, 2048, 0.75f, 0.74f);
        TERRAIN_HEIGHT = HeightMap[1, 1];

        //setQuadraticCliffPatch(400,300,350,450);

        Cliff.quadraticCliffPatchController(400, 300, 370, 430, 88, 0.1f, 0.9f, 15, -1 * 0.005f);

        //createPathToCliff (700,400,120,Mathf.PI,HeightMap[5,5],true);
        //createPathToCliff (700,400,100,Mathf.PI*2,HeightMap[5,5],true);
        Average(4, td.heightmapWidth, td.heightmapHeight);

        // Sets the heightmap of the terrain equal to the height map we just generated.
        td.SetHeights(0, 0, HeightMap);
    }
    // Use this for initialization


    /*
     * Sets a patch of terrain to a different height to the rest of the terrain. Useful for creating mountains and valleys.
     * The core code is to be used for splitting up the terrain into segments, so that different terrain details
     * can be applied to different parts of the map
     * LIMITATION: Only allows for squares or rectangles.
     * */



    void setPondPatch(int x, int z, float depth, int spread)
    {
        Vector3 waterVector = new Vector3(x, z, 0);

        Cliff.setHillPatch(x, z, depth, spread);

        Vector3    position = new Vector3(x + 530, 281, z + 520);
        GameObject pond     = (GameObject)Instantiate(Resources.Load("waterPond"), position, Quaternion.identity);
    }
示例#3
0
 /// <summary>
 /// The constructor.
 /// </summary>
 public Sensors(Robot _robot)
     : base(_robot)
 {
     Bumps             = new Bump(_robot);
     Wheeldrops        = new Wheeldrop(_robot);
     Cliffs            = new Cliff(_robot);
     MotorOvercurrents = new MotorOvercurrent(_robot);
     DirtDetectors     = new DirtDetector(_robot);
     Buttons           = new Button(_robot);
 }
示例#4
0
文件: MapCell.cs 项目: SAubrey/DotS
    public static MapCell create_cell(int ID, int tier, Tile tile, Pos pos)
    {
        MapCell mc = null;

        // Don't extract name from tile if provided.
        if (ID == PLAINS_ID)
        {
            mc = new Plains(tier, tile, pos);
        }
        else if (ID == FOREST_ID)
        {
            mc = new Forest(tier, tile, pos);
        }
        else if (ID == RUINS_ID)
        {
            mc = new Ruins(tier, tile, pos);
        }
        else if (ID == CLIFF_ID)
        {
            mc = new Cliff(tier, tile, pos);
        }
        else if (ID == CAVE_ID)
        {
            mc = new Cave(tier, tile, pos);
        }
        else if (ID == STAR_ID)
        {
            mc = new Star(tier, tile, pos);
        }
        else if (ID == TITRUM_ID)
        {
            mc = new Titrum(tier, tile, pos);
        }
        else if (ID == LUSH_LAND_ID)
        {
            mc = new LushLand(tier, tile, pos);
            //} else if (name == MIRE) {
            //mc = new Mire(tier, tile, pos);
        }
        else if (ID == MOUNTAIN_ID)
        {
            mc = new Mountain(tier, tile, pos);
        }
        else if (ID == SETTLEMENT_ID)
        {
            mc = new Settlement(tier, tile, pos);
        }
        else if (ID == RUNE_GATE_ID)
        {
            mc = new RuneGate(tier, tile, pos);
        }
        else if (ID == CITY_ID)
        {
            mc = new CityCell(tier, tile, pos);
        }
        else if (ID == GUARDIAN_PASS_ID)
        {
            mc = new GuardianPass(tier, tile, pos);
        }
        else if (ID == CITY_ID)
        {
            mc = new CityCell(tier, tile, pos);
        }
        else
        {
            mc = new MapCell(0, tier, tile, pos);
        }
        //mc.tile_type_ID = tile_type_ID;
        return(mc);
    }
示例#5
0
 /// <summary>
 /// The constructor.
 /// </summary>
 public Sensors(Robot _robot)
     : base(_robot)
 {
     Bumps = new Bump(_robot);
     Wheeldrops = new Wheeldrop(_robot);
     Cliffs = new Cliff(_robot);
     MotorOvercurrents = new MotorOvercurrent(_robot);
     DirtDetectors = new DirtDetector(_robot);
     Buttons = new Button(_robot);
 }