// Save and Load the Stats public void SaveMuseumStats() { data.currencyData = instance.GetWealth(); data.ratingData = instance.GetRatingRaw(); data.staminaData = instance.GetStamina(); data.dayData = instance.GetDay(); SaveLoad.Save(data, "museumStats"); }
// Places an item in the museum, if the player is at an empty slot which meets the correct criteria for placement public void PlaceExhibit(GameObject exhibitObject, Transform slotToHold) { try { Exhibit exhibitToPlace = exhibitObject.GetComponent <Exhibit>(); exhibitToPlace.itemDefinition.exhibitSlot = slotToHold.GetComponent <Transform>().name; // check the target slot is not null if (exhibitToPlace.itemDefinition.exhibitSlot != "") { // check whether the exhibit has already been displayed if (!exhibitToPlace.itemDefinition.isDisplayed) { // check whether the exhibit can be placed in the desired slot if (exhibitToPlace.itemDefinition.exhibitSize.ToString().Equals(slotToHold.GetComponent <ExhibitSlot>().slotInRange.slotDefinition.exhibitSlotSize.ToString()) && exhibitToPlace.itemDefinition.exhibitType.ToString().Equals(slotToHold.GetComponent <ExhibitSlot>().slotInRange.slotDefinition.exhibitSlotType.ToString())) { // Create a new version of the stored exhibit Instantiate(exhibitToPlace.itemDefinition.exhibitObject, new Vector3(slotToHold.position.x, slotToHold.position.y, -0.3f), Quaternion.Euler(0, 0, 0), slotToHold); // Apply the rating value of the exhibit museStats.ApplyRating(exhibitToPlace.itemDefinition.exhibitRatingAmount); Debug.Log("[PlaceExhibit] Exhibit placed at slot: " + slotToHold.name + ", museStats: " + museStats.GetRatingRaw()); // Set the boolean values to true for future checks. slotToHold.GetComponent <ExhibitSlot>().containsExhibit = true; exhibitToPlace.itemDefinition.isDisplayed = true; DisplayInventory(); SaveInventory(); } else { Debug.Log("[MuseumInventory - PlaceExhibit] The slot size/type and exhibit size/type do not match " + exhibitToPlace.itemDefinition.exhibitSize + " -> " + slotToHold.GetComponent <ExhibitSlot>().slotInRange.slotDefinition.exhibitSlotSize + " || " + exhibitToPlace.itemDefinition.exhibitType + " -> " + slotToHold.GetComponent <ExhibitSlot>().slotInRange.slotDefinition.exhibitSlotType); } } else { Debug.Log("[MuseumInventory - PlaceExhibit] Exhibit already placed - " + exhibitToPlace.itemDefinition.exhibitName); } } else { Debug.Log("[MuseumInventory] exhibitSlot = null"); } }catch (KeyNotFoundException knfe) { Debug.Log("[MuseumInventory] KeyNotFoundException || " + knfe.Data); } }