public static void LoadData() { playerData = SaveSystem.LoadData(); if (playerData == null) { playerData = new PlayerData(); return; } InventoryItemData[] inventory = JsonArrayParser.FromJson <InventoryItemData>(playerData.GetInventoryString()); itemList.Clear(); foreach (InventoryItemData item in inventory) { for (int i = 0; i < item.count; i++) { itemList.Add(GameData.GetItemById(item.id)); } } instance.StartCoroutine(PopulateUI()); }
private void SetItemsConfig(int count) { Log.WriteLog("Set backgrounds config.", Log.LevelsOfLogs.INFO, "ShopBackgrounds"); _itemsConfig = new ItemConfig[count]; Log.WriteLog(string.Format("Count of current backgrounds: {0}.", _itemsConfig.Length), Log.LevelsOfLogs.INFO, "ShopBackgrounds"); pathForJson = Application.dataPath + "/Resources/" + resourcesPath + jsonNameFile; if (!File.Exists(pathForJson)) { Log.WriteLog("File not exists.", Log.LevelsOfLogs.ERROR, "BuyItemManager"); return; } string json = File.ReadAllText(pathForJson); if (json.Length == 0) { Log.WriteLog("Can not set json.", Log.LevelsOfLogs.ERROR, "ShopBackgrounds"); } _itemsConfig = JsonArrayParser.FromJson <ItemConfig>(json); }