public override void DoAugment(TileMass tMass)
    {
        base.DoAugment(tMass);

        TileChunk cPrefab = tMass.tileChunkPrefab.GetComponent<TileChunk>();

        int worldSizeX = tMass.massSizeX * cPrefab.chunkSizeX;
        int worldSizeY = tMass.massSizeY * cPrefab.chunkSizeY;

        float height = worldSizeY / 2;

        for(int i = 0; i < worldSizeX; i ++){

            height += Random.Range(-Mathf.PerlinNoise(i, 0), Mathf.PerlinNoise(i, 0));

            for(int j = 0; j < worldSizeY; j ++){

                if(j < height)
                    tMass.SetTileAtNoBuild(new Vector2(i, j), "Dirt");

                if(j == (int) height)
                    tMass.SetTileAtNoBuild(new Vector2(i, j), "Grass");
            }
        }
    }
 public virtual void DoAugment(TileMass tMass)
 {
     this.tMass = tMass;
 }
 void Start()
 {
     tMass = GetComponent<TileMass>();
 }
Пример #4
0
 void Start()
 {
     tMass = GetComponent <TileMass>();
 }
Пример #5
0
    public void Setup(TileMass tMassRef)
    {
        meshFilter = gameObject.AddComponent<MeshFilter>();
        meshRenderer = gameObject.AddComponent<MeshRenderer>();

        verts = new List<Vector3>();
        uvs = new List<Vector2>();
        tris = new List<int>();

        mesh = new Mesh();

        tMass = tMassRef;

        List<Material> materials = new List<Material>();

        foreach(Tile t in tMass.possibleTiles){

            materials.Add(t.tileMaterial);
        }

        meshRenderer.materials = materials.ToArray();

        tiles = new TileChunkCell[chunkSizeX, chunkSizeY];
        colliders = new BoxCollider2D[chunkSizeX, chunkSizeY];

        for(int i = 0; i < chunkSizeX; i ++){

            for(int j = 0; j < chunkSizeY; j ++){

                tiles[i, j] = new TileChunkCell(tMass.possibleTiles[0].tileID, 0);
            }
        }

        for(int i = 0; i < chunkSizeX; i ++){

            for(int j = 0; j < chunkSizeY; j ++){

                colliders[i, j] = gameObject.AddComponent<BoxCollider2D>();
                colliders[i, j].offset = new Vector2(i + 0.5f, j + 0.5f);
                colliders[i, j].isTrigger = !tMass.GetTile(tiles[i, j].tileID).collides;
            }
        }
    }