public void RefreshSaveData(PlayerSaveData saveData)
    {
        lives  = saveData.lives;
        health = saveData.health;
        inventoryManager.selectedPotionUuid = saveData.selectedPotionUuid;
        inventoryManager.selectedAmmoUuid   = saveData.selectedAmmoUuid;

        ModifyPoints(saveData.points - points);
        currentStamina = saveData.currentStamina;
        if (saveData.hasSquareKey)
        {
            ModifyKeys(CollectableKeys.KEY_TYPE.SQUARE, true);
        }
        if (saveData.hasCircleKey)
        {
            ModifyKeys(CollectableKeys.KEY_TYPE.CIRCLE, true);
        }
        if (saveData.hasTriangleKey)
        {
            ModifyKeys(CollectableKeys.KEY_TYPE.TRIANGLE, true);
        }

        DictionaryOfUuidAndItem inventoryItems = new DictionaryOfUuidAndItem();

        foreach (KeyValuePair <string, int> kvp in saveData.inventoryItems)
        {
            Item originalItem = ItemManager.GetInstance().FindItem(kvp.Key);
            Item myItem       = new Item(originalItem);
            myItem.amount = kvp.Value;
            inventoryItems.Add(myItem.uuid, myItem);
        }

        inventoryManager.InitInventory(inventoryItems);
    }
Beispiel #2
0
    public void InitInventory(DictionaryOfUuidAndItem loadInventory)
    {
        statistics.InitBaseData();

        inventory = loadInventory;

        // First read all items and add all effects
        foreach (KeyValuePair <string, Item> kvp in inventory)
        {
            UpdateEffectToPlayerStatistics(kvp.Value, true);
        }

        // second check max values
        foreach (KeyValuePair <string, Item> kvp in inventory)
        {
            CheckMaxValuesInInventory(kvp.Value);
        }

        // publish all statistic data to all depending components
        statistics.PublishBaseData();

        // publish items to display
        PublishSelectedItems();
    }