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

Managed equipping items. More...

Inheritance diagram for PlatformerPro.EquipmentManager:
PlatformerPro.ItemStatProvider PlatformerPro.ICoreComponent PlatformerPro.Persistable PlatformerPro.PlatformerProMonoBehaviour PlatformerPro.ICharacterReference

Public Member Functions

virtual void Init (Character character)
 Init this instance. Called from awake. More...
 
virtual EquipmentData GetItemForSlot (string slot)
 Gets the item data for the given slot. More...
 
bool EquipFromInventory (string slot, int inventorySlot)
 Equips an item from the inventory slot provided. More...
 
bool UnequipToInventory (string slot)
 Unequips to a given inventory slot. More...
 
bool UnequipToInventoryAtSlot (string slot, int inventorySlot)
 Unequips to a specific inventory slot. More...
 
bool DestroyItem (string slot)
 Destroy an item (Unequip the given item and don't add it to inventory). More...
 
bool IsEquipped (string itemId)
 Returns true if an item with the given id is equipped in any slot. More...
 
bool IsEquippedinSlot (string itemId, string slot)
 Returns true if an item with the given id is in the given slot. More...
 
int ItemCount (string itemId)
 Gets the count of a given item type across all stacks. More...
 
int ConsumeFromSlot (string slot, int amount)
 Consume the amount of item from the specificed slot. More...
 
override void ApplySaveData (object t)
 Applies the save data to the object. More...
 
override System.Type SavedObjectType ()
 Get the type of object this Persistable saves. More...
 
override void ResetSaveData ()
 Resets the save data back to default. More...
 
override System.Type[] GetExtraTypes ()
 Support complex object serialisation by passing additional types to seralizer. More...
 
- Public Member Functions inherited from PlatformerPro.PlatformerProMonoBehaviour
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

bool autoEquip
 If true automatically equip a weapon if no weapon is currently equipped More...
 
bool alwaysAutoEquip
 If true automatically equip a weapon if no weapon is currently equipped More...
 
bool dropOnAutoEquip
 If true automatically drop the item that was in the auto equip slot. More...
 
List< string > autoEquipSlots
 A list of slots that auto equip will apply to. More...
 
bool ignoreZeroValuedMultipliers = true
 If true then we allow zero valued multipliers. Otherwise we ignore them and raise a warning. More...
 
List< string > ignoredSlots
 Slots in here will have their multipliers ignored More...
 
- Public Attributes inherited from PlatformerPro.Persistable
bool usePersistenceDefaults = true
 Should we use the persistence defaults or override with our own values. More...
 
bool enablePersistence = true
 Should we enable persistence. More...
 
bool saveOnAnyChange
 Save whenever this value changes (Note: not supported by all objects). More...
 
PersistenceResetType persistenceType
 When do we reset persistence? More...
 

Static Public Attributes

const string UniqueDataIdentifier = "EquipmentManager"
 The player preference identifier. More...
 
- Static Public Attributes inherited from PlatformerPro.Persistable
const string BasePlayerPrefId = "PP.Persistent."
 The base player preference identifier. More...
 

Protected Member Functions

virtual void OnItemEquipped (string type, Character character)
 Raises the item equipped event. More...
 
virtual void OnItemUnequipped (string type, Character character)
 Raises the item unequipped event. More...
 
override void ConfigureEventListeners ()
 Init this instance. More...
 
virtual void HandleItemCollected (object sender, ItemEventArgs e)
 Handles an item being collected. Used for autoequip. More...
 
override void RecalculateEffectsOfItems ()
 Updates item multipler stats. More...
 
- Protected Member Functions inherited from PlatformerPro.Persistable
virtual void OnLoaded ()
 Raises the loaded event. More...
 
virtual void DoPendingSaves (object sender, PersistenceEventArgs e)
 Trigger any pending saves. More...
 
virtual void PhaseChange (object sender, GamePhaseEventArgs e)
 Handle a change of game phase, look for persistence event and apply. More...
 
virtual void HandleRespawn (object sender, CharacterEventArgs e)
 Handle a change of game phase, look for persistence event and apply. More...
 
virtual void HandleWillExitScene (object sender, SceneEventArgs e)
 Handles the will exit scene event More...
 
virtual void HandleGameOver (object sender, CharacterEventArgs e)
 Handles the game over event More...
 
virtual void HandleDied (object sender, DamageInfoEventArgs e)
 Handles the died event. More...
 

Protected Attributes

Dictionary< string, EquipmentDatadata
 Lookup for getting equipment state. More...
 
Character character
 Which character does this inventory belong to. More...
 
- Protected Attributes inherited from PlatformerPro.ItemStatProvider
float totalJumpHeightMultiplier = 1.0f
 
float totalMoveSpeedMultiplier = 1.0f
 
float totalRunSpeedMultiplier = 1.0f
 
float totalAccelerationMultiplier = 1.0f
 
int totalMaxHealthAdjustment = 1
 
float totalDamageMultiplier = 1.0f
 
float totalWeaponSpeedMultiplier = 1.0f
 
- Protected Attributes inherited from PlatformerPro.Persistable
bool loaded
 Have we loaded the data yet? More...
 
bool readyToSave
 Are we ready to save on the next save tick? More...
 
Persistable latestSaveData
 Data to save when we trigger the next save tick. More...
 

Properties

override Character Character [get, set]
 Gets the character. More...
 
override object SaveData [get]
 Gets the data to save. More...
 
override string Identifier [get]
 Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name). More...
 
- Properties inherited from PlatformerPro.ItemStatProvider
virtual float TotalJumpHeightMultiplier [get]
 Gets the total JumpHeightMultiplier of all equipped items, updated whenever items are equipped. More...
 
virtual float TotalMoveSpeedMultiplier [get]
 Gets the total MoveSpeedMultiplier of all equipped items, updated whenever items are equipped. More...
 
virtual float TotalRunSpeedMultiplier [get]
 Gets the total RunSpeedMultiplier of all equipped items, updated whenever items are equipped. More...
 
virtual float TotalAccelerationMultiplier [get]
 Gets the total AccelerationMultiplier of all equipped items, updated whenever items are equipped. More...
 
virtual int TotalMaxHealthAdjustment [get]
 Gets the total MaxHealthAdjustment of all equipped items, updated whenever items are equipped. More...
 
virtual float TotalDamageMultiplier [get]
 Gets the total DamageMultiplier of all equipped items, updated whenever items are equipped. More...
 
virtual float TotalWeaponSpeedMultiplier [get]
 Gets the total WeaponSpeedMultiplier of all equipped items, updated whenever items are equipped. More...
 
- Properties inherited from PlatformerPro.Persistable
virtual string PlayerPrefsIdentifier [get]
 The player preference identifier. More...
 
virtual bool EnablePersistence [get]
 Gets the value for persistence type taking in to account defaults. More...
 
virtual PersistenceResetType PersistenceType [get]
 Gets the value for persistence type taking in to account defaults. More...
 
virtual bool SaveOnChange [get]
 Gets the value for save on change type taking in to account defaults. More...
 
abstract Character Character [get, set]
 Gets the character. More...
 
abstract object SaveData [get]
 Gets the data to save. More...
 
abstract string Identifier [get]
 Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name). More...
 
- Properties inherited from PlatformerPro.PlatformerProMonoBehaviour
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...
 
- Properties inherited from PlatformerPro.ICharacterReference
Character Character [get, set]
 Get the character. More...
 

Events

System.EventHandler< ItemEventArgsItemEquipped
 Item collected. More...
 
System.EventHandler< ItemEventArgsItemUnequipped
 Item collected. More...
 
- Events inherited from PlatformerPro.Persistable
System.EventHandler< EmptyEventArgsLoaded
 Sent when this persistable is loaded. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from PlatformerPro.Persistable
static void Save (Persistable p)
 Save the given persistable. More...
 
static void SaveXml (Persistable p)
 Save the given persistable in XML format. More...
 
static void SaveBinary (Persistable p)
 Save the given persistable in XML format. More...
 
static void Load (Persistable p)
 Load the given persistable. More...
 
static void Reset (Persistable p)
 Resets the given persistable. More...
 
- Static Protected Member Functions inherited from PlatformerPro.Persistable
static object LoadSavedDataXml (Persistable p)
 Does the actual load and returns raw object. More...
 
static object LoadSavedDataBinary (Persistable p)
 Does the actual load and returns raw object. More...
 

Detailed Description

Managed equipping items.

Member Function Documentation

◆ ApplySaveData()

override void PlatformerPro.EquipmentManager.ApplySaveData ( object  t)
virtual

Applies the save data to the object.

Implements PlatformerPro.Persistable.

◆ ConfigureEventListeners()

override void PlatformerPro.EquipmentManager.ConfigureEventListeners ( )
protectedvirtual

Init this instance.

Reimplemented from PlatformerPro.Persistable.

◆ ConsumeFromSlot()

int PlatformerPro.EquipmentManager.ConsumeFromSlot ( string  slot,
int  amount 
)

Consume the amount of item from the specificed slot.

Returns
The actual number consumed.
Parameters
slotSlot to consume from.
amountAmount.

◆ DestroyItem()

bool PlatformerPro.EquipmentManager.DestroyItem ( string  slot)

Destroy an item (Unequip the given item and don't add it to inventory).

Returns
true, if item was destroyed, false if it couldn't be found.
Parameters
slotSlot.

◆ EquipFromInventory()

bool PlatformerPro.EquipmentManager.EquipFromInventory ( string  slot,
int  inventorySlot 
)

Equips an item from the inventory slot provided.

Returns
true, if item from inventory was equiped, false otherwise.
Parameters
slotname of equippable slot.
inventorySlotIndex of inventory slot.

◆ GetExtraTypes()

override System.Type [] PlatformerPro.EquipmentManager.GetExtraTypes ( )
virtual

Support complex object serialisation by passing additional types to seralizer.

Reimplemented from PlatformerPro.Persistable.

◆ GetItemForSlot()

virtual EquipmentData PlatformerPro.EquipmentManager.GetItemForSlot ( string  slot)
virtual

Gets the item data for the given slot.

Returns
The item for given slot.
Parameters
slotSlot.

◆ HandleItemCollected()

virtual void PlatformerPro.EquipmentManager.HandleItemCollected ( object  sender,
ItemEventArgs  e 
)
protectedvirtual

Handles an item being collected. Used for autoequip.

Parameters
sender
e

◆ Init()

virtual void PlatformerPro.EquipmentManager.Init ( Character  character)
virtual

Init this instance. Called from awake.

Implements PlatformerPro.ICoreComponent.

◆ IsEquipped()

bool PlatformerPro.EquipmentManager.IsEquipped ( string  itemId)

Returns true if an item with the given id is equipped in any slot.

Returns
true, If item is in slot.
Parameters
itemIdItem identifier.

◆ IsEquippedinSlot()

bool PlatformerPro.EquipmentManager.IsEquippedinSlot ( string  itemId,
string  slot 
)

Returns true if an item with the given id is in the given slot.

Returns
true, If item is in slot.
Parameters
itemIdItem identifier.
slotSlot.

◆ ItemCount()

int PlatformerPro.EquipmentManager.ItemCount ( string  itemId)

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

Returns
The count.
Parameters
itemIdItem identifier.

◆ OnItemEquipped()

virtual void PlatformerPro.EquipmentManager.OnItemEquipped ( string  type,
Character  character 
)
protectedvirtual

Raises the item equipped event.

Parameters
typeType.
characterCharacter.

◆ OnItemUnequipped()

virtual void PlatformerPro.EquipmentManager.OnItemUnequipped ( string  type,
Character  character 
)
protectedvirtual

Raises the item unequipped event.

Parameters
typeType.
characterCharacter.

◆ RecalculateEffectsOfItems()

override void PlatformerPro.EquipmentManager.RecalculateEffectsOfItems ( )
protectedvirtual

Updates item multipler stats.

Implements PlatformerPro.ItemStatProvider.

◆ ResetSaveData()

override void PlatformerPro.EquipmentManager.ResetSaveData ( )
virtual

Resets the save data back to default.

Implements PlatformerPro.Persistable.

◆ SavedObjectType()

override System.Type PlatformerPro.EquipmentManager.SavedObjectType ( )
virtual

Get the type of object this Persistable saves.

Implements PlatformerPro.Persistable.

◆ UnequipToInventory()

bool PlatformerPro.EquipmentManager.UnequipToInventory ( string  slot)

Unequips to a given inventory slot.

Returns
true, if able to unequipped, false otherwise.
Parameters
slotSlot.

◆ UnequipToInventoryAtSlot()

bool PlatformerPro.EquipmentManager.UnequipToInventoryAtSlot ( string  slot,
int  inventorySlot 
)

Unequips to a specific inventory slot.

Returns
true, if able to unequip to slot, false otherwise.
Parameters
slotSlot.
inventorySlotInventory slot.

Member Data Documentation

◆ alwaysAutoEquip

bool PlatformerPro.EquipmentManager.alwaysAutoEquip

If true automatically equip a weapon if no weapon is currently equipped

◆ autoEquip

bool PlatformerPro.EquipmentManager.autoEquip

If true automatically equip a weapon if no weapon is currently equipped

◆ autoEquipSlots

List<string> PlatformerPro.EquipmentManager.autoEquipSlots

A list of slots that auto equip will apply to.

◆ character

Character PlatformerPro.EquipmentManager.character
protected

Which character does this inventory belong to.

◆ data

Dictionary<string, EquipmentData> PlatformerPro.EquipmentManager.data
protected

Lookup for getting equipment state.

◆ dropOnAutoEquip

bool PlatformerPro.EquipmentManager.dropOnAutoEquip

If true automatically drop the item that was in the auto equip slot.

◆ ignoredSlots

List<string> PlatformerPro.EquipmentManager.ignoredSlots

Slots in here will have their multipliers ignored

◆ ignoreZeroValuedMultipliers

bool PlatformerPro.EquipmentManager.ignoreZeroValuedMultipliers = true

If true then we allow zero valued multipliers. Otherwise we ignore them and raise a warning.

◆ UniqueDataIdentifier

const string PlatformerPro.EquipmentManager.UniqueDataIdentifier = "EquipmentManager"
static

The player preference identifier.

Property Documentation

◆ Character

override Character PlatformerPro.EquipmentManager.Character
getset

Gets the character.

◆ Identifier

override string PlatformerPro.EquipmentManager.Identifier
get

Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name).

◆ SaveData

override object PlatformerPro.EquipmentManager.SaveData
get

Gets the data to save.

Event Documentation

◆ ItemEquipped

System.EventHandler<ItemEventArgs> PlatformerPro.EquipmentManager.ItemEquipped

Item collected.

◆ ItemUnequipped

System.EventHandler<ItemEventArgs> PlatformerPro.EquipmentManager.ItemUnequipped

Item collected.


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