Platformer Pro  2.3.2
A platform game kit for Unity.
PlatformerPro.InventoryData Class Reference

Stores data baout an inventory. More...

Public Member Functions

 InventoryData ()
 Initializes a new instance of the PlatformerPro.InventoryData class. More...
 
 InventoryData (int size)
 Initializes a new instance of the PlatformerPro.InventoryData class. More...
 
int[] FindStacks (string itemId)
 Finds the stacks for a given item. More...
 
int ItemCount (string itemId)
 Gets the count of a given item type across all stacks. More...
 
int GetAmountAtStack (int position)
 Gets the amount in the given stack position. More...
 
ItemInstanceData GetItemAtStack (int position)
 Gets the data at the given stack position. More...
 
int FirstEmptySlot ()
 Finds the first empty slot. More...
 
void AddToEmptyStack (string typeId, int position, int amount)
 Adds new items to a stack at the given position. More...
 
void AddToEmptyStack (ItemInstanceData data, int index)
 Adds new items to a stack at the given position. More...
 
void AddToStack (int position, string itemId, int amount)
 Adds items to an existing stack at given position. More...
 
void RemoveFromStack (int position, int amount)
 Removes items from a stack at given position. More...
 
void SwitchPositions (int indexA, int indexB)
 Switches the positions of items unless items are stacks of same type it which case it tries to merge the stacks. More...
 
bool CleanUpGaps ()
 Shifts positions of items such that there are no gaps in the inventory. More...
 
void ClearStack (int position)
 Remvoed items from a stack at given position. More...
 

Public Attributes

ItemInstanceData[] itemData
 

Protected Attributes

List< int > stackCache
 Used to calcualte results. More...
 

Detailed Description

Stores data baout an inventory.

Constructor & Destructor Documentation

◆ InventoryData() [1/2]

PlatformerPro.InventoryData.InventoryData ( )

Initializes a new instance of the PlatformerPro.InventoryData class.

◆ InventoryData() [2/2]

PlatformerPro.InventoryData.InventoryData ( int  size)

Initializes a new instance of the PlatformerPro.InventoryData class.

Parameters
sizeSize.

Member Function Documentation

◆ AddToEmptyStack() [1/2]

void PlatformerPro.InventoryData.AddToEmptyStack ( ItemInstanceData  data,
int  index 
)

Adds new items to a stack at the given position.

Parameters
typeIdItem Type ID.
positionSlot to fill.
amountAmount.

◆ AddToEmptyStack() [2/2]

void PlatformerPro.InventoryData.AddToEmptyStack ( string  typeId,
int  position,
int  amount 
)

Adds new items to a stack at the given position.

Parameters
typeIdItem Type ID.
positionSlot to fill.
amountAmount.

◆ AddToStack()

void PlatformerPro.InventoryData.AddToStack ( int  position,
string  itemId,
int  amount 
)

Adds items to an existing stack at given position.

Parameters
positionSlot to fill.
amountAmount.

◆ CleanUpGaps()

bool PlatformerPro.InventoryData.CleanUpGaps ( )

Shifts positions of items such that there are no gaps in the inventory.

◆ ClearStack()

void PlatformerPro.InventoryData.ClearStack ( int  position)

Remvoed items from a stack at given position.

Parameters
positionSlot to fill.
amountAmount.

◆ FindStacks()

int [] PlatformerPro.InventoryData.FindStacks ( string  itemId)

Finds the stacks for a given item.

Returns
An array of stacks, or empty array if none found.
Parameters
itemIdItem identifier.

◆ FirstEmptySlot()

int PlatformerPro.InventoryData.FirstEmptySlot ( )

Finds the first empty slot.

Returns
The empty slot.

◆ GetAmountAtStack()

int PlatformerPro.InventoryData.GetAmountAtStack ( int  position)

Gets the amount in the given stack position.

Returns
The amount at stack.
Parameters
positionPosition.

◆ GetItemAtStack()

ItemInstanceData PlatformerPro.InventoryData.GetItemAtStack ( int  position)

Gets the data at the given stack position.

Returns
The data at stack.
Parameters
positionPosition.

◆ ItemCount()

int PlatformerPro.InventoryData.ItemCount ( string  itemId)

Gets the count of a given item type across all stacks.

Returns
The count.
Parameters
itemIdItem identifier.

◆ RemoveFromStack()

void PlatformerPro.InventoryData.RemoveFromStack ( int  position,
int  amount 
)

Removes items from a stack at given position.

Parameters
positionSlot to fill.
amountAmount.

◆ SwitchPositions()

void PlatformerPro.InventoryData.SwitchPositions ( int  indexA,
int  indexB 
)

Switches the positions of items unless items are stacks of same type it which case it tries to merge the stacks.

Parameters
indexAIndex a.
indexBIndex b.

Member Data Documentation

◆ itemData

ItemInstanceData [] PlatformerPro.InventoryData.itemData

◆ stackCache

List<int> PlatformerPro.InventoryData.stackCache
protected

Used to calcualte results.


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