1using System.Collections.Generic;
93 List<InventoryItem> inventoryList =
m_InventoryLists[(int)inventoryLocation];
98 if( itemPosition != -1 )
119 AddItem( inventoryLocation, item );
120 Destroy( gameObjectToDelete );
132 inventoryItem._ItemCode = itemCode;
133 inventoryItem._ItemQuantity = 1;
134 inventoryList.Add( inventoryItem );
146 int quantity = inventoryList[position]._ItemQuantity + 1;
147 inventoryItem._ItemCode = itemCode;
148 inventoryItem._ItemQuantity = quantity;
149 inventoryList[position] = inventoryItem;
151 Debug.ClearDeveloperConsole();
165 && fromItem != toItem && fromItem >= 0 && toItem >= 0 )
195 List<InventoryItem> inventoryList =
m_InventoryLists[(int)inventoryLocation];
197 for(
int i = 0; i < inventoryList.Count; i++ )
199 if( inventoryList[i]._ItemCode == itemCode )
260 string itemTypeDescription;
289 itemTypeDescription = itemType.ToString();
293 return itemTypeDescription;
301 List<InventoryItem> inventoryList =
m_InventoryLists[(int)inventoryLocation];
306 if( itemPosition != -1 )
325 int quantity = inventoryList[position]._ItemQuantity - 1;
329 inventoryItem._ItemQuantity = quantity;
330 inventoryItem._ItemCode = itemCode;
331 inventoryList[position] = inventoryItem;
335 inventoryList.RemoveAt(position);
InventoryLocation
Describes the type of inventory and count Ex: player inventory or chest inventory
ItemType
Describe the item type
Raise an handle event when a movement is triggered.
static void CallInventoryUpdatedEvent(InventoryLocation inventoryLocation, List< InventoryItem > inventoryList)
Update the event
This class will manage all the inventory related operations.
string GetItemTypeDescription(ItemType itemType)
Return the desctiption of the item type.
void AddItemAtPosition(List< InventoryItem > inventoryList, int itemCode)
Add item to the end of the inventory.
void RemoveItemAtPosition(List< InventoryItem > inventoryList, int itemCode, int position)
Remove an item from a specific position
int GetSelectedInventoryItem(InventoryLocation inventoryLocation)
Get the selected item for inventoryLocation
void CreateItemDetailsDictionary()
Populates the itemDetailsDictionary from scriptable object item list.
int FindItemInInventory(InventoryLocation inventoryLocation, int itemCode)
Find if an itemCode is already in the inventory. Returns the item position in the inventory list,...
void RemoveItem(InventoryLocation inventoryLocation, int itemCode)
Remove an item from the inventory, and create a gameobject at the position it was dropped
override void Awake()
Create item details dictionary Keep the original awake function in Singleton class and the override i...
void AddItem(InventoryLocation inventoryLocation, Item item, GameObject gameObjectToDelete)
Add an item to the inventory list for the inventoryLocation and then destroy the gameObjectToDelete
void ClearSelectedInventoryItem(InventoryLocation inventoryLocation)
Clear the selected inventory item for inventory Location.
void SwapInventoryItems(InventoryLocation inventoryLocation, int fromItem, int toItem)
Swap item at fromItem index with item at toItem index in inventoryLocation inventory list.
Dictionary< int, ItemDetails > m_ItemDetailsDictionary
int[] m_SelectedInventoryItem
The index of the array is the inventory list, and the value is the item code.
int[] m_InventoryListCapacityIntArray
The index of the array is the inventory list (From the inventory location enum), and the value is the...
List< InventoryItem >[] m_InventoryLists
We have two inventory lists, one for player and other for chest. index 0 is for player.
void AddItem(InventoryLocation inventoryLocation, Item item)
Add an item to the inventory List for the inventory location
void SetSelectedInventoryItem(InventoryLocation inventoryLocation, int itemCode)
Set the selected inventory item for inventoryLocation to itemCode
void CreateInventoryLists()
Create Inventory Lists
ItemDetails GetItemDetails(int itemCode)
Returns the itemDetails (from the SOItemList) for the itemCode, or null if the item code doesn't exis...
void AddItemAtPosition(List< InventoryItem > inventoryList, int itemCode, int position)
Add item to postion in the inventory
ItemDetails GetSelectedInventoryItemDetails(InventoryLocation inventoryLocation)
Returns the item details (From the So_ItemList) of the currently selected item.
This class holds information of items.
List< ItemDetails > m_ItemDetails
This class handle the game settings.
static int m_PlayerInitialInventoryCapacity
Inventory.
const string m_BreakingTool
const string m_HoeingTool
const string m_ChoppingTool
const string m_CollectingTool
const string m_ReapingTool
const string m_WateringTool
Abstract class that inherited by all the game managers. All the game managers use singleton since gam...