C# Класс InventoryData, 2DPlatformer

Наследование: MonoBehaviour
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
equippedItem int
gold int
itemCount int>.Dictionary
items List

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

AddItem() публичный статический Метод

Used to add items to the inventory
public static AddItem ( object name, int number ) : void
name object
number int
Результат void

Attack() публичный статический Метод

Returns the float attack value of the equipped item
public static Attack ( ) : float
Результат float

Awake() публичный статический Метод

public static Awake ( ) : void
Результат void

Cooldown() публичный статический Метод

Returns the cooldown/swingSpeed attribute of the equipped item
public static Cooldown ( ) : float
Результат float

DropItem() публичный статический Метод

Executes the Drop() method on the object passed if it exists in the inventory
public static DropItem ( object obj ) : void
obj object
Результат void

GetItem() публичный статический Метод

Returns the item object from the inventory matching the name passed, defaulting to null
public static GetItem ( string name ) : object
name string
Результат object

HasItem() публичный статический Метод

Returns boolean whether the object passed exists in the inventory
public static HasItem ( object obj ) : bool
obj object
Результат bool

Range() публичный статический Метод

Returns the range attribute of the equipped item
public static Range ( ) : float
Результат float

RemoveItem() публичный статический Метод

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
Результат bool

RemoveItem() публичный статический Метод

public static RemoveItem ( string name, int number ) : bool
name string
number int
Результат bool

ResetInv() публичный статический Метод

Clears all inventory data, then saves to disk
public static ResetInv ( ) : void
Результат void

UpdateInv() публичный статический Метод

public static UpdateInv ( ) : void
Результат void

UseItem() публичный статический Метод

Executes the Use() method on the object passed if it exits in the inventory
public static UseItem ( object obj ) : void
obj object
Результат void

addGold() публичный статический Метод

Adds the integer amount to the player's gold quantity
public static addGold ( int amount ) : void
amount int
Результат void

compareItems() публичный статический Метод

public static compareItems ( object obj1, object obj2 ) : bool
obj1 object
obj2 object
Результат bool

equipItem() публичный статический Метод

Equips the object passed if it exists in the inventory
public static equipItem ( object obj ) : void
obj object
Результат void

getEquipped() публичный статический Метод

Returns the currently equipped item, defaulting to Hands
public static getEquipped ( ) : object
Результат object

hasEnoughGold() публичный статический Метод

Returns whether the player has more than the amount specified of gold
public static hasEnoughGold ( int amount ) : bool
amount int
Результат bool

removeGold() публичный статический Метод

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
Результат bool

Описание свойств

equippedItem публичное статическое свойство

public static int equippedItem
Результат int

gold публичное статическое свойство

public static int gold
Результат int

itemCount публичное статическое свойство

public static Dictionary itemCount
Результат int>.Dictionary

items публичное статическое свойство

public static List items
Результат List