C# Class InventoryData, 2DPlatformer

Inheritance: MonoBehaviour
Afficher le fichier Open project: MarbleGameDev/2DPlatformer Class Usage Examples

Méthodes publiques

Свойство Type Description
equippedItem int
gold int
itemCount int>.Dictionary
items List

Méthodes publiques

Méthode 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

Méthode 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 méthode

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

Attack() public static méthode

Returns the float attack value of the equipped item
public static Attack ( ) : float
Résultat float

Awake() public static méthode

public static Awake ( ) : void
Résultat void

Cooldown() public static méthode

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

DropItem() public static méthode

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

GetItem() public static méthode

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

HasItem() public static méthode

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

Range() public static méthode

Returns the range attribute of the equipped item
public static Range ( ) : float
Résultat float

RemoveItem() public static méthode

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
Résultat bool

RemoveItem() public static méthode

public static RemoveItem ( string name, int number ) : bool
name string
number int
Résultat bool

ResetInv() public static méthode

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

UpdateInv() public static méthode

public static UpdateInv ( ) : void
Résultat void

UseItem() public static méthode

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

addGold() public static méthode

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

compareItems() public static méthode

public static compareItems ( object obj1, object obj2 ) : bool
obj1 object
obj2 object
Résultat bool

equipItem() public static méthode

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

getEquipped() public static méthode

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

hasEnoughGold() public static méthode

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

removeGold() public static méthode

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
Résultat bool

Property Details

equippedItem public_oe static_oe property

public static int equippedItem
Résultat int

gold public_oe static_oe property

public static int gold
Résultat int

itemCount public_oe static_oe property

public static Dictionary itemCount
Résultat int>.Dictionary

items public_oe static_oe property

public static List items
Résultat List