public void LoadPlantedCrops(PlantedCropData[] plantedCropDatas) { foreach (PlantedCropData cropData in plantedCropDatas) { PlantedCrop crop = Instantiate(plantedCropPrefab, cropData.position.TileToWorld(), Quaternion.identity); plantedCrops[cropData.position] = crop; crop.Load(cropData); } }
public void PlantCrop(Vector2Int tile, CropData cropData) { if (plantedCrops.ContainsKey(tile)) { Debug.LogWarning($"Tile {tile} already has a crop!"); return; } PlantedCrop crop = Instantiate(plantedCropPrefab, tile + new Vector2(0.5f, 0.5f), Quaternion.identity); plantedCrops[tile] = crop; crop.SetCrop(cropData); }
public void RemoveCrop(PlantedCrop crop) { RemoveCrop(plantedCrops.First(pair => pair.Value == crop).Key); }