Exemplo n.º 1
0
        private void OnTick()
        {
            lock (this)
            {
                MillisecondsLeft -= 1;
                OnCountdownChanged?.Invoke(MillisecondsLeft);
                if (MillisecondsLeft > 0)
                {
                    return;
                }

                var sensor = NextSensor;
                TimingTriggered?.Invoke(sensor, DateTime.Now);

                if (NextSensor + 1 >= SensorCount)
                {
                    Reset();
                    return;
                }

                NextSensor++;
                OnNextSensorChanged?.Invoke(NextSensor);
                MillisecondsLeft = GetNextWaitTime();
            }
        }
Exemplo n.º 2
0
 public void Reset()
 {
     _timer.Stop();
     MillisecondsLeft = 0;
     NextSensor       = 0;
     OnRunningChanged?.Invoke(false);
     OnCountdownChanged?.Invoke(MillisecondsLeft);
     OnNextSensorChanged?.Invoke(NextSensor);
 }
Exemplo n.º 3
0
 public void SkipNextSensor()
 {
     if (NextSensor + 1 >= SensorCount)
     {
         return;
     }
     NextSensor++;
     MillisecondsLeft += GetNextWaitTime();
     OnCountdownChanged?.Invoke(MillisecondsLeft);
     OnNextSensorChanged?.Invoke(NextSensor);
 }
Exemplo n.º 4
0
 public PlayerServiceWebClient(SignalRConnection signalR)
 {
     SignalR = signalR;
     SignalR.HubConnection.On <IImmutableList <PlayerState> >("PlayerlistChanged", newValue =>
     {
         OnPlayerlistChanged?.Invoke(this, newValue);
     });
     SignalR.HubConnection.On <PlayerInfo?>("MyInfoChanged", newValue =>
     {
         OnMyInfoChanged?.Invoke(this, newValue);
     });
     SignalR.HubConnection.On <int>("TokenStockChanged", newValue =>
     {
         OnTokenStockChanged?.Invoke(this, newValue);
     });
     HubConnection.On <ChangeSet>("BoardChanged", changes =>
     {
         OnBoardChanged?.Invoke(this, changes);
     });
     HubConnection.On <int>("CountdownChanged", countDown =>
     {
         OnCountdownChanged?.Invoke(this, countDown);
     });
 }