Пример #1
0
    public GameObject desertBiome(int xIndex, int yIndex)
    {
        desertAmbient.Play();
        Biome      biome   = new Biome();
        GameObject terrain = Instantiate(
            terrainTilePrefab,
            new Vector3(terrainSize.x * xIndex, terrainSize.y, terrainSize.z * yIndex),
            Quaternion.identity
            );

        terrain.name = TrimEnd(terrain.name, "(Clone)") + " [" + xIndex + " , " + yIndex + "]";

        terrianControl.terrainTiles.Add(new Vector2(xIndex, yIndex), terrain);
        // Debug.Log("Hill Biome");
        GenerateMeshSimple gm = terrain.GetComponent <GenerateMeshSimple>();

        gm.TerrainSize = new Vector3(20, 1, 20);;
        gm.Gradient    = desertGradient;
        gm.NoiseScale  = 3f;
        gm.CellSize    = 1f;
        gm.NoiseOffset = NoiseOffsetHill(xIndex, yIndex);
        gm.Generate();

        SpawnEntity.dustStorm(terrain.transform.position);
        SpawnEntity.Rock(terrain.transform.position);
        SpawnEntity.Mountain(terrain.transform.position);
        return(terrain);
    }
Пример #2
0
    //Testing a way to approach biomes
    public GameObject plainsBiome(int xIndex, int yIndex)
    {
        Biome      biome   = new Biome();
        GameObject terrain = Instantiate(
            terrainTilePrefab,
            new Vector3(terrainSize.x * xIndex, terrainSize.y, terrainSize.z * yIndex),
            Quaternion.identity
            );

        terrain.name = TrimEnd(terrain.name, "(Clone)") + " [" + xIndex + " , " + yIndex + "]";

        terrianControl.terrainTiles.Add(new Vector2(xIndex, yIndex), terrain);
        //  Debug.Log("Plain Biome");
        GenerateMeshSimple gm = terrain.GetComponent <GenerateMeshSimple>();

        gm.TerrainSize = terrainSize;
        gm.Gradient    = plainsGradient;
        gm.NoiseScale  = 3f;
        gm.CellSize    = 1f;
        gm.NoiseOffset = NoiseOffsetPlains(xIndex, yIndex);
        gm.Generate();
        SpawnEntity.Grass(terrain.transform.position);
        SpawnEntity.Grass(terrain.transform.position);
        SpawnEntity.Grass(terrain.transform.position);
        SpawnEntity.Grass(terrain.transform.position);
        return(terrain);
    }
Пример #3
0
    private GameObject CreateTile(int xIndex, int yIndex)
    {
        Vector3    tilePosition = new Vector3(terrainSize.x * xIndex, terrainSize.y + transform.position.y, terrainSize.z * yIndex);
        GameObject terrain      = Instantiate(
            terrainTilePrefab,
            tilePosition,
            Quaternion.identity
            );

        Vector3 landmarkPosition = terrain.transform.position * 3f;

        if (landmarkPosition.magnitude > ((terrainSize.x + cellSize) * radiusToRender * 3f))
        {
            GameObject newLandmark = Instantiate(terrainLandmarkPrefab, landmarkPosition, Quaternion.identity);
            newLandmark.transform.SetParent(transform);
        }

        terrain.name = TrimEnd(terrain.name, "(Clone)") + " [" + xIndex + " , " + yIndex + "]";
        terrainTiles.Add(new Vector2(xIndex, yIndex), terrain);

        GenerateMeshSimple gm = terrain.GetComponent <GenerateMeshSimple>();

        gm.TerrainSize = terrainSize;
        gm.Gradient    = gradient;
        gm.NoiseScale  = noiseScale;
        gm.CellSize    = cellSize;
        gm.NoiseOffset = NoiseOffset(xIndex, yIndex);
        gm.Generate();

        if (terrain.GetComponent <FadeObject>())
        {
            terrain.GetComponent <FadeObject>().StartFadeIn();
        }

        GarnishTile(terrain, terrain.transform.position);

        terrain.transform.SetParent(transform);

        return(terrain);
    }
Пример #4
0
    private GameObject CreateTile(int xIndex, int yIndex)
    {
        GameObject terrain = Instantiate(
            terrainTilePrefab,
            new Vector3(terrainSize.x * xIndex, terrainSize.y, terrainSize.z * yIndex),
            Quaternion.identity
            );

        terrain.name = TrimEnd(terrain.name, "(Clone)") + " [" + xIndex + " , " + yIndex + "]";

        terrainTiles.Add(new Vector2(xIndex, yIndex), terrain);

        GenerateMeshSimple gm = terrain.GetComponent <GenerateMeshSimple>();

        gm.TerrainSize = terrainSize;
        gm.Gradient    = gradient;
        gm.NoiseScale  = noiseScale;
        gm.CellSize    = cellSize;
        gm.NoiseOffset = NoiseOffset(xIndex, yIndex);
        gm.Generate();

        return(terrain);
    }