I want to reward a user for 24 hour after 24 hour the game object will be locked for another 24 hours how would i do it in unity ???
public bool isLocked(){
System.UInt32 currentTime= System.DateTime.Now.Second;
if((currentTime-lastSavedTime)>(24*60*60)){
lastSavedTime=currentTime;
return false;
}
else{
return true;
}
}
public System.UInt32 lastSavedTime{
get{
string stime= PlayerPrefs.GetString("lastSavedTime","0");
return System.UInt32.Parse(stime);
}
set{
PlayerPrefs.SetString("lastSavedTime",value+"");
}
}
Call the method isLocked() where you want to check the locked status.
isLocked() will return true only once after 24 hours.
This whole process probably not work like the way you want but it will give you a quick Idea I hope.