/// <summary> /// record the state of the gameObject /// </summary> void PushState() { EnemySpawnerTimeState ests = new EnemySpawnerTimeState(); ests.timerSecondsLeft = spawnTimer.SecondsLeft; ests.spawnCounter = spawnCounter; states.Add(ests); }
/// <summary> /// Rewind the state by 1 stored frame /// </summary> void PopState() { int lastIndex = states.Count - 1; if (lastIndex > -1) { EnemySpawnerTimeState lastState = states[lastIndex]; states.RemoveAt(lastIndex); spawnTimer.Duration = lastState.timerSecondsLeft; spawnCounter = lastState.spawnCounter; } }