using System; using System.Collections.Generic; using UnityEditor; using UnityEngine; public class SceneShopDataLoader : SceneBaseDataLoader { public SceneShopDataLoader(string _objectListName, string _objectFolderName) { SaveModelSystem = new SaveShopManager(); SaveModelSystem.ObjectFolderName = _objectFolderName; SaveModelSystem.ObjectListName = _objectListName; } /* public void LoadInventoryItemsList() { string path = SaveSystem.GetSavePath(); if (!Directory.Exists(path)) // if not exists thats mean there was nothing saved yet - nothing to load return; FileInfo[] fileInfo = new DirectoryInfo(path).GetFiles(); foreach(FileInfo file in fileInfo) { if(file.Name != this.ItemsListName + ".fun") continue; Dictionary equippableItemsList = SaveInventorySystem.LoadInventoryItemsList(this.ItemsListName); // itemEntry.Value.MapDataToObject() - map data format to object // save object foreach(KeyValuePair itemEntry in equippableItemsList) { InventoryManager.Instance.SetupItemInInventory(itemEntry.Key, itemEntry.Value.MapDataToEquippableItemPrefarbAsset().equippableItem); } } } public void SaveInventoryItems() { // Case I - if we remember all list // 1) if after removed item form DynamicList is empty - remove all file // 2) if after removed item form DynamciList there are another one - save updated list again if(InventoryManager.Instance._items.Count > 0) { // 1. Map From Dictionary' to 'Dictionary' Dictionary mappedList = new Dictionary(); foreach(KeyValuePair itemElement in InventoryManager.Instance._items) { mappedList[itemElement.Key] = new EquippableItemPrefabAsset( itemElement.Value.Name, itemElement.Value.ItemModel.name, new Vector3(0,0,0), (EquippableItem) itemElement.Value ); } // 2. Save Items SaveInventorySystem.SaveInventoryItemsList(mappedList, this.ItemsListName); } else { string _path = SaveSystem.GetSavePath() + "/" + this.ItemsListName + ".fun"; try { Debug.Log("File to remove: " + _path); if(File.Exists(_path)) { File.Delete(_path); } } catch (IOException ioExp) { Debug.LogError(ioExp.Message); } } // Case II - if we rememenber object per file // 1) remove specyfic file // // Unfortunatelly we don't use this way of saving items yet :D } */ protected override List LoadDynamicData() { SaveModelSystem.Path = PathBuilder.BuildSavePath().WithMap(CurrentMap).WithDataType(SceneElementTypeEnum.Dynamic).GetString(); return SaveModelSystem.LoadModelList(); } protected override bool SaveDynamicData(List _elements) { SaveModelSystem.Path = PathBuilder.BuildSavePath().WithMap(CurrentMap).WithDataType(SceneElementTypeEnum.Dynamic).GetString(); return base.SaveDynamicData(_elements); } protected override List LoadGenericData() { throw new NotImplementedException(); } protected override bool SaveGenericData(List _elements) { throw new NotImplementedException(); } }