Configuring the Time Limit
Last updated
Last updated
This setting defines the available time for each player to answer questions during a game session.
This tutorial requires modifying scripts.
In the Project window, navigate to KamelMahjoub/Kuizo/Scripts/Game Settings.
Locate and open the script named TimeLimit.
Inside the TimeLimit enum, add, remove or comment out values to define the durations you want your game to support.
For example, to make your game support a time limit of 5 minutes , modify the enum like this:
public enum TimeLimit
{
FifteenSeconds,
ThirtySeconds,
FortyFiveSeconds,
OneMinute,
OneMinuteFifteenSeconds,
OneMinuteThirtySeconds,
OneMinuteFortyFiveSeconds,
TwoMinutes,
FiveMinutes,
NoTimeLimit
}
Save the script.
Next, locate and open the script named TimeLimitSetting.
Inside the TimeLimitSetting script, locate the method named UpdateOptionText().
Add, remove, or comment out any switch cases to match the values defined in your modified enum.
For example, if your TimeLimit enum now supports a time limit of 5 minutes, update the method like this:
private void UpdateOptionText()
{
optionText.text = selectedOption switch
{
TimeLimit.FifteenSeconds => "15 Seconds",
TimeLimit.ThirtySeconds => "30 Seconds",
TimeLimit.FortyFiveSeconds => "45 Seconds",
TimeLimit.OneMinute => "60 Seconds",
TimeLimit.OneMinuteFifteenSeconds => "75 Seconds",
TimeLimit.OneMinuteThirtySeconds => "90 Seconds",
TimeLimit.OneMinuteFortyFiveSeconds => "105 Seconds",
TimeLimit.TwoMinutes => "120 Seconds",
TimeLimit.FiveMinutes => "300 Seconds",
TimeLimit.NoTimeLimit => "No Time Limit",
_ => "Unknown Time Limit"
};
}
Save the script.
Locate and open the script named GameSettings.
Inside the GameSettings script, locate the method named GetTimeLimit().
Add, remove, or comment out any switch cases to match the values defined in your modified enum.
For example, if your TimeLimit enum now supports a time limit of 5 minutes, update the method like this:
public int GetTimeLimit()
{
switch (selectedTimeLimit)
{
case TimeLimit.FifteenSeconds:
return 15;
case TimeLimit.ThirtySeconds:
return 30;
case TimeLimit.FortyFiveSeconds:
return 45;
case TimeLimit.OneMinute:
return 60;
case TimeLimit.OneMinuteFifteenSeconds:
return 75;
case TimeLimit.OneMinuteThirtySeconds:
return 90;
case TimeLimit.OneMinuteFortyFiveSeconds:
return 105;
case TimeLimit.TwoMinutes:
return 120;
case TimeLimit.FiveMinutes:
return 300;
case TimeLimit.NoTimeLimit:
default:
throw new ArgumentOutOfRangeException();
}
}
Save the script.
Return to Unity and let it recompile the changes.