Пример #1
0
 public PlayerState(float playerHealth, float playerHunger, float playerThirst, float playerSleep, SavableInventory savableInventory)
 {
     this.playerHealth     = playerHealth;
     this.playerHunger     = playerHunger;
     this.playerThirst     = playerThirst;
     this.playerSleep      = playerSleep;
     this.savableInventory = savableInventory;
 }
Пример #2
0
    public void SaveData()
    {
        SavableInventory saveableInventory = inventoryHandler.GetSavableInventory();
        PlayerState      state             = new PlayerState(statsHandler._CurrentHealth, statsHandler._CurrentHunger, statsHandler._CurrentThirst, statsHandler._CurrentEnergy, saveableInventory);

        SavableData savableData = new SavableData(SavableIdentifier.Player, new object[] { state });

        SaveManager.Instance.AddSaveData(savableData);

        SaveManager.Instance.onSaveGame -= SaveData;
    }
Пример #3
0
    private void RecreateInventory(SavableInventory savedInventory)
    {
        Debug.Log("Recreating inventory");

        List <int>    keys   = savedInventory.inventoryKeys;
        List <string> values = savedInventory.inventoryValues;

        for (int i = 0; i < keys.Count; i++)
        {
            if (!string.IsNullOrEmpty(values[i]))
            {
                BaseItem item = GameAccesPoint.Instance.mainGameState._gameItemDatabase.CreateItemInstance(values[i], Vector3.zero, Quaternion.identity);
                if (item is BasePickableItem)
                {
                    BasePickableItem pickableItem = (BasePickableItem)item;
                    pickableItem.SetVisualState(false);
                    AddItem(pickableItem, pickableItem.myIcon, i);
                }
            }
        }
    }