C# Class InventoryData, 2DPlatformer

Inheritance: MonoBehaviour
Mostra file Open project: MarbleGameDev/2DPlatformer Class Usage Examples

Public Properties

Property Type Description
equippedItem int
gold int
itemCount int>.Dictionary
items List

Public Methods

Method Description
AddItem ( object name, int number ) : void

Used to add items to the inventory

Attack ( ) : float

Returns the float attack value of the equipped item

Awake ( ) : void
Cooldown ( ) : float

Returns the cooldown/swingSpeed attribute of the equipped item

DropItem ( object obj ) : void

Executes the Drop() method on the object passed if it exists in the inventory

GetItem ( string name ) : object

Returns the item object from the inventory matching the name passed, defaulting to null

HasItem ( object obj ) : bool

Returns boolean whether the object passed exists in the inventory

Range ( ) : float

Returns the range attribute of the equipped item

RemoveItem ( object name, int number ) : bool

Used to remove items from the inventory, returning a boolean value of the successfulness

RemoveItem ( string name, int number ) : bool
ResetInv ( ) : void

Clears all inventory data, then saves to disk

UpdateInv ( ) : void
UseItem ( object obj ) : void

Executes the Use() method on the object passed if it exits in the inventory

addGold ( int amount ) : void

Adds the integer amount to the player's gold quantity

compareItems ( object obj1, object obj2 ) : bool
equipItem ( object obj ) : void

Equips the object passed if it exists in the inventory

getEquipped ( ) : object

Returns the currently equipped item, defaulting to Hands

hasEnoughGold ( int amount ) : bool

Returns whether the player has more than the amount specified of gold

removeGold ( int amount ) : bool

Removes the integer amount from the player's gold if possible, doing nothing if not, returning a boolean value of it's success

Private Methods

Method Description
AddObject ( object obj, int number ) : void

Used internally to deal with adding objects to the necessary lists and dictionaries

GetInventory ( ) : void

Retrieves data from the stored data in the Json file

SaveInventory ( ) : void

Saves data in the Json file save object, then writes the data to file

Method Details

AddItem() public static method

Used to add items to the inventory
public static AddItem ( object name, int number ) : void
name object
number int
return void

Attack() public static method

Returns the float attack value of the equipped item
public static Attack ( ) : float
return float

Awake() public static method

public static Awake ( ) : void
return void

Cooldown() public static method

Returns the cooldown/swingSpeed attribute of the equipped item
public static Cooldown ( ) : float
return float

DropItem() public static method

Executes the Drop() method on the object passed if it exists in the inventory
public static DropItem ( object obj ) : void
obj object
return void

GetItem() public static method

Returns the item object from the inventory matching the name passed, defaulting to null
public static GetItem ( string name ) : object
name string
return object

HasItem() public static method

Returns boolean whether the object passed exists in the inventory
public static HasItem ( object obj ) : bool
obj object
return bool

Range() public static method

Returns the range attribute of the equipped item
public static Range ( ) : float
return float

RemoveItem() public static method

Used to remove items from the inventory, returning a boolean value of the successfulness
public static RemoveItem ( object name, int number ) : bool
name object
number int
return bool

RemoveItem() public static method

public static RemoveItem ( string name, int number ) : bool
name string
number int
return bool

ResetInv() public static method

Clears all inventory data, then saves to disk
public static ResetInv ( ) : void
return void

UpdateInv() public static method

public static UpdateInv ( ) : void
return void

UseItem() public static method

Executes the Use() method on the object passed if it exits in the inventory
public static UseItem ( object obj ) : void
obj object
return void

addGold() public static method

Adds the integer amount to the player's gold quantity
public static addGold ( int amount ) : void
amount int
return void

compareItems() public static method

public static compareItems ( object obj1, object obj2 ) : bool
obj1 object
obj2 object
return bool

equipItem() public static method

Equips the object passed if it exists in the inventory
public static equipItem ( object obj ) : void
obj object
return void

getEquipped() public static method

Returns the currently equipped item, defaulting to Hands
public static getEquipped ( ) : object
return object

hasEnoughGold() public static method

Returns whether the player has more than the amount specified of gold
public static hasEnoughGold ( int amount ) : bool
amount int
return bool

removeGold() public static method

Removes the integer amount from the player's gold if possible, doing nothing if not, returning a boolean value of it's success
public static removeGold ( int amount ) : bool
amount int
return bool

Property Details

equippedItem public_oe static_oe property

public static int equippedItem
return int

gold public_oe static_oe property

public static int gold
return int

itemCount public_oe static_oe property

public static Dictionary itemCount
return int>.Dictionary

items public_oe static_oe property

public static List items
return List