Hi,
First, I'll give some context:
I have the Player's Inventory with a Main and an Equipped Collection, which works well for Equipping/Unequipping Items.
I also have a Shop Inventory with a "Shop" Main ItemCollection (for all Items available for purchase), and a "Locked" Secondary ItemCollection, which contains all Items that are not yet available for Purchase (depending on the "UnlockLevel" int Attribute). I'm thinking that I should probably configure the Main Collection as an ItemSlotCollection, since these Items are displayed in a Grid List, but I don't want to make any changes at this point, before consulting you.
An UnlockController Component on the same GameObject as the Shop, checks the current game level and compares it to the "UnlockLevel" Attribute of each Item in the "Locked" Collection. If the UnlockLevel is smaller than or equal to the current game Level, it "moves" the Item from the Locked Collection to the Shop Collection, i.e., removes it from the first and adds it to the second. I've tried this while iterating either through "lockedItemStacks" or "lockedItemInfos", using the following:
Get reference to the Inventory collections:
ItemCollection lockedItemCollection = shopInventory.GetItemCollection(lockedCollectionID);
ItemCollection shopItemCollection = shopInventory.GetItemCollection(shopCollectionID);
Method A - Direct Add/Remove.
shopItemCollection.AddItem(lockedItemStacks.Item, quantityToMove)
and
lockedItemCollection.RemoveItem(lockedItemStacks.Item, quantityToMove)
Method B - Using an ItemActionSet and getting a reference to a MoveToCollectionItemAction (after correctly configuring it).
moveToCollectionItemAction.Initialize(false);
moveToCollectionItemAction.InvokeAction
(
lockedItemInfos,
shopInventory.ItemUser
);
As I step through code and inspect the contents of the collections, the correct Items get moved from the Locked to the Shop Collection, with both the above methods.
However, the Unity Inspector shows these collections unaltered, and the Items are still displayed as locked in the Shop Grid List, probably as a consequence.
I still can't figure out why this is happening.
I'd really appreciate your help.
Thanks in advance!
First, I'll give some context:
I have the Player's Inventory with a Main and an Equipped Collection, which works well for Equipping/Unequipping Items.
I also have a Shop Inventory with a "Shop" Main ItemCollection (for all Items available for purchase), and a "Locked" Secondary ItemCollection, which contains all Items that are not yet available for Purchase (depending on the "UnlockLevel" int Attribute). I'm thinking that I should probably configure the Main Collection as an ItemSlotCollection, since these Items are displayed in a Grid List, but I don't want to make any changes at this point, before consulting you.
An UnlockController Component on the same GameObject as the Shop, checks the current game level and compares it to the "UnlockLevel" Attribute of each Item in the "Locked" Collection. If the UnlockLevel is smaller than or equal to the current game Level, it "moves" the Item from the Locked Collection to the Shop Collection, i.e., removes it from the first and adds it to the second. I've tried this while iterating either through "lockedItemStacks" or "lockedItemInfos", using the following:
Get reference to the Inventory collections:
ItemCollection lockedItemCollection = shopInventory.GetItemCollection(lockedCollectionID);
ItemCollection shopItemCollection = shopInventory.GetItemCollection(shopCollectionID);
Method A - Direct Add/Remove.
shopItemCollection.AddItem(lockedItemStacks.Item, quantityToMove)
and
lockedItemCollection.RemoveItem(lockedItemStacks.Item, quantityToMove)
Method B - Using an ItemActionSet and getting a reference to a MoveToCollectionItemAction (after correctly configuring it).
moveToCollectionItemAction.Initialize(false);
moveToCollectionItemAction.InvokeAction
(
lockedItemInfos,
shopInventory.ItemUser
);
As I step through code and inspect the contents of the collections, the correct Items get moved from the Locked to the Shop Collection, with both the above methods.
However, the Unity Inspector shows these collections unaltered, and the Items are still displayed as locked in the Shop Grid List, probably as a consequence.
I still can't figure out why this is happening.
I'd really appreciate your help.
Thanks in advance!