|
|
|
|
|
|
using UnityEngine; |
|
|
|
using System.Collections; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.AddressableAssets; |
|
|
|
using UnityEngine.ResourceManagement.AsyncOperations; |
|
|
|
|
|
|
|
public class SaveSystem : ScriptableObject |
|
|
|
{ |
|
|
|
|
|
|
saveData._locationId = locationSo.Guid; |
|
|
|
} |
|
|
|
|
|
|
|
SaveGame(); |
|
|
|
SaveDataToDisk(); |
|
|
|
public void LoadGame() |
|
|
|
public void LoadSaveDataFromDisk() |
|
|
|
{ |
|
|
|
if (FileManager.LoadFromFile(saveFilename, out var json)) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
public IEnumerator LoadSavedInventory() |
|
|
|
{ |
|
|
|
_playerInventory.Items.Clear(); |
|
|
|
foreach (var serializedItemStack in saveData._itemStacks) |
|
|
|
{ |
|
|
|
var loadItemOperationHandle = Addressables.LoadAssetAsync<Item>(serializedItemStack.itemGuid); |
|
|
|
yield return loadItemOperationHandle; |
|
|
|
if (loadItemOperationHandle.Status == AsyncOperationStatus.Succeeded) |
|
|
|
{ |
|
|
|
var itemSo = loadItemOperationHandle.Result; |
|
|
|
_playerInventory.Add(itemSo, serializedItemStack.amount); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public void SaveGame() |
|
|
|
public void SaveDataToDisk() |
|
|
|
{ |
|
|
|
saveData._itemStacks.Clear(); |
|
|
|
foreach (var itemStack in _playerInventory.Items) |
|
|
|