Daily Bonus

I wanted to ask if anyone has any ideas on implementing the daily bonus system?
Which checks that if a person plays the game daily, he gets a bonus.
Can you please point me in the right direction?

The way I accomplished this is as follows (from memory, so may not be completely right, but it’s the concept that matters):

  1. Read PlayerPrefs in for “LastDayPlayed”, and convert from a string to Date type.

  2. If value doesn’t exist yet, give them a bonus, and store current day at midnight as the LastDayPlayed value

  3. Otherwise, compute the time difference between this value and the current day at midnight.

  4. If time diff is > 24 hours and < 48 hours, save “LastDayPlayed” as current day at midnight and give them the bonus

void TimerUpdate()
//Current-Gives you current date and time
System.DateTime Current = new System.DateTime(System.DateTime.Now.Year,System.DateTime.Now.Month,System.DateTime.Now.Day,System.DateTime.Now.Hour,System.DateTime.Now.Minute,System.DateTime.Now.Second);
//Last-Gives you last played time(Get the last played time simply by storing the date time hours min sec in playerprefs as soon as player opens the game get those playerprefs values
System.TimeSpan Last=new System.DateTime(PlayerPrefs.GetInt(“LastOpened_Year”),PlayerPrefs.GetInt(“LastOpened_Month”),PlayerPrefs.GetInt(“LastOpened_Day”),PlayerPrefs.GetInt(“LastOpened_Hours”),PlayerPrefs.GetInt(“LastOpened_Minutes”),PlayerPrefs.GetInt(“LastOpened_Seconds”));
//TimeDiff-Gives you difference between last played time and current time
System.TimeSpan TimeDiff = Current.Subtract(Last).Duration();
if(TimeDiff.Days>=1 || TimeDiff.Hours>=24)
//Do your Stuf and its been more than 24 hours or more than one day


This code snippet will help you to get the time difference.Hope this may help you.