Sign In Register

How can we help you today?

Start a new topic
Answered

How can I do something like social energy system with gamesparks?

 Hello,


I am developing mobile game which requires to have "energy system" like you see in candy crush, where each lives takes some amount of time to get increase.


So suppose, if you click "play game", 1 live will be deducted.

The timer will be start for 30 minutes.

User then have to wait for 30 mintutes to get another live to play next turn.


Any help regarding, how to implement it via gamesparks will be cool like how to store timer for each lives of particular user in cloud code,once timer ends then sending data back to game etc




Best Answer

On Registration, store the player's Id into another collection called "playerLives"


The document should look something like: {"playerId" : "5559d90b1b3f58c687edd7f5", "addLifeIn" : "30"}


For energy you can use the currency system.


In Cloud Code, every minute load every playerId from the playerLives collection, loop through every Id and decrement the "addLifeIn" value, once the "addLifeIn" value reaches zero, execute some code to add 1 currency to the player's balance.


Shane


Answer

On Registration, store the player's Id into another collection called "playerLives"


The document should look something like: {"playerId" : "5559d90b1b3f58c687edd7f5", "addLifeIn" : "30"}


For energy you can use the currency system.


In Cloud Code, every minute load every playerId from the playerLives collection, loop through every Id and decrement the "addLifeIn" value, once the "addLifeIn" value reaches zero, execute some code to add 1 currency to the player's balance.


Shane

Does this solution apply to updating the "server" state for all currently connected players?  For example, I need to compute the resource state of every currently connected player every minute or so.  It's going to be a relatively complex computation updating many items in the mongo document for a player (imagine a simcity-like update of the world state but not quite as complex as simcity).


Is this fast enough to work if you were lucky enough to have 100K concurrent users?

.

Login to post a comment