Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: nehz on January 20, 2012, 09:58:42 PM

Title: Make a pet hungry every 6 hours even the game is not on
Post by: nehz on January 20, 2012, 09:58:42 PM
How can i make a pet hungry every 6 hours?(real life time)
This includes the next time the player start the game, it will calculate how much time had passed since and for every 6 hours the hunger/food of the pet will will decrease by 10 from the global hunger value pre-set when the egg is hatch.

any help would be much appreciated.
 
Title: Re: Make a pet hungry every 6 hours even the game is not on
Post by: elvis75k on January 21, 2012, 09:49:21 AM
searching the site for making custom actions i find some hints on how to access system date..
Animal crossing use this kind of variable and i love how it work.

https://hutonggames.fogbugz.com/default.asp?W351
Title: Re: Make a pet hungry every 6 hours even the game is not on
Post by: jeanfabre on January 24, 2012, 04:35:09 AM
Hi,

 Yes, you'll likely need to create some custom actions.

look at the following timespan class:
http://msdn.microsoft.com/en-us/library/system.timespan.hours.aspx (http://msdn.microsoft.com/en-us/library/system.timespan.hours.aspx)


 1: store a datetime as frame of reference ( like the last time you have increased his hunger).
 2: on start, get the current time and store the difference between the current time and the frame of reference in a timespan class. then find out the number of hours elapsed you can then decrease the value by the number of hours.

if you need help to create the custom actions required for this, tell me and I'll do them.

 Bye,

 Jean
Title: Re: Make a pet hungry every 6 hours even the game is not on
Post by: nehz on January 24, 2012, 04:41:57 PM
@ Jean:
Can you make the custom actions for me please?

Thank you for your assistance.
Title: Re: Make a pet hungry every 6 hours even the game is not on
Post by: Mark_T on January 25, 2012, 01:32:19 AM

Such an action might be really useful.
Would it be an OS specific action? Or it`s the same for every platform?
Thanks.
Title: Re: Make a pet hungry every 6 hours even the game is not on
Post by: jeanfabre on January 25, 2012, 03:19:08 AM
Hi,

They would work on any platform ( I am pretty sure of that).

 I'll work on some actions for this. Remind me again sometimes next week if nothing come up before... running in all directions at the moment, so might slipped off my mind.

 Bye,

 Jean
Title: Re: Make a pet hungry every 6 hours even the game is not on
Post by: jeanfabre on January 27, 2012, 07:00:16 AM
Hi,

 Here is is:

http://hutonggames.com/playmakerforum/index.php?topic=1047.0 (http://hutonggames.com/playmakerforum/index.php?topic=1047.0)

and I made a unitypackage with a working scene. This is just a proof of concept and more will need to be done for a fully working hunger system, but it deduce per hour, and store in the playerprefs settings so that if you stop and repen it will catch up and starve the right amount since the last time.

 Hopefully, that is what you are after. If you need any help or have question, don't hesitate.

Bye,

 Jean