/// Load data from the MapData by iterating through the tiles, creating a tile instance at each, loading plants, and shading. public void CreateMap() { ClearMap(); for (int i = 0; i < mapData.tileList.Count; i++) { Vector3Int tilePosition = mapData.tileList[i]; TileController.Tile newTile = new TileController.Tile(tilePosition, tilemap, mapObj, mapMesh); tiles.Add(newTile); if (mapData.hasPlant[i]) { tiles[i].AddPlant(plant); } } CalculateShade(); }
public void CreateSeedling(TileController.Tile tile) { /// Select a random neighbor plant int xrandom = (int)Math.Round(UnityEngine.Random.value * 2f - 1); int yrandom = (int)Math.Round(UnityEngine.Random.value * 2f - 1); var seededTilePosition = tile.position + new Vector3Int(xrandom, yrandom, 0); if (tilemap.HasTile(seededTilePosition)) { var seededTileID = tiles.FindIndex(x => (x.position == seededTilePosition)); tiles[seededTileID].AddPlant(plant); Debug.Log($"made a plant: {seededTilePosition}, {xrandom}, {yrandom}"); } else { Debug.Log($"Position not found: {seededTilePosition}"); } }