user3397025
user3397025

Reputation: 25

Shutdown Mechanism in Unity 3D for Therapeutic Video Game

I am working on a therapeutic video game in Unity 3D which can only be played by a patient for 2 hours per day. After the two hour mark is reached, the game should not be able to be played until a full 24 hours later.

What is the best way to go about this in C# using any built in features of Unity3D? I am looking to use PlayerPrefs, Time.time (for the time the game has been on) and can't find anything in the documentation or forum that would let me access the current date.

My pseudo code is as follows:

variable that stores current date

variable that stores total play time

variable that stores the time that the 2 hour mark was reached

if it has been 24 hours past the last 2 hour mark:

game turns on

else

Application.Quit() - turn off the game

current total play time variable += Time.time

Upvotes: 1

Views: 71

Answers (1)

Thomas Hilbert
Thomas Hilbert

Reputation: 3629

It's as simple as using System.DateTime to access the current system time and date. C# in Unity runs on the Mono Framework (or .NET under special circumstances) and you can use most of their functionality.

Upvotes: 0

Related Questions