Esempio n. 1
0
    void createTile(int i, int j, Vector2 pos)
    {
        GameObject tileGameObject = (GameObject) Instantiate(tilePrefab, pos, Quaternion.identity);
        tileGameObject.transform.parent = this.gameObject.transform;

        Tile tile = tileGameObject.GetComponent<Tile>();
        tile.setId(i*mapWidth+j);

        // Terrain
        float terrainPixel = terrainTexture.GetPixel(i, j).r;

        for(int n=0; n < dataFiles.tileTerrainTypes.Length; n++){
            TileTerrain item = dataFiles.tileTerrainTypes[n];
            if( (item.range.min <= terrainPixel) && (item.range.max > terrainPixel) ){
                tile.setTerrain(ref item);
                tile.setDisplayMode(DisplayMode.Terrain);
                break;
            }
        }

        // Forestry
        float forestryPixel = forestTexture.GetPixel(i, j).r;
        forestryPixel = forestryPixel * tile.getTerrain().forestryFactor;

        for(int n=0; n < dataFiles.tileForestryTypes.Length; n++){
            TileForestry item = dataFiles.tileForestryTypes[n];
            if( (item.range.min <= forestryPixel) && (item.range.max > forestryPixel) ){
                tile.setForestry(ref item);
                break;
            }
        }

        tiles[tile.getId()] = tileGameObject;
    }
Esempio n. 2
0
 public void setForestry(ref TileForestry forestry)
 {
     this.forestry = forestry;
 }