![]() |
Platformer Pro
2.3.2
A platform game kit for Unity.
|
Holds Items. Extend to create your own inventories. More...
Public Member Functions | |
virtual void | Init (Character character) |
Init this instance. Called from awake. More... | |
ItemInstanceData | GetItemAt (int position) |
Gets item type and amount at the given position or null if nothing there (or out of range). More... | |
int | GetFirstSlotForItem (string itemId) |
Gets the first slot holding the given item. More... | |
int | Consume (string itemId, int amount) |
Consume the item with specified key in the given amount. More... | |
ItemTypeData | GetItemTypeDataAt (int position) |
Gets the item type data for the item at the given position or null if nothing there (or out of range). More... | |
int | AddItem (ItemInstanceData data) |
Add the given item to the inventory. More... | |
int | AddItem (string typeId, int amount) |
Add the given item to the inventory. More... | |
int | AddItemAt (ItemInstanceData data, int slot) |
Add the given item to the inventory at the given slot. More... | |
virtual int | ItemCount (string itemType) |
Gets the number of items of the given type. More... | |
virtual int | ItemCount (ItemTypeData type) |
Gets the number of items of the given type. More... | |
void | RemoveItemAt (int index, int amount) |
Remove a single item from the given inventory slot. More... | |
void | SwitchPositions (int indexA, int indexB) |
Switches the positions of items unless item is a stack of same type it which case it tries to merge the stacks. More... | |
void | CleanUpGaps () |
Shifts positions of items such that there are no gaps in the inventory. More... | |
void | CleanUp () |
Combines stacks until stack max is reached and then shifts positions of items such that there are no gaps in the inventory. More... | |
virtual void | ApplySaveData (object t) |
Applies the save data. More... | |
![]() | |
virtual void | Validate (PlatformerProMonoBehaviour myTarget) |
Override this method if you want to provide custom validation. The actual code should be surrounded by the if UNITY_EDITOR / endif directive. More... | |
Public Attributes | |
int | inventorySize |
Starting size of the inventory. More... | |
bool | noGaps |
If true empty inventory spots will cause the inventory to be shifted such as there is no gaps. More... | |
Protected Member Functions | |
virtual void | PostInit () |
Post Init this instance. Called from Start. More... | |
int | AddStackableItem (ItemTypeData type, int amount) |
Add the given item to the inventory. More... | |
Protected Attributes | |
Character | character |
Which character does this inventory belong to. More... | |
InventoryData | inventoryData |
The inventory data. More... | |
bool | loaded |
Tracks if we have loaded data. More... | |
Properties | |
ItemInstanceData[] | AllItems [get] |
Gets all inventory item data. WARNING: For performance reasons this is not a copy. More... | |
virtual object | SaveData [get] |
Gets the data required to save this inventory. More... | |
![]() | |
virtual string | Header [get] |
Gets the header string used to describe the component. More... | |
virtual string | DocLink [get] |
Gets a link to documentation site. More... | |
virtual string | VideoLink [get] |
Gets a link to a youtube video. More... | |
virtual string | Deprecated [get] |
If non-null this component is deprecated. The string shows a message indicating how it should be replaced. More... | |
Holds Items. Extend to create your own inventories.
int PlatformerPro.Inventory.AddItem | ( | ItemInstanceData | data | ) |
Add the given item to the inventory.
data | Item instance data to add |
int PlatformerPro.Inventory.AddItem | ( | string | typeId, |
int | amount | ||
) |
Add the given item to the inventory.
typeId | Item Type identifier. |
amount | Amount. |
int PlatformerPro.Inventory.AddItemAt | ( | ItemInstanceData | data, |
int | slot | ||
) |
Add the given item to the inventory at the given slot.
data | Inventory data. |
slot | Slot to use. |
|
protected |
Add the given item to the inventory.
type | Item Type. |
amount | Amount. |
|
virtual |
Applies the save data.
t | T. |
void PlatformerPro.Inventory.CleanUp | ( | ) |
Combines stacks until stack max is reached and then shifts positions of items such that there are no gaps in the inventory.
void PlatformerPro.Inventory.CleanUpGaps | ( | ) |
Shifts positions of items such that there are no gaps in the inventory.
int PlatformerPro.Inventory.Consume | ( | string | itemId, |
int | amount | ||
) |
Consume the item with specified key in the given amount.
key | Key. |
amount | Amount. |
int PlatformerPro.Inventory.GetFirstSlotForItem | ( | string | itemId | ) |
Gets the first slot holding the given item.
itemId | Item identifier. |
ItemInstanceData PlatformerPro.Inventory.GetItemAt | ( | int | position | ) |
Gets item type and amount at the given position or null if nothing there (or out of range).
position | Position. |
ItemTypeData PlatformerPro.Inventory.GetItemTypeDataAt | ( | int | position | ) |
Gets the item type data for the item at the given position or null if nothing there (or out of range).
position | Position. |
|
virtual |
Init this instance. Called from awake.
Implements PlatformerPro.ICoreComponent.
|
virtual |
|
virtual |
|
protectedvirtual |
Post Init this instance. Called from Start.
void PlatformerPro.Inventory.RemoveItemAt | ( | int | index, |
int | amount | ||
) |
Remove a single item from the given inventory slot.
index | Index. |
void PlatformerPro.Inventory.SwitchPositions | ( | int | indexA, |
int | indexB | ||
) |
Switches the positions of items unless item is a stack of same type it which case it tries to merge the stacks.
indexA | Index a. |
indexB | Index b. |
|
protected |
Which character does this inventory belong to.
|
protected |
The inventory data.
int PlatformerPro.Inventory.inventorySize |
Starting size of the inventory.
|
protected |
Tracks if we have loaded data.
bool PlatformerPro.Inventory.noGaps |
If true empty inventory spots will cause the inventory to be shifted such as there is no gaps.
|
get |
Gets all inventory item data. WARNING: For performance reasons this is not a copy.
|
get |
Gets the data required to save this inventory.
The save data.