I have a clock. So I want to take some time range and in random moment of this range do something.
For example I want to print message to console from 22:45 to 01:12 o’clock.
How can I do it? I have a coroutines for each of 4 clock’s numbers, here is for 00:0x:
IEnumerator Time000X() {
while (true) {
if(isNeedStopTime)
time000X[timeValue000X].SetActive(true);
else {
isTimeEnabled = !isTimeEnabled;
foreach(GameObject i in timeImages)
i.SetActive (isTimeEnabled);
time000X[timeValue000X].SetActive(true);
yield return new WaitForSeconds(speedOfTime);
time000X[timeValue000X++].SetActive(false);
if(timeValue000X == 10)
timeValue000X = 0;
}
yield return null;
}
}
I can do it using Random.Range:
1. 22:50
2. 00:01
3. 01:01
currentRandomTime = Random.Range(0, 4);
But how can I do it not only for 3 time values, but for each value in the range?