public void LoadTemp(int saveSlot) { if (saveSlot == 1 || saveSlot == 2 || saveSlot == 3) { MainCharInventory.Instance.EmptyInventory(); HotbarController.Instance.EmptyHotbar(); PickUpTypeList list = PickUpTypeList.Instance; JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString(TEMP_SAVE_KEY), this); for (int i = 0; i < counts.Count; i++) { if (list.GetPickUpItem(items[i]) != null) { MainCharInventory.Instance.AddItemToInventory(list.GetPickUpItem(items[i]), counts[i]); } else { Debug.Log("PickUpItem not found " + items[i]); } } Debug.Log("Temp load " + PlayerPrefs.GetString(TEMP_SAVE_KEY)); } else { Debug.Log("Save slot number invalid!"); } }
private void Awake() { if (Instance == null) { Instance = this; } }
public void Load(int saveSlot) { if (saveSlot == 1 || saveSlot == 2 || saveSlot == 3) { PickUpTypeList list = PickUpTypeList.Instance; FarmingController.Instance.EmptyDirtPlotList(); JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString(SAVE_KEY + saveSlot), this); for (int i = 0; i < IDs.Count; i++) { PickUpItem item = list.GetPickUpItem(items[i]); if (item != null) { DirtPlot plot = FarmingController.Instance.GetDirtPlot(IDs[i]); if (plot != null) { if (item is Plant) { FarmingController.Instance.AddPlant(plot, ((Plant)item)); } else { plot.AddPlant(item, days2Grows[i]); } } } } } else { Debug.Log("Save slot number invalid!"); } }