Пример #1
0
        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());
            }
        }
Пример #2
0
 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;
 }
Пример #3
0
 public void LateDispose()
 {
     _changeSceneSignal -= OnSceneChange;
     _areaClickedSignal -= OnAreaClicked;
     _resetSignal       -= OnReset;
 }
Пример #4
0
 public void Initialize()
 {
     _changeSceneSignal += OnSceneChange;
     _areaClickedSignal += OnAreaClicked;
     _resetSignal       += OnReset;
 }
Пример #5
0
 public void Init(RestartSignal restartSignal, ResetSignal resetSignal)
 {
     _restartSignal = restartSignal;
     _resetSignal   = resetSignal;
 }
Пример #6
0
 public void SignalTrigered(ResetSignal reset)
 {
     Reset();
 }