© vrchewal

Money Kit Documentation

version 1.0                                                     for Unity

Documentation: Online Documentation

Support: vrchewal.com/unity/money-kit

Asset Store: http://u3d.as/1qGD

Jump To:

Introduction

How To

The Scripts

API

Troubleshooting

Support

Introduction

Money Kit is your Unity Tycoon Toolkit!

In most games, you need to manage an in-game economy. With Money Kit, you can easily handle this task without worrying about the math and management of the numbers. Handle multiple currencies, player wallets, NPC wallets, banks, stores, rewards, jobs and much much more.

Money Kit is designed to be a collection of scripts, primarily for coders to easily create an in-game economy. Designers and other non-programmers can use it for many simple applications, however, some C# coding will be required for most uses. The demos are the best place to see how the code works. Feel free to copy whatever you need from the demos and extend the system. Let us know what you create!

If you run into any issues, you can reach out to us on any of our support channels for assistance.

All Entities! Any entity in your game can get involved. Attach the MK_Entity script to your players, NPCs, banks, quests, chests, stores, side shops, or the master game manager. Any entity can hold, send and receive money.

Wallets! Track your game money in wallets. Any entity in your game can have multiple wallets, one for each currency. Give wallets to your players, NPCs, side shops, quests, banks, etc.

Multiple Currencies! Money Kit supports multiple currencies. Support your players need for gold, diamonds, points, wood, stone or anything else that needs tracking.

Calculate Interest! Built in support for accounts between entities. Create savings accounts for the player to deposit money that earns them interest. Or, give them a loan with compounded interest!

Jobs! Put your entities to work! Built in support for jobs, or recurring transfers from one wallet to another.

Crafting! Support for crafting products from other products. Great for recipes and other crafting based games.

Idle Earnings! Built in support for calculating time spent out of the game, whether between gameplay sessions or time spent with the application out of focus. This is a great opportunity to show and advertisement to double your player’s idle earnings!

Tools! Includes several scripts that automate your tycoon game. MoneyKit Manager, Timers, Modifiers, Inventories, Price Randomizer, Saving/Loading and more!

Automation! Money Kit can manage many aspects of your economy from time cycles, automatic interest calculation, automatic pricing randomization and automatic job payments. Just set some settings and let the system take care of the rest.

This package contains multiple demos to show off the features of the plugin. The best way to learn the system is to play each demo and review their scripts to see how to achieve the various features.


How To

Money Kit is a very versatile and powerful toolkit. While the Scripts and API section will dive further into the details of each tool, we will provide an overview of how to use the system now. Note: Each script will register itself with the manager no matter where it is located in the hierarchy. You can attach the scripts on your existing gameobjects with no issue. The location in the hierarchy is not important.

  1. Add the Money Kit Prefab

Add the Money Kit prefab to the scene, located Assets/MoneyKit/Prefabs/Money Kit. The MK_Manager component is attached to the main gameobject of the prefab. Later, you will want to adjust the settings of the Manager to your needs. Check out the section below in “The Scripts” for details on each option. For now, we will leave the defaults settings.

 

  1. Add your Currencies

Looking at the children of our new Money Kit gameobject in the hierarchy, we can see several objects that work as containers. One of these containers is named “Currencies.” This holds all of your currencies. The prefab contains one currency by default, Gold. You can use this one, edit or remove it, and add as many new currencies as your game requires. Let’s add a new one.

Create a new empty gameobject as a child of Currencies and rename it Diamonds (or whatever currency you plan to use for your game, for demonstration purposes, we will use Diamonds). Add the MK_Currency component to this new gameobject, located Assets/MoneyKit/Scripts/MK_Currency.cs

Type in your currency name into the name field of the component. This will likely match the gameobject name, but scripts will search for it based on its name in this field.

 

  1. Add your Entities

The prefab already contains an entity called Player. You can use this or remove it and attach the MK_Entity script to your existing player gameobject. For the demo, we will use the prefab player object and add a new entity to be our Bank. You will want to add an Entity for every object in the game that needs to send or receive money.

Create an empty gameobject as a child of “Entities” and rename it “Bank.” Find the MK_Entity script located Assets/MoneyKit/Scripts/MK_Entity.cs and drag it onto your new Bank gameobject. Set the Name field to Bank.

           

  1. Wallets, wallets, wallets!

Entities need a wallet to hold, send and receive money. One wallet for each currency. Wallets will be created at runtime automatically, as needed. Check out the Player entity and see that it already contains a wallet for the default Gold currency. We will do the same now for our new Bank entity.

Create a new empty gameobject as a child of the Bank entity and rename it “BankGoldWallet.” Add the MK_Wallet script to this object, located Assets/MoneyKit/Scripts/Core/MK_Wallet.cs. Now, connect this wallet to the Bank by dragging the wallet gameobject

   

  1. Jobs and Accounts

Details coming soon, check demos for usage examples.

  1. Products, Inventory and Recipes

Details coming soon, check demos for usage examples.

  1. Timers and Modifiers

Details coming soon, check demos for usage examples.

  1. Save and Load

Details coming soon, check demos for usage examples.

  1. Idle Earnings and Lost Focus

Details coming soon, check demos for usage examples.

The Scripts

MK_Manager

The Manager is the hub of the system and contains the high level API functions. Adjust the settings to your liking and check out the API section for additional methods available.

TimeOptions TimeOption

Set to SystemClock if you want to use the devices clock to track time or set to UnityTime if you want to use the Unity Time.time instead. The difference is that you can track offline time with SystemClock where UnityTime can only track the time in the game. Generally, you will want to use UnityTime unless you plan to calculate idle time out of the application.

bool AutoStartFirstDay

The manager can start your first day automatically once everything is loaded and ready. If false, the Day will remain at 0 and will require you to run MK_Manager.StartNextDay(); to start the first day.

bool AutoAdvanceDays

The system is setup on time cycles, labeled as days. Set to false if you want to manually manage the time cycles. If you have a turn based game or want to manage the flow of the game, set to false. Set to true if your game runs in real time and want MK_Manager to automate some tasks.

float SecondsPerDay

If AutoAdvanceDays is true, the manager will advance the days on time schedule.

bool AutoApplyInterest

If true, MK_Account scripts will calculate and apply interest automatically.

bool AutoPayJobs

If true, MK_Job scripts will automatically transfer money to the supplied entities.

AutoSaveOptions AutoSaveOption

You can set an option on when to call the save delegate automatically. In addition, you can call the MK_Manager.Save(); method to initiate a save game manually.

AutoLoadOptions AutoLoadOption

You can set an option on when to call the load delegate automatically. In addition, you can call the MK_Manager.Load(); method to load a save game manually.

bool NoDestroyOnLoad

If true, the manager will remain active when changing scenes.

bool PrintToConsole

If true, scripts will print key information to the Console.

bool LimitTransactionLog

If true, the manager will remove old transaction entries to limit memory usage.

int TransactionLogMax

If LimitTransactionLog is true, the manager will maintain this quantity of transaction logs.

Transform *Parent

The transform parents for the various API created objects.

MK_Currency

Add as many currencies as you want. Ultimately, currencies are just labels for the types of money you manage. For example, in many mobile games, players can earn gold, stone, wood, gems, etc. Each of these are a currency.

string Name

The name of the currency. Should be unique as scripts will attempt to find currency by name.

MK_Entity

Create as many entities as you want. Entities are players, NPCs and systems in your game. Entities can send and receive money from other entities. Each entity can have multiple wallets, a single wallet for each currency the entity needs to use.

string Name

The name of the entity.

List<MK_Wallet> Wallets

The collection of wallets for this entity. Wallets will be created automatically at runtime for each currency the entity uses. You can create and connect wallets in editor if you want to preload the wallet(s).

List<MK_Account> Accounts

The connected accounts for this entity. This includes both lender and borrower accounts. Used for reference, however, the accounts will still function as expected even if not added to this list.

List<MK_Job> Jobs

The collection of Jobs for this entity. This can include both employer and employee jobs. Used for reference, however, the jobs will still function as expected even if not added to this list.

MK_Inventory ProductInventory

The product inventory for this entity. Can be used by other scripts to check/add/edit/remove items from the entity’s inventory.

MK_Wallet

Holds the money of a specific currency for the entity. One wallet per currency per entity. The wallet can be set to contain unlimited funds if needed. This is ideal for banks and system entities that you don’t want to run out of money. Wallets are automatically created on demand if they do not exist. You can optionally turn off the ability to send or receive money for a wallet, essentially freezing the funds.

decimal Amount

The quantity of money in the wallet.

MK_Base.Units Unit

The suffix for the amount. In multiples of 1000, the Unit determines the ultimate size of the amount. Setting Amount to 1000 with Unit of One is equivalent to Amount of 1 and Unit of Thousand.

MK_Currency Currency

The currency used for the wallet.

bool UnlimitedFunds

If true, the wallet will never change the amount, but will always have money available to send.

bool CanSendMoney

If true, the wallet is available to send money to another wallet. If false, any attempt to send money from this wallet will fail.

bool CanReceiveMoney

If true, the wallet can receive money from another wallet. If false, the wallet will not receive money from another wallet.

MK_Account

Setup accounts to track entity to entity transfers. Examples of accounts are bank accounts and loans. Accounts can optionally apply interest on whatever time cycle you want. Accounts can be setup for tracking and managing any currency transaction between any two entities. Interest can be applied in simple or compounded calculations. Accounts are not required to send money between two entities, only for tracking and calculating interest or debt between two entities.

Setup as a Lender and Borrower. When the Lender gives money to the Borrower, the Principal is increased. When the Borrower pays back the Lender, the Principal is decreased. Interest can be applied to increase the amount owed by the Borrower.

AutoTransfers can be setup to make regular payments from the Borrower to the Lender or regular transfers from the Lender to the Borrower. Examples of these would be a Bank loan where the player needs to make regular payments to payback the loan or if a player wants to make recurring deposits into a bank account.

decimal Amount

The total amount owed by the Borrower to the Lender. This includes the principal and interest.

MK_Base.Units Unit

The suffix for the amount. In multiples of 1000, the Unit determines the ultimate size of the amount. Setting Amount to 1000 with Unit of One is equivalent to Amount of 1 and Unit of Thousand.

string Name

The name for the account. For example: Savings, BankLoan, etc.

MK_Currency Currency

The currency used for the account.

MK_Entity Lender

The entity that gave the initial principal amount to the Borrower. This might be a bank entity giving money to the player.

MK_Entity Borrower

The entity that received the initial principal amount from the Lender. This might be the player receiving money from a Bank entity as a loan.

MK_Balance Principal

The balance of the account minus any interest applied. This is the actual amount the Lender has given the Borrower.

MK_Balance Interest

The balance of the interest applied to the account.

bool Active

If true, the account is active. If false, no interest will be applied and the account is considered closed.

float InterestRate

The interest rate used for calculating interest on the account.

MK_Base.InterestType InterestType

Simple or Compounded. Simple only calculates interest based on the amount in the Principal. Compounded calculates interest on the total amount of the account, including both the Principal and any interest already applied.

uint DaysBetweenInterest

The number of days between interest calculations.

AutoTransferOptions AutoTransfer

If set to FromBorrowerToLender, this will make regular payments from the Borrower to payback the Lender. This will never exceed the total amount of the account. If set to FromLenderToBorrower, the Lender will transfer money to the Borrower, increasing the Principal with each transfer.

decimal AutoTransferAmount

The amount to transfer automatically.

MK_Base.Units AutoTransferUnit

The unit for the AutoTransferAmount field.

uint DaysBetweenAutoTransfers

The number of days between attempts to autotransfer according to the settings above.

uint TotalAutoTransferDays

The total number of days for the term of the autotransfer. The number of transfers would be determined by a combination of DaysBetweenAutoTransfers and the TotalAutoTransferDays. For example, if you set TotalAutoTransferDays to 30 and DaysBetweenAutoTransfers to 3, then every 3 days an autotransfer would occur for a total of 10 autotransfers.

MK_Job

Jobs are essentially a recurring transfer from one entity to another. While active, the Job will send money from the Employer to the Employee according to the settings, forever.

If money is transferred successfully, the boolean isPaid will be true. The public method IsEmployeeWorking(), is a good method to check to determine if the Employee entity has been paid, the job is active and the employee should perform whatever task you set for it.

string Name

The name for the job.

MK_Entity Employer

The entity that sends money to the Employee.

MK_Entity Employee

The entity that receives money from the Employer.

bool Active

If true, the job is active and will make regular transfers from the Employer to the Employee.

bool isPaid

If true, the Employee has been paid in the recent pay cycle. Can be used to verify payments are being sent from the Employer to the Employee.

MK_Currency Currency

The currency used for the job.

decimal Salary

The amount to pay the employee each pay cycle.

MK_Base.Units SalaryUnit

The unity for the salary.

uint DaysBetweenPay

The number of days between attempts to pay the Employee.

MK_Product

Products represent items in your game. The product script is used as the management of prices and the item held in a players inventory. You can set a base price, sell price and upgrade price. Prices can have ranges and be automatically randomized. You may set the Level for the item and the cost to upgrade. All of this is optional, as you may just want to track if the player has the product in their inventory. See the demos for some ways that Products can be used.

string Name

The name for the product.

int Level

An optional field to track the level of the product. For example, you could have a sword that can be upgraded from Level 1 to 20. With your own scripts determining the damage done based on the level of the sword.

decimal BasePrice

Can be used as the purchase price for the product.

MK_Base.Units BasePriceUnit

The unit for the BasePrice.

decimal SellPrice

Can be used as the selling price for the product.

MK_Base.Units SellPriceUnit

The unit for the SellPrice.

decimal UpgradePrice

Can be used as the cost to upgrade the product’s level.

MK_Base.Units UpgradePriceUnit

The unit for the UpgradePrice.

float MaxRandomChange

The percentage of change used to calculate randomized prices. If set to 0.1f, this would be a maximum of 10% change from the seed values, in both positive and negative directions.

float BasePriceRandomSeed

The midpoint for a randomized base price. If set to 100, with a MaxRandomChange set to 0.1f, the range for the base price would be 90 to 110.

MK_Base.Units BasePriceUnitRandomSeed

The unit for the BasePriceRandomSeed.

float SellPriceRandomSeed

The midpoint for a randomized sell price. If set to 100, with a MaxRandomChange set to 0.2f, the range for the sell price would be 80 to 120.

MK_Base.Units SellPriceUnitRandomSeed

The unit for the SellPriceRandomSeed.

float UpgradePriceRandomSeed

The midpoint for a randomized upgrade price. If set to 100, with a MaxRandomChange set to 0.25f, the range for the upgrade price would be 75 to 125.

MK_Base.Units UpgradePriceUnitRandomSeed

The unit for the UpgradePriceRandomSeed.

MK_Inventory

An entity can have an inventory of products. The inventory script tracks how many of any given product the entity owns. Balances are created as needed at runtime or you can manually add an InventoryBalance to the inventory, connect the Product and provide an amount.

List<MK_InventoryBalance> ProductBalances

The collection of product balances in the inventory. An InventoryBalance is like a wallet, but for products. It tracks how many of a product the inventory is holding.

MK_Recipe

The recipe script is used to create recipes and craft products. You supply the ingredients (MK_Product) and how many of each are required to craft the final product. The script will reduce the balances of your ingredients and increase the balance of your final product automatically.

string Name

The name for the recipe.

List<MK_Product> Ingredients

The list of products that are required to craft the final product. You supply the inventory to check and the recipe will check it for this list of products.

List<int> IngredientQty

The amount of each product in the Ingredients list that are required to craft the final product. The indexes of this list need to match up with indexes of the Ingredients list.

MK_Product Output

The product to craft if all the ingredients are present in the inventory.

float OutputQty

The amount of the product to create when crafting.

MK_Timer

The Timer script can be used to track time for objects in the system. This is a powerful script that can track time in many ways, allow modifiers and reporting on progress.

string Name

The name for the timer.

TimeUnits TimeUnit

Select how you want to track the time. UpdateFrames is the number of frame ticks from Unity’s Update MonoBehavior. FixedUpdateFrames is the number of frame ticks from FixedUpdate. Seconds is the number of seconds in real time, respecting the MK_Manager TimeOption. Days uses the Day value as reported from MK_Manager.

float TimeAmount

The amount of time for the timer, based on whatever TimeUnit you picked above. Setting TimeAmount to 2 and TimeUnit to Seconds will mean the timer will end in 2 seconds. If TimeUnit is set to UpdateFrames, the timer will complete in 2 frames.

float TimeAmountModified

This is equal to TimeAmount with any active Modifiers applied. See the Modifiers section for more options.

float Progress

The percentage of progress towards completing the timer. Ranging from 0f to 1f, where 1f is a completed timer.

bool IsActive

Set this to false to turn off the timer, true to turn on.

List<MK_Modifier> Modifiers

The list of modifiers that can affect the timer. See the Modifiers section for more options.

MK_Modifier : MK_ModifierBalance, MK_ModifierTime, MK_ModifierInventory, MK_ModifierProductLevel

Modifiers give you the ability to adjust other script’s values if certain conditions are true. Modifiers can be used with any script that supports them, like the MK_Timer script.

If all the conditions are met, the modifier becomes Active. When active, the Action and Value in the How to Modify section become relevant.

For example, you create a Timer script and set it to complete in 10 seconds. You set the Action to Subtract and the Value to 2. When the modifier is Active, the Timer will then use the action of the modifier by subtracting 2 seconds from its own TimeAmount. The timer’s TimeAmountModified will now equal 8.

We will add support for modifiers to more scripts in the future. Perhaps the ability to modify product prices if conditions are met. Maybe, 50% off one product if the player has another product in their inventory. The options are nearly endless.

There are multiple styles of modifiers, each with their own conditions and uses. Each type builds on the base MK_Modifier script, but adds more conditions. They all work the same once Active, the only difference are the conditions by which they become active.

MK_Modifier

The base modifier is pretty simple. You can turn it on or off.

string Name

The name for the modifier.

ModifyOptions Action

The action to take if the modifier is active. The options are Add, Subtract, Multiply, Divide.

float Value

The amount to use for the Action. It is up to the connected script to determine what this means.

        bool ForceActive

The first condition. If true, the modifier will be active no matter what other conditions are present.

MK_ModifierBalance

This modifier checks a MK_Balance (or children like MK_Wallet) and compares it to the amount you specify.

MK_Balance BalanceToCheck

The balance object to check.

MK_Base.ComparisonOptions Comparison

The comparison operator to check the balance. You can check for less than, less than or equal, equal, not equal, greater than or equal, and just greater than.

decimal Amount

The amount to compare with the balance.

MK_Base.Units Unit

The unit for Amount.

MK_ModifierInventory

This modifier checks an inventory for a list of products.

MK_Inventory InventoryToCheck

The inventory to check for a list of products.

List<MK_Product> ProductsToFind

The list of products to find. Currently, the inventory just needs to have a positive balance for each product. This may be adjusted in the future to allow for specific quantities for each product.

MK_ModifierTime

This modifier checks the day reported by the manager and allows for comparisons.

MK_Base.ComparisonOptions DayComparison

The comparison operator to check the day value.

uint Day

The day value for the comparison.

MK_ModifierProductLevel

This modifier checks the level of a given product and makes a comparison.

MK_Product Product

The product with the Level to compare.

MK_Base.ComparisonOptions LevelComparison

The comparison operator to check the level value.

uint Level

The level value for the comparison.

MK_Balance

The underlying class of wallets and other number tracking classes. This maintains the actual numbers and quantitative units for wallets.

MK_IO

The base class for saving and loading games. This creates the save data (see MK_SaveData) and can rebuild the game from a save file. There are multiple provided scripts for saving and loading games, they all derive from this script. If you need to create your own custom save/load script, you will want to look at the structure of the following scripts to ensure compatibility.

string SaveName

The save name for the game. Depending on the save method, this could be a file name or a key in a larger save system. Best practice then is to limit special characters and spaces.

MK_JsonFile

This script will store your saved games in a json file located in the application persistent data path.

MK_PlayerPrefs

This script will store your saved games in Unity’s PlayerPrefs.

MK_EasySave3 (Third Party Support)

This script can be used if you use the third party plugin called Easy Save 3, by Moodkie. This script will save your game using the ES3 tools. Check out ES3 at https://assetstore.unity.com/packages/tools/input-management/easy-save-the-complete-save-load-asset-768

MK_Transaction

Used to log transactions between two entities. MK_Manager keeps a list of transactions reported to it for later retrieval.

MK_Factory

The factory contains all of the object creation methods. Used when loading from a save game to create and update the system. You can also use it to create objects at runtime. It will automatically update matching objects or create new ones if they do not exist.

MK_Base

The base calculation script. Review this if you are extending the system for your own scripts. The methods within are very useful for math and formatting values.

MK_MonoBehavior

This script contains all the logic for creating GUIDs and is the source for every savable object in the system. Each object that is a child of MK_MonoBehavior will get a unique identifier, making save games possible. It is itself derived from Unity’s MonoBehavior, so all the usual callbacks work as expected.

API

The following methods are open via the Money Kit API. Add “using MoneyKit;” to the top of your scripts. These are the main functions for the primary scripts. Review each script to learn more about them and the entire list of functions available.

MK_Manager

StartNextDay

void

MK_Manager.StartNextDay();

Manually start the next day cycle for automatic interest calculation and job payments. Use if AutoAdvanceDays is false.

CreateEntity

MK_Entity

MK_Manager.CreateEntity(string name, string id);

Creates an entity with a given name. The id is optional and can be used for unique tracking of entities.

CreateCurrency

MK_Currency

MK_Manager.CreateCurrency(string name);

Creates a currency.

CreateAccount

MK_Account

MK_Manager.CreateAccount(MK_Entity Lender, MK_Entity Borrower, float InterestRate);

Creates an account between two entities. Interest rate is optional.

CreateJob

MK_Job

MK_Manager.CreateJob(MK_Entity Employer, MK_Entity Employee, double Salary, MK_Base.Units Unit, MK_Currency Currency);

Creates a recurring transfer between two entities. Employer is the sender whose wallet will be reduced each time cycle. Employee will receive the funds. Salary and Unit are the amount sent in the currency provided.

CreateProduct

MK_Product

MK_Manager.CreateProduct(string name, string BasePrice, MK_Base.Units BasePriceUnit, string SellPrice, MK_Base.Units SellPriceUnit);

Creates a product that you can use for basic tracking of a base value and a sell value. This is a helper tool and not required.

AccountTransfer

bool

MK_Manager.AccountTransfer(MK_Entity Sender, MK_Account Account, decimal Amount, MK_Base.Units Unit);

Sends money from the Sender wallet to the Borrower wallet set in the account in the currency set in the account.

LogTransaction

void

MK_Manager.LogTransaction(MK_Transaction Transaction);

Logs a transaction created by other methods. Used to track a history of transactions between entities.

GetEntities

List<MK_Entity>

MK_Manager.GetEntities();

Returns the list of entities registered to the manager.

GetAccounts

List<MK_Account>

MK_Manager.GetAccounts();

Returns the list of accounts registered to the manager.

GetJobs

List<MK_Job>

MK_Manager.GetJobs();

Returns the list of jobs registered to the manager.

GetProducts

List<MK_Product>

MK_Manager.GetProducts();

Returns the list of products registered to the manager.

GetCurrencies

List<MK_Currency>

MK_Manager.GetCurrencies();

Returns the list of currencies registered to the manager.

GetCurrency

MK_Currency

MK_Manager.GetCurrency(int index);

Returns the currency from the registered list based on its index.

GetCurrency

MK_Currency

MK_Manager.GetCurrency(string name);

Returns the currency from the registered list based on its name.

GetTransactions

List<MK_Transaction>

MK_Manager.GetTransactions();

Returns the list of transactions logged into the manager.

SubscribeOnStartNextDay

void

MK_Manager.SubscribeOnStartNextDay(OnStartNextDayDelegate method);

Adds method to the delegate called when StartNextDay is run.

UnsubscribeOnStartNextDay

void

MK_Manager.UnsubscribeOnStartNextDay(OnStartNextDayDelegate method);

Removes method from the delegate called on StartNextDay.

MK_Entity

GetWallet

MK_Wallet

MK_Entity.GetWallet(string currency);

Returns the wallet for the entity in the given currency. Creates the wallet if it does not exist.

GetWallet

MK_Wallet

MK_Entity.GetWallet(MK_Currency currency);

Returns the wallet for the entity in the given currency. Creates the wallet if it does not exist.

SendMoney

bool

MK_Entity.SendMoney(MK_Entity Receiver, decimal amount, MK_Base.Units unit, MK_Currency Currency);

Sends money if available to the receiver in the currency provided.

ReceiveMoney

bool

MK_Entity.ReceiveMoney(decimal amount, MK_Base.Units unit, MK_Currency Currency);

Receives money in the currency provided.

MK_Balance

Increase

void

MK_Balance.Increase(decimal Value, MK_Base.Units ValueUnit);

Adds Value to the balance. Used by wallets and accounts.

Decrease

void

MK_Balance.Decrease(decimal Value, MK_Base.Units ValueUnit);

Subtracts Value from the balance. Used by wallets and accounts.

Set

void

MK_Balance.Set(decimal Value, MK_Base.Units ValueUnit);

Sets the balance to Value. Good for settings a default wallet or account balance.

MK_Base

Increase

decimal (out Units)

MK_Base.Increase(decimal StartingAmount, Units StartingUnit, decimal Value, Units ValueUnit, out Units UnitUnit);

Adds Value to the StartingAmount and automatically handles converting different units. Returns the new calculated decimal value and uses out to return the new unit.

Decrease

decimal (out Units)

MK_Base.Decrease(decimal StartingAmount, Units StartingUnit, decimal Value, Units ValueUnit, out Units UnitUnit);

Subtracts Value from the StartingAmount and automatically handles converting different units. Returns the new calculated decimal value and uses out to return the new unit.

CalculateInterest

decimal

MK_Base.CalculateInterest(decimal StartingAmount, float interestRate, InterestType interestType, int days);

Calculates interest and returns just the interest value.

FormatNumberAfterThousands

string

MK_Base.FormatNumberAfterThousands(decimal Amount, Units unit, bool append_unit, bool long_unit, string format);

Formats a number to a more user friendly readable format. A few options and defaults that should work for most cases. Use FormatNumber for more control. This function converts the number to a common format for money.

Troubleshooting

Oops, something went wrong. You have come to the right place.

1

Problem 

You see errors and warnings regarding TextMesh Pro or do not see text in the demo.

Answer

The demo uses TextMesh Pro for text labels. TMP is built in to Unity now as a package you can easily import. For older versions of Unity, get TMP from the asset store and import into your project. Or, delete the demo folder if you do not need it.

2

Problem 

You see errors and warnings saying you are missing currency.

Answer

You are attempting to ask the manager for a currency that you have not created. Add the currency via the methods in this document and provide the reference to the manager script.

Support

You can get your question answered by emailing support@vrchewal.com

Thank you for your purchase of Money Kit!