public virtual void Load(PlantableZoneData data) { ResetPatch(); this.transform.position = data.location.AsVector3(); if (data.isPlanted) { PlantSeed(InventorySystem.GetInstance().seedItemMap[data.seedType]); plant.Load(data.plantData); } }
public virtual PlantableZoneData Save() { PlantableZoneData data = new PlantableZoneData(); data.location = new SerializedVector(this.transform.position); data.isPlanted = IsPlanted(); data.seedType = seedType; data.zoneType = zoneType; if (plant != null) { data.plantData = plant.Save(); } return(data); }
private void LoadRoomState(RoomData data) { // Load is only called if we already have data for this room, so we should delete default plantable zones foreach (PlantableZone zone in GameObject.FindObjectsOfType <PlantableZone>()) { Destroy(zone.gameObject); } // Create all plants that were stored in level data. for (int i = 0; i < data.plantableZoneNames.Count; i++) { string name = data.plantableZoneNames[i]; PlantableZoneData zoneData = data.plantableZoneData[i]; GameObject obj = Instantiate(inventory.plantableZonePrefabMap[zoneData.zoneType]); PlantableZone plantableZone = obj.GetComponent <PlantableZone>(); plantableZone.Load(zoneData); } }