public ObservableResetableTOI(int kind, TimeSpan duration, Subject <Unit> resetSignal, List <Action> ThingsToDo, IScheduler scheduler = null) { Duration = duration; ResetSignal = resetSignal ?? throw new ArgumentNullException(nameof(resetSignal)); ActionList = ThingsToDo; MyScheduler = scheduler ?? Scheduler.Default; IObservable <IObservable <long> > ResetSignalAfterSelect; switch (kind) { case 1: ResetSignalAfterSelect = ResetSignal .Select(_ => Observable.Timer(duration)); break; case 2: ResetSignalAfterSelect = ResetSignal .Select(_ => Observable.Interval(duration)); break; default: // ToDo: Add error handling throw new ArgumentOutOfRangeException($"Kind {kind} is unknown"); } ResetSignalAfterSelect .Switch() .ObserveOn(MyScheduler); foreach (var somethingToDo in ThingsToDo) { ResetSignal.Subscribe(_ => somethingToDo()); } }
public GameController(IGameManager gameManager, ChangeSceneSignal changeSceneSignal, GameStatusChangedSignal gameStatusChangedSignal, AreaClickedSignal areaClickedSignal, CurrentMarkChangedSignal currentMarkChangedSignal, ResetSignal resetSignal, RestartSignal restartSignal ) { _gameManager = gameManager; _changeSceneSignal = changeSceneSignal; _areaClickedSignal = areaClickedSignal; _gameStatusChangedSignal = gameStatusChangedSignal; _currentMarkChangedSignal = currentMarkChangedSignal; _resetSignal = resetSignal; _restartSignal = restartSignal; }
public void LateDispose() { _changeSceneSignal -= OnSceneChange; _areaClickedSignal -= OnAreaClicked; _resetSignal -= OnReset; }
public void Initialize() { _changeSceneSignal += OnSceneChange; _areaClickedSignal += OnAreaClicked; _resetSignal += OnReset; }
public void Init(RestartSignal restartSignal, ResetSignal resetSignal) { _restartSignal = restartSignal; _resetSignal = resetSignal; }
public void SignalTrigered(ResetSignal reset) { Reset(); }