コード例 #1
0
        /// <summary>
        /// Starts the test
        /// </summary>
        public void TestStart()
        {
            if (IsTestInProgress)
            {
                return;
            }

            if (CurrentTest == null || TestStartupArgs == null || ClientsInTest == null || ClientsInTest.Count == 0)
            {
                throw new Exception("Not ready to start test");
            }

            // Send package indicating the start of the test
            var TestStartPackage = DataPackage.StartTestPackage(TestStartupArgs);

            foreach (var client in ClientsInTest)
            {
                // Send start command with args
                IoCServer.Network.Send(client, TestStartPackage);

                // Reset the client for new test
                client.ResetForNewTest(CurrentTest.Questions.Count);
            }

            IsTestInProgress = true;

            TimeLeft = CurrentTest.Info.Duration;

            // Start cutdown
            mTestTimer.Start();
            OnTimerUpdated.Invoke();
        }
コード例 #2
0
ファイル: Timer.cs プロジェクト: MomiaBLN/ARTechnicalTest
        protected IEnumerator CountTime()
        {
            do
            {
                yield return(null);

                currentTime += Time.deltaTime;
                OnTimerUpdated?.Invoke(currentTime);
            } while (Active);
        }
コード例 #3
0
        /// <summary>
        /// Fired every time timer's cycle elapses
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HandleTimer(object sender, ElapsedEventArgs e)
        {
            TimeLeft = TimeLeft.Subtract(new TimeSpan(0, 0, 1));

            OnTimerUpdated.Invoke();

            if (TimeLeft.Equals(TimeSpan.Zero))
            {
                TimesUp();
            }
        }
コード例 #4
0
 /// <summary>
 /// Stops the timer
 /// </summary>
 private void StopTimer()
 {
     mTestTimer.Start();
     OnTimerUpdated.Invoke();
 }
コード例 #5
0
ファイル: Timer.cs プロジェクト: CoenSteuns/Ludum-dare-46
 private void SetTimeLeft(float timeLeft)
 {
     this.timeLeft = Math.Max(0, timeLeft);
     OnTimerUpdated?.Invoke(this);
 }