![]() |
Platformer Pro
2.3.2
A platform game kit for Unity.
|
A shop where a player can buy and sell items. More...
Public Member Functions | |
virtual void | Init () |
Init the shop. More... | |
void | ShowShop () |
Initialise and show the shop. More... | |
virtual ShopItemData | GetItemInPosition (int pos) |
Gets the item for given slot. More... | |
virtual int | GetSellPriceForItemAtPosition (int pos) |
bool | CanSellItem (string itemType) |
bool | WillBuyItemOfType (string itemType) |
PurchaseFailReason | GetPurchaseFailReasonInPosition (int index, Character character) |
Gets the reason why a purcahse of the given slot would fail. More... | |
int | PurchaseItemAt (int index, Character character, int desiredAmount) |
Supplied character purchases the item at given shop index and character. More... | |
bool | SellItemToShop (ItemInstanceData data, Character character, int slot) |
Supplied character purchases the item at given shop index and character. 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... | |
![]() | |
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 | |
string | shopName = "Shop" |
The name of the shop. Must be unique for each shop as its used in persistence. More... | |
string | currencyItem |
List< ShopItem > | items |
Items the shop sells. More... | |
int | sellMarkUp |
How much do we markup prices as a percentage 0 = no mark, 100 = 100% mark up. More... | |
bool | buyAllItems |
If true buy all items, if false buy only items that are listed as buyable in the item list. More... | |
int | buyMarkDown |
How much do we markdown prices as a percentage 0 = no mark down, 100 = 100% mark down (nothing paid). More... | |
bool | sellAllBoughtItems |
If true bought items which aren't in the item list still appear for sale using default sell price. More... | |
bool | neverRestock |
int | baseRestockInterval = 15 |
Restock interval in minutes. More... | |
int | maxRestock = 3 |
Maximum number of times to trigger restock regardless of time elapsed since last restock. More... | |
GameObject | visibleContent |
bool | escapeClosesShop = true |
If true pressing escape always closes shop. More... | |
![]() | |
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 = "Shop" |
The player preference identifier. More... | |
![]() | |
const string | BasePlayerPrefId = "PP.Persistent." |
The base player preference identifier. More... | |
Protected Member Functions | |
virtual void | OnShopSoldItem (string type, Character character) |
Raises the item sold event. More... | |
virtual void | OnShopPurchaseFailed (string type, Character character, PurchaseFailReason reason) |
Raises the item sold event. More... | |
virtual void | OnShopBoughtItem (string type, Character character) |
Raises the item bought event. More... | |
virtual void | OnShopShopRestocked () |
Raises the shop restocked event. More... | |
virtual void | ProcessUserInput () |
Checks for keys that close the store. More... | |
virtual void | HandleUnpause (object sender, System.EventArgs e) |
Make sure we close the shop if the game becomes unpaused for any reason. More... | |
virtual int | CalculateSellPriceFor (ShopItemData data) |
virtual int | CalculateBuyPriceFor (ShopItemData data) |
Calculates the buy price for the given item. More... | |
virtual int | CalculateBuyPriceFor (ItemTypeData data) |
Calculates the buy price for the given item. More... | |
int | DoPurchaseItemAt (int index, Character character, int desiredAmount) |
Purchases 1 or more items returning the amount purchased. More... | |
virtual void | UpdateSellableItems () |
virtual void | Restock () |
Checks the time since last restock and restocks once for each restock interval up to max restock times. More... | |
virtual void | DoRestock (ShopItem item, ShopItemData data) |
Does the actual restocking for the given item with no checks on time, etc (usually called from Restock). More... | |
virtual void | ShowUI () |
virtual void | HideShop () |
![]() | |
virtual void | OnLoaded () |
Raises the loaded event. More... | |
virtual void | ConfigureEventListeners () |
Init this instance. 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 | |
List< ShopItemData > | itemData |
Data about the actual items in the shop. More... | |
List< string > | sellableItems |
Cached list of things we sell. More... | |
![]() | |
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 string | Header [get] |
Gets the header string used to describe the component. More... | |
List< string > | SellableItem [get] |
Get a list of all items this shop sells, including items that are usually sold but that aren't in stock, and including bought items even if they aren't usually sold. More... | |
override string | PlayerPrefsIdentifier [get] |
override Character | Character [get, set] |
Gets the character reference. 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... | |
![]() | |
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... | |
![]() | |
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... | |
![]() | |
Character | Character [get, set] |
Get the character. More... | |
Events | |
System.EventHandler< ItemEventArgs > | ShopSoldItem |
Item sold by shop. More... | |
System.EventHandler< PurchaseFailEventArgs > | ShopPurchaseFailed |
Player tried to buy item but didn't have enough space or cash. More... | |
System.EventHandler< ItemEventArgs > | ShopBoughtItem |
Item purchased by shop More... | |
System.EventHandler< EmptyEventArgs > | ShopRestocked |
Item purchased. More... | |
![]() | |
System.EventHandler< EmptyEventArgs > | Loaded |
Sent when this persistable is loaded. More... | |
Additional Inherited Members | |
![]() | |
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 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... | |
A shop where a player can buy and sell items.
|
virtual |
Applies the save data to the object.
Implements PlatformerPro.Persistable.
|
protectedvirtual |
Calculates the buy price for the given item.
data | Item data. |
|
protectedvirtual |
Calculates the buy price for the given item.
data | Item data. |
|
protectedvirtual |
bool PlatformerPro.Shop.CanSellItem | ( | string | itemType | ) |
|
protected |
Purchases 1 or more items returning the amount purchased.
index | Index of the item in shop. |
character | Character doings the purchasing. |
|
protectedvirtual |
Does the actual restocking for the given item with no checks on time, etc (usually called from Restock).
|
virtual |
Support complex object serialisation by passing additional types to seralizer.
Reimplemented from PlatformerPro.Persistable.
|
virtual |
Gets the item for given slot.
pos | position. |
PurchaseFailReason PlatformerPro.Shop.GetPurchaseFailReasonInPosition | ( | int | index, |
Character | character | ||
) |
Gets the reason why a purcahse of the given slot would fail.
index | Index. |
|
virtual |
|
protectedvirtual |
Make sure we close the shop if the game becomes unpaused for any reason.
|
protectedvirtual |
|
virtual |
Init the shop.
|
protectedvirtual |
Raises the item bought event.
type | Type. |
character | Character. |
|
protectedvirtual |
Raises the item sold event.
type | Type. |
character | Character. |
|
protectedvirtual |
Raises the shop restocked event.
|
protectedvirtual |
Raises the item sold event.
type | Type. |
character | Character. |
|
protectedvirtual |
Checks for keys that close the store.
int PlatformerPro.Shop.PurchaseItemAt | ( | int | index, |
Character | character, | ||
int | desiredAmount | ||
) |
Supplied character purchases the item at given shop index and character.
index | Index. |
character | Character. |
desiredAmount | Number to purcahse or 0 for default. |
|
virtual |
Resets the save data back to default.
Implements PlatformerPro.Persistable.
|
protectedvirtual |
Checks the time since last restock and restocks once for each restock interval up to max restock times.
|
virtual |
Get the type of object this Persistable saves.
Implements PlatformerPro.Persistable.
bool PlatformerPro.Shop.SellItemToShop | ( | ItemInstanceData | data, |
Character | character, | ||
int | slot | ||
) |
Supplied character purchases the item at given shop index and character.
void PlatformerPro.Shop.ShowShop | ( | ) |
Initialise and show the shop.
|
protectedvirtual |
|
protectedvirtual |
bool PlatformerPro.Shop.WillBuyItemOfType | ( | string | itemType | ) |
int PlatformerPro.Shop.baseRestockInterval = 15 |
Restock interval in minutes.
bool PlatformerPro.Shop.buyAllItems |
If true buy all items, if false buy only items that are listed as buyable in the item list.
int PlatformerPro.Shop.buyMarkDown |
How much do we markdown prices as a percentage 0 = no mark down, 100 = 100% mark down (nothing paid).
string PlatformerPro.Shop.currencyItem |
bool PlatformerPro.Shop.escapeClosesShop = true |
If true pressing escape always closes shop.
|
protected |
Data about the actual items in the shop.
List<ShopItem> PlatformerPro.Shop.items |
Items the shop sells.
int PlatformerPro.Shop.maxRestock = 3 |
Maximum number of times to trigger restock regardless of time elapsed since last restock.
bool PlatformerPro.Shop.neverRestock |
|
protected |
Cached list of things we sell.
bool PlatformerPro.Shop.sellAllBoughtItems |
If true bought items which aren't in the item list still appear for sale using default sell price.
int PlatformerPro.Shop.sellMarkUp |
How much do we markup prices as a percentage 0 = no mark, 100 = 100% mark up.
string PlatformerPro.Shop.shopName = "Shop" |
The name of the shop. Must be unique for each shop as its used in persistence.
|
static |
The player preference identifier.
GameObject PlatformerPro.Shop.visibleContent |
|
getset |
Gets the character reference.
The character.
|
get |
Gets the header string used to describe the component.
The header.
|
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).
The identifier.
|
get |
|
get |
Gets the data to save.
|
get |
Get a list of all items this shop sells, including items that are usually sold but that aren't in stock, and including bought items even if they aren't usually sold.
The sellable item.
System.EventHandler<ItemEventArgs> PlatformerPro.Shop.ShopBoughtItem |
Item purchased by shop
System.EventHandler<PurchaseFailEventArgs> PlatformerPro.Shop.ShopPurchaseFailed |
Player tried to buy item but didn't have enough space or cash.
System.EventHandler<EmptyEventArgs> PlatformerPro.Shop.ShopRestocked |
Item purchased.
System.EventHandler<ItemEventArgs> PlatformerPro.Shop.ShopSoldItem |
Item sold by shop.