예제 #1
0
    public void Load(string temp)
    {
        InventoryData data = SaveData.current.inventory;

        if (data != default)
        {
            if (temp == "")
            {
                trinkets.Clear();
                abilities.Clear();
                seeds.Clear();

                foreach (string item in data.trinkets)
                {
                    trinkets.Add(Resources.Load("ScriptableObjects/Trinkets/" + item) as Item);
                }
                foreach (string item in data.abilities)
                {
                    abilities.Add(Resources.Load("ScriptableObjects/Abilities/" + item) as Item);
                }
                foreach (KeyValuePair <string, bool> item in data.seeds)
                {
                    seeds.Add(new KeyValuePair <Item, bool>(Resources.Load("ScriptableObjects/Seeds/" + item.Key) as Item, item.Value));
                }
                foreach (KeyValuePair <string, bool> item in data.seedsActiveStatus)
                {
                    seedsActiveStatus.Add(new KeyValuePair <Item, bool>(Resources.Load("ScriptableObjects/Seeds/" + item.Key) as Item, item.Value));
                }
                foreach (KeyValuePair <string, int> item in data.equippedAbilities)
                {
                    equippedAbilities.Add(new KeyValuePair <Item, int>(Resources.Load("ScriptableObjects/Abilities/" + item.Key) as Item, item.Value));
                }

                onInventoryLoadedCallback?.Invoke(trinkets, abilities, seeds, seedsActiveStatus, equippedAbilities);
            }
        }
    }
예제 #2
0
 public void RestoreState(object state)
 {
     inventory = (Inventory)state;
     OnInventoryLoaded?.Invoke(inventory.Slots);
 }
예제 #3
0
 void Start()
 {
     OnInventoryLoaded?.Invoke(inventory.Slots);
 }