using UnityEngine;
using System.Collections.Generic;
///
/// This component is responsible of the Inventory which listens for purchases from the StoreManager, and increments the inventory count
/// for items being tracked in the inventory
///
/// It keeps the inventory stored in PlayerPrefs.
/// Besides keeping count, it also helps in keeping track of items to be equipped in the next game using ToggleEquip.
/// Once the equipped items need to be consumed (i.e. item count needs to be decremented), ConsumeEquipped needs to be called.
/// Other query methods for UI purposes are available (HasEquipped and GetPowerupCount)
///
/// Note that each purchase counts as 5 items of the bought product, e.g. LifePack is 5 hearts. This might change in the future and might need to updated accordingly
///
public class InventoryManager : GenericInventoryManager
{
private const string ALREADY_GIVEN_START_WAVES = "awgpbdfge";
private const int START_WAVES = 3;
void Start()
{
CoreNotificationCenter.AddListener(OnReceivedStoreProducts, CoreNotificationType.ReceivedStoreProducts);
}
void OnDestroy()
{
CoreNotificationCenter.RemoveListener(OnReceivedStoreProducts, CoreNotificationType.ReceivedStoreProducts);
}
void OnReceivedStoreProducts(CoreNotification note)
{
if (PlayerPrefs.GetInt(ALREADY_GIVEN_START_WAVES, 0) == 0)
{
for (int i = 0; i < START_WAVES; i++)
{
InventoryManager.Instance.Increment(InventoryItem.specialwave);
}
PlayerPrefs.SetInt(ALREADY_GIVEN_START_WAVES, 1);
PlayerPrefs.Save();
}
}
}