A 2D Farming RPG
This is just a simple 2D farming RPG game
Loading...
Searching...
No Matches
InventoryManager Class Reference

This class will manage all the inventory related operations. More...

Inheritance diagram for InventoryManager:
Inheritance graph
Collaboration diagram for InventoryManager:
Collaboration graph

Public Member Functions

void AddItem (InventoryLocation inventoryLocation, Item item)
 Add an item to the inventory List for the inventory location More...
 
void AddItem (InventoryLocation inventoryLocation, Item item, GameObject gameObjectToDelete)
 Add an item to the inventory list for the inventoryLocation and then destroy the gameObjectToDelete More...
 
void SwapInventoryItems (InventoryLocation inventoryLocation, int fromItem, int toItem)
 Swap item at fromItem index with item at toItem index in inventoryLocation inventory list. More...
 
void ClearSelectedInventoryItem (InventoryLocation inventoryLocation)
 Clear the selected inventory item for inventory Location. More...
 
int FindItemInInventory (InventoryLocation inventoryLocation, int itemCode)
 Find if an itemCode is already in the inventory. Returns the item position in the inventory list, or -1 if the item is not in the inventory More...
 
ItemDetails GetItemDetails (int itemCode)
 Returns the itemDetails (from the SOItemList) for the itemCode, or null if the item code doesn't exist. More...
 
ItemDetails GetSelectedInventoryItemDetails (InventoryLocation inventoryLocation)
 Returns the item details (From the So_ItemList) of the currently selected item. More...
 
string GetItemTypeDescription (ItemType itemType)
 Return the desctiption of the item type. More...
 
void RemoveItem (InventoryLocation inventoryLocation, int itemCode)
 Remove an item from the inventory, and create a gameobject at the position it was dropped More...
 
void SetSelectedInventoryItem (InventoryLocation inventoryLocation, int itemCode)
 Set the selected inventory item for inventoryLocation to itemCode More...
 

Data Fields

List< InventoryItem >[] m_InventoryLists
 We have two inventory lists, one for player and other for chest. index 0 is for player. More...
 
int[] m_InventoryListCapacityIntArray
 The index of the array is the inventory list (From the inventory location enum), and the value is the capacity of that inventory list. More...
 

Protected Member Functions

override void Awake ()
 Create item details dictionary Keep the original awake function in Singleton class and the override it to initialize item dictionary. This will gurantee that dictionary will initialize before we used that in other classes. More...
 
virtual void Awake ()
 

Private Member Functions

void CreateInventoryLists ()
 Create Inventory Lists More...
 
void CreateItemDetailsDictionary ()
 Populates the itemDetailsDictionary from scriptable object item list. More...
 
void AddItemAtPosition (List< InventoryItem > inventoryList, int itemCode)
 Add item to the end of the inventory. More...
 
void AddItemAtPosition (List< InventoryItem > inventoryList, int itemCode, int position)
 Add item to postion in the inventory More...
 
int GetSelectedInventoryItem (InventoryLocation inventoryLocation)
 Get the selected item for inventoryLocation More...
 
void RemoveItemAtPosition (List< InventoryItem > inventoryList, int itemCode, int position)
 Remove an item from a specific position More...
 

Private Attributes

Dictionary< int, ItemDetailsm_ItemDetailsDictionary
 
int[] m_SelectedInventoryItem
 The index of the array is the inventory list, and the value is the item code. More...
 
SOItemList m_ItemList = null
 

Additional Inherited Members

- Properties inherited from SingletonMonobehaviour< InventoryManager >
static T Instance [get]
 

Detailed Description

This class will manage all the inventory related operations.

Definition at line 7 of file InventoryManager.cs.

Member Function Documentation

◆ AddItem() [1/2]

void InventoryManager.AddItem ( InventoryLocation  inventoryLocation,
Item  item 
)
inline

Add an item to the inventory List for the inventory location

Parameters
inventoryLocation
item

Definition at line 90 of file InventoryManager.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddItem() [2/2]

void InventoryManager.AddItem ( InventoryLocation  inventoryLocation,
Item  item,
GameObject  gameObjectToDelete 
)
inline

Add an item to the inventory list for the inventoryLocation and then destroy the gameObjectToDelete

Parameters
inventoryLocation
item
gameObjectToDelete

Definition at line 117 of file InventoryManager.cs.

Here is the call graph for this function:

◆ AddItemAtPosition() [1/2]

void InventoryManager.AddItemAtPosition ( List< InventoryItem inventoryList,
int  itemCode 
)
inlineprivate

Add item to the end of the inventory.

Parameters
inventoryList
itemCode

Definition at line 128 of file InventoryManager.cs.

Here is the caller graph for this function:

◆ AddItemAtPosition() [2/2]

void InventoryManager.AddItemAtPosition ( List< InventoryItem inventoryList,
int  itemCode,
int  position 
)
inlineprivate

Add item to postion in the inventory

Definition at line 142 of file InventoryManager.cs.

◆ Awake()

override void InventoryManager.Awake ( )
inlineprotectedvirtual

Create item details dictionary Keep the original awake function in Singleton class and the override it to initialize item dictionary. This will gurantee that dictionary will initialize before we used that in other classes.

Reimplemented from SingletonMonobehaviour< InventoryManager >.

Definition at line 32 of file InventoryManager.cs.

Here is the call graph for this function:

◆ ClearSelectedInventoryItem()

void InventoryManager.ClearSelectedInventoryItem ( InventoryLocation  inventoryLocation)
inline

Clear the selected inventory item for inventory Location.

Definition at line 181 of file InventoryManager.cs.

◆ CreateInventoryLists()

void InventoryManager.CreateInventoryLists ( )
inlineprivate

Create Inventory Lists

Definition at line 54 of file InventoryManager.cs.

Here is the caller graph for this function:

◆ CreateItemDetailsDictionary()

void InventoryManager.CreateItemDetailsDictionary ( )
inlineprivate

Populates the itemDetailsDictionary from scriptable object item list.

Definition at line 75 of file InventoryManager.cs.

Here is the caller graph for this function:

◆ FindItemInInventory()

int InventoryManager.FindItemInInventory ( InventoryLocation  inventoryLocation,
int  itemCode 
)
inline

Find if an itemCode is already in the inventory. Returns the item position in the inventory list, or -1 if the item is not in the inventory

Parameters
inventoryLocation
itemCode
Returns

Definition at line 193 of file InventoryManager.cs.

Here is the caller graph for this function:

◆ GetItemDetails()

ItemDetails InventoryManager.GetItemDetails ( int  itemCode)
inline

Returns the itemDetails (from the SOItemList) for the itemCode, or null if the item code doesn't exist.

Parameters
itemCode
Returns

Definition at line 213 of file InventoryManager.cs.

Here is the caller graph for this function:

◆ GetItemTypeDescription()

string InventoryManager.GetItemTypeDescription ( ItemType  itemType)
inline

Return the desctiption of the item type.

Parameters
itemType
Returns

Definition at line 258 of file InventoryManager.cs.

◆ GetSelectedInventoryItem()

int InventoryManager.GetSelectedInventoryItem ( InventoryLocation  inventoryLocation)
inlineprivate

Get the selected item for inventoryLocation

Returns
itemCode or -1 if not fount.

Definition at line 248 of file InventoryManager.cs.

Here is the caller graph for this function:

◆ GetSelectedInventoryItemDetails()

ItemDetails InventoryManager.GetSelectedInventoryItemDetails ( InventoryLocation  inventoryLocation)
inline

Returns the item details (From the So_ItemList) of the currently selected item.

Parameters
inventoryLocation
Returns
itemDetails or null if there is no item

Definition at line 230 of file InventoryManager.cs.

Here is the call graph for this function:

◆ RemoveItem()

void InventoryManager.RemoveItem ( InventoryLocation  inventoryLocation,
int  itemCode 
)
inline

Remove an item from the inventory, and create a gameobject at the position it was dropped

Definition at line 299 of file InventoryManager.cs.

Here is the call graph for this function:

◆ RemoveItemAtPosition()

void InventoryManager.RemoveItemAtPosition ( List< InventoryItem inventoryList,
int  itemCode,
int  position 
)
inlineprivate

Remove an item from a specific position

Parameters
inventoryList
itemCode
position

Definition at line 321 of file InventoryManager.cs.

Here is the caller graph for this function:

◆ SetSelectedInventoryItem()

void InventoryManager.SetSelectedInventoryItem ( InventoryLocation  inventoryLocation,
int  itemCode 
)
inline

Set the selected inventory item for inventoryLocation to itemCode

Parameters
inventoryLocation
itemCode

Definition at line 344 of file InventoryManager.cs.

◆ SwapInventoryItems()

void InventoryManager.SwapInventoryItems ( InventoryLocation  inventoryLocation,
int  fromItem,
int  toItem 
)
inline

Swap item at fromItem index with item at toItem index in inventoryLocation inventory list.

Parameters
inventoryLocation
fromItem
toItem

Definition at line 161 of file InventoryManager.cs.

Here is the call graph for this function:

Field Documentation

◆ m_InventoryListCapacityIntArray

int [] InventoryManager.m_InventoryListCapacityIntArray

The index of the array is the inventory list (From the inventory location enum), and the value is the capacity of that inventory list.

Definition at line 21 of file InventoryManager.cs.

◆ m_InventoryLists

List<InventoryItem> [] InventoryManager.m_InventoryLists

We have two inventory lists, one for player and other for chest. index 0 is for player.

Definition at line 16 of file InventoryManager.cs.

◆ m_ItemDetailsDictionary

Dictionary<int, ItemDetails> InventoryManager.m_ItemDetailsDictionary
private

Definition at line 9 of file InventoryManager.cs.

◆ m_ItemList

SOItemList InventoryManager.m_ItemList = null
private

Definition at line 24 of file InventoryManager.cs.

◆ m_SelectedInventoryItem

int [] InventoryManager.m_SelectedInventoryItem
private

The index of the array is the inventory list, and the value is the item code.

Definition at line 12 of file InventoryManager.cs.


The documentation for this class was generated from the following file: