Answer the question
In order to leave comments, you need to log in
Creating a financial system in the game?
Hello! If it doesn’t make it difficult, share your knowledge on how to implement a money system in a game for mobile phones, the essence is that the game needs to remember how much money the player has, and even when the game is turned off, they accumulate. I do not ask for a code (I do not want to strain anyone) even a verbal description of what needs to be done will help me a lot. I write in C#, Unity engine. Thanks in advance friends.
Answer the question
In order to leave comments, you need to log in
The system... Wow, how loud!
int currentMoney - started the system.
PlayerPrefs.SetInt("Money", currentMoney) - saved.
You will find the download yourself - PlayerPrefs is your guide.
Consider all finances on the server, otherwise your program can be easily deceived. To protect yourself from very childish mistakes, implement the financial logic as a separate object, ideally even on a third-party engine, for example, on procedures in the database (this is the most logical place) so that a reliable database engine is responsible for the atomicity and consistency of the data.
If you need the user's balances to depend on the time the user is out of the game, then either track the time and entry and exit of the user, and at the time of each next entry, adjust the balances from time and other logic, or in the method that returns the current balance, make a formula, which will each time calculate, according to your logic, how much to add to the saved balance-constant from time, from the moment the user created the game. Roughly speaking, you will not have one currency, but two / several, but under the hood, when calculating the final balance, you simply sum up the available currencies, some are virtual - i.e. which do not have a current balance and it is calculated from time or something else, and some only a number in the base.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question