void StartSimFun() { //initialize schedule references periodIndex = 0; curPer = curSched.periods[periodIndex]; atHome = curPer.atHome; atSchool = curPer.atSchool; startTime = Time.time; simStarted = true; SendEventOnPeriodChange(); }
void Update() { if (simStarted) { if (Time.time > startTime + curPer.period * p.dayLength) { //update curSched, curPer, atHome and atSchool values based on new period periodIndex = (periodIndex + 1) % curSched.periods.Length; curPer = curSched.periods[periodIndex]; atHome = curPer.atHome; atSchool = curPer.atSchool; startTime = Time.time; //send event to change period SendEventOnPeriodChange(); } } }