public async Task CountdownTimer_StartTwice_AbortsOldTimer() { // Arrange CountdownTimer timer = CreateTimer(); var timeout = TimeSpan.FromMilliseconds(10); int called1 = 0; int called2 = 0; Action callback1 = () => { called1++; }; Action callback2 = () => { called2++; }; // Act timer.Start(timeout, callback1); timer.Start(timeout, callback2); await Task.Delay(250); // Assert called2.Should().Be(1); called1.Should().Be(0); }
public void EnterState() { game.InitializeOverlayWidget(); game.questionsManager.StartNewQuestion(); game.isTimesUp = false; game.ResetScore(); // Reset game timer gameTime.Reset(); gameTime.Start(); game.Context.GetOverlayWidget().SetClockDuration(gameTime.Duration); game.Context.GetOverlayWidget().SetClockTime(gameTime.Time); hurryUpSfx = false; game.questionsManager.Enabled = true; nextQuestionTimer = 0f; requestNextQueston = false; game.questionsManager.onAnswered += OnAnswered; }
public void AddTimer(float time, System.Action <object> callback, object param) { CountdownTimer timer = new CountdownTimer(); timer.Start(time, TimesUp, null, null); timers[timer] = new CallbackStruct(callback, param);; }
public void Update(float delta) { if (MinigamesUI.Timer.Duration == MinigamesUI.Timer.Elapsed) { MinigamesUI.Timer.Pause(); game.OnTimesUp(); } //game.gameTime.Update(delta); anturaTimer.Update(delta); //game.timerText.text = ((int)game.gameTime.Time).ToString(); if (game.currentLetter.dragging) { anturaTimer.Reset(); anturaTimer.Start(); } //check if we placed the CurrentLetter: if (!game.currentLetter.dragging && game.currentLetter.collidedTubes.Count > 0) { game.SetCurrentState(game.ResetState); } }
public Droplet(Vector2 pos) { Position = pos; _shaderPosition = new Vector2(0.5f, 0.5f); Timer = new CountdownTimer(); Timer.Start(1.5f); }
private static void InitializeDeviceRegistrationService() { var timer = new CountdownTimer(100); timer.Action = param => { DeviceRegistrationServiceInitializer.Initialize(); }; timer.Start(); }
public ScreenGrabber(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, float frameDelay = 0.1f, int numImages = 20) { Enabled = true; SpriteBatch = spriteBatch; GraphicsDevice = graphicsDevice; // Look up the resolution and format of our main backbuffer. PresentationParameters pp = GraphicsDevice.PresentationParameters; int width = pp.BackBufferWidth; int height = pp.BackBufferHeight; SurfaceFormat format = pp.BackBufferFormat; // Create a texture for rendering the main scene, prior to applying bloom. sceneRenderTarget = new RenderTarget2D(GraphicsDevice, width, height, false, format, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.PreserveContents); CurrentImageList = new ImageList(GraphicsDevice, numImages); FrameDelay = frameDelay; frameTimer = new CountdownTimer(); frameTimer.Start(FrameDelay); }
private static void InitializeUpdateService() { var timer = new CountdownTimer(500); timer.Action = param => { UpdateServiceInitializer.Initialize(); }; timer.Start(); }
public bool StartWait(Action <bool, ErrorInfo> callback, TimeSpan timeout, bool restart = false) { if (_channel.State == _awaitedState && !restart) { try { callback?.Invoke(true, null); } catch (Exception e) { Logger.Error("Error invoking callback for - " + _name, e); } return(false); } lock (_lock) { if (_waiting) { Logger.Warning( $"Awaiter for {_awaitedState} has been called multiple times. Adding action to callbacks"); _callbacks.Add(callback); return(false); } _timer.Start(timeout, ElapsedSync); _waiting = true; _callbacks.Add(callback); return(true); } }
private static void InitializeAutoSignIn() { var timer = new CountdownTimer(3000); timer.Action = param => { SignInInitializer.Initialize(); }; timer.Start(); }
private static void InitializeDownloadManager() { var timer = new CountdownTimer(2000); timer.Action = param => { DownloadManagerInitializer.Initialize(); }; timer.Start(); }
public ZombieState_Locked(Zombie z) { zombie = z; lockedTimer = new CountdownTimer(); lockedTimer.Start (1.0f); }
private void SetDelay() { CountdownTimer.Stop(); CountdownPanel.Visible = CurrentTease.CurrentPage.AvailableDelay != null && CurrentTease.CurrentPage.AvailableDelay.Style != DelayStyle.Hidden; if (CurrentTease.CurrentPage.AvailableDelay != null) { secondsUntilNextPage = CurrentTease.GetInteger(CurrentTease.CurrentPage.AvailableDelay.Seconds); if (secondsUntilNextPage > 0) { // If there are seconds to countdown, start the timer. secondsShownUntilNextPage = secondsUntilNextPage; if (!String.IsNullOrEmpty(CurrentTease.CurrentPage.AvailableDelay.StartWithSeconds)) { secondsShownUntilNextPage = CurrentTease.GetInteger(CurrentTease.CurrentPage.AvailableDelay.StartWithSeconds); } UpdateCountDownPanel(); CountdownTimer.Start(); } else { // Otherwise execute the delay actions straight away. ExecuteTeaseAction(CurrentTease.CurrentPage.AvailableDelay); } } }
public void CountdownTimer_Tick(object sender, EventArgs e) { if (totalSeconds > 0) { totalSeconds--; int hours = totalSeconds / 3600; int minutes = (totalSeconds / 60) % 60; int seconds = (totalSeconds % 60); TimeSpan T = new TimeSpan(hours, minutes, seconds); Countdown_Time.Text = T.ToString(); } else { for (int i = 1; i < 2; i++) { Console.Beep(); } CountdownTimer.Stop(); DialogResult result = (MessageBox.Show(" Put on snooze + 5 min ", " Time * up ", MessageBoxButtons.YesNo, MessageBoxIcon.Question)); switch (result) { case DialogResult.Yes: totalSeconds = 5 * 60; CountdownTimer.Start(); MessageBox.Show(" Added 5 mins "); break; case DialogResult.No: break; } } }
// Update is called once per frame void Update() { // if (Input.GetButtonDown ("Button4")) { // var d = distractions [Random.Range (0, distractions.Length)]; // print ("Playing distractor: " + d.distractionName); // d.TriggerDistraction (null); // return; // } // } if (timer.isComplete) { if (timerState == TimerState.Waiting) { if (distractions.Length > 0) { currentDistraction = distractions [UnityEngine.Random.Range(0, distractions.Length)]; recordDistractors.WriteRow(Time.time + "," + currentDistraction.distractionName); currentDistraction.TriggerDistraction(salienceController.salience, endDistraction); } } timerState = timerState.Next(); timer.duration = timerState.Duration(); timer.Start(); } }
/// <summary> /// This is where it all happens. Grabs a scene that has already been rendered, /// and uses postprocess magic to add a glowing bloom effect over the top of it. /// </summary> /// <param name="gameTime"></param> public void Draw(GameTime gameTime) { if (Enabled) { frameTimer.Update(gameTime); //Grab a frame if the timer has expired if (!frameTimer.Paused && !frameTimer.HasTimeRemaining) { CurrentImageList.AddFrame(sceneRenderTarget, (int)(FrameDelay * 1000)); frameTimer.Start(FrameDelay); } //Draw the entire rendered frame to the screen. GraphicsDevice.SetRenderTargets(prevRenderTargets); int width = GraphicsDevice.PresentationParameters.BackBufferWidth; int height = GraphicsDevice.PresentationParameters.BackBufferHeight; SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, null); SpriteBatch.Draw(sceneRenderTarget, new Rectangle(0, 0, width, height), Color.White); SpriteBatch.End(); } }
public async Task CountdownTimer_Abort_StopsCountdown() { // Arrange var timer = new CountdownTimer("Test timer", Logger); var timeout = TimeSpan.FromMilliseconds(50); int called = 0; Action callback = () => called++; timer.Start(timeout, callback); // Act timer.Abort(); for (var i = 0; i < 20; i++) { if (called == 0) { await Task.Delay(50); } else { break; } } // Assert called.Should().Be(0); }
public override async Task LoadContent() { await base.LoadContent(); //Don't do anything if the player had a negative experience or if they've already rated the game if (!GameWon || HasRated) { ExitScreen(); } else { //update the rate ask number RateAskNumber = RateAskNumber + 1; //Has the user done enough stuff to ask them to rate? if (RateAskNumber < MinAsks) { ExitScreen(); } else { //Reset the amout of stuff the user has done RateAskNumber = 0; //Start asking for a rating in a second timer.Start(1f); } } }
private static void InitializeUpdateService() { UpdateService.Instance.UpdateIsAvailable += updateService_UpdateIsAvailable; var timer = new CountdownTimer(2); timer.Action = CheckForCurrentAppUpdate; timer.Start(); }
private static void InitializeDownloadManager() { AppDownloadManager.Instance.DownloadCompleted += appDownloadManager_DownloadCompleted; var countDownTimer = new CountdownTimer(obj => { var task = AppDownloadManager.Instance.InitializeAsync(); }, null, 3); countDownTimer.Start(); }
public void BeginTimer() { if (m_CountdownTimer != null) { m_CountdownTimer.Stop(); } m_CountdownTimer = new CountdownTimer(this); m_CountdownTimer.Start(); }
public XmasSnowflakeBranch(Boss boss, Sprite sprite) : base(sprite) { Speed = 1500f; _boss = boss; _canRushTimer = new CountdownTimer(1f + (_boss.Game.GameManager.Random.NextDouble() * 3f)); _rushTimer = new CountdownTimer(5f); _rushTimer.Stop(); _rushing = false; _canRush = false; _angularSpeed = 2f + ((float)_boss.Game.GameManager.Random.NextDouble() * 3f); if (_boss.Game.GameManager.Random.NextDouble() > 0.5f) { _angularSpeed *= -1; } _destroyed = false; _canRushTimer.Completed += (sender, args) => { _canRush = true; _rushTimer.Start(); }; _rushTimer.Completed += (sender, args) => { if (!_destroyed && !TargetingPosition) { RushToPlayer(); } }; Sprite.Origin = new Vector2(0.5f * Sprite.TextureRegion.Width, 0.5f * Sprite.TextureRegion.Height); // Physics var bbWidth = sprite.TextureRegion.Width / 4f; var bbLocalPosition = new Vector2((sprite.TextureRegion.Width / 2f) - (bbWidth / 2f), 0f); var startX = -sprite.TextureRegion.Width / 2f; var startY = -sprite.TextureRegion.Height / 2f; var vertices = new List <Vector2>() { new Vector2(startX, startY), new Vector2(startX + bbWidth, startY), new Vector2(startX + bbWidth, startY + sprite.TextureRegion.Height), new Vector2(startX, startY + sprite.TextureRegion.Height) }; _boundingBox = new CollisionConvexPolygon(this, bbLocalPosition, vertices); _boss.AddHitBox(_boundingBox); _branchPlayerLine = new Line(Position(), _boss.GetPlayerPosition()); }
public void EnterState() { game.QuestionManager.OnCompleted += OnQuestionCompleted; game.QuestionManager.OnDropped += OnAnswerDropped; /* * List<ILivingLetterData> wrongAnswers = new List<ILivingLetterData>(); * * for (int i = 0; * i < FastCrowdConfiguration.Instance.MaxNumbOfWrongLettersNoise && * i < game.QuestionNumber && * i < game.NoiseData.Count; i++) * { * wrongAnswers.Add(game.NoiseData[i]); * } */ if (game.CurrentChallenge != null) { game.QuestionManager.StartQuestion(game.CurrentChallenge, game.NoiseData); if (FastCrowdConfiguration.Instance.Variation == FastCrowdVariation.Alphabet) { if (gameTime != null) { gameTime.onTimesUp -= OnTimesUp; } gameTime = new CountdownTimer(game.CurrentChallenge.Count * 4f); gameTime.onTimesUp += OnTimesUp; } } else { game.QuestionManager.Clean(); } // Reset game timer gameTime.Start(); if (initializeOveralyWidget) { initializeOveralyWidget = false; game.InitializeOverlayWidget(); } game.Context.GetOverlayWidget().SetClockDuration(gameTime.Duration); game.Context.GetOverlayWidget().SetClockTime(gameTime.Time); StopAntura(); game.QuestionManager.wordComposer.gameObject.SetActive(FastCrowdConfiguration.Instance.NeedsWordComposer); }
private void SetDelay() { CountdownTimer.Stop(); CountdownPanel.Visible = currentTease.CurrentPage.AvailableDelay != null && currentTease.CurrentPage.AvailableDelay.Style != DelayStyle.Hidden; if (currentTease.CurrentPage.AvailableDelay != null) { secondsUntilNextPage = currentTease.GetInteger(currentTease.CurrentPage.AvailableDelay.Seconds); UpdateCountDownPanel(); CountdownTimer.Start(); } }
internal void internalSetCountdownClock(int timerType, int timer1, int timer2, int armedState) { if (timer1 > 0 && armedState != 0) { entryExitTimer.CountdownSeconds = timer1; entryExitTimer.Start(); myPanel.SendDebug(string.Format("Area {0} - internalSetCountdownClock = {1}", areaNumber, timer1)); } checkRegistered(); }
public void Starting_a_timer_and_letting_it_run_for_5_seconds_gives_back_24_55_as_remaining_time() { var pomodoroTimer = new CountdownTimer(new TimeSpan(0, 25, 0)); pomodoroTimer.Start(); Thread.Sleep(4500); var remainingTime = pomodoroTimer.RemainingTime; Assert.Equal("24:55", remainingTime.ToString("mm\\:ss")); }
private async void OnSpeechSynthesisEnded(object sender, EventArgs e) => await RunOnUi(() => { if (_startCountdownTimer) { if (_lightningMode) { _countdownTimer.Start(TimeSpan.FromSeconds(10)); } _startCountdownTimer = false; } });
public override void Play() { var timer = new CountdownTimer(); timer.Start(Duration.FromHours(30)); while (timer.Complete == false) { ProcessKeyboardInput(); Console.DrawToMainDisplay(TimeSpan.FromMilliseconds(8), Normandy, Normandy.ThanixCannon); } }
void Start() { spawnTimer = new CountdownTimer(); spawnTimer.Start (spawnTime); decrementTimer = new CountdownTimer(); decrementTimer.Start (decrementTime); decrementTimeIncreaseTimer = new CountdownTimer(); decrementTimeIncreaseTimer.Start (decrementTimeIncreaseTime); random = new System.Random(); }
private void HandleVisibilityStyles(bool visible) { if (visible) { ExecuteAfterRender(() => { countdownTimer?.Start(); return(Task.CompletedTask); }); } DirtyClasses(); DirtyStyles(); }
public async Task CountdownTimer_Start_StartsCountdown() { // Arrange var timer = new CountdownTimer("Test timer", Logger); var timeout = TimeSpan.FromMilliseconds(10); int called = 0; Action callback = () => called++; // Act timer.Start(timeout, callback); await Task.Delay(50); // Assert called.Should().Be(1); }
public override async Task LoadContent() { await base.LoadContent(); var label = new Label("Main screen", Content) { Horizontal = HorizontalAlignment.Center, Vertical = VerticalAlignment.Center, Position = Resolution.ScreenArea.Center }; AddItem(label); timer.Start(1f); }
public void AddTimer(float time, System.Action<object> callback, object param) { CountdownTimer timer = new CountdownTimer(); timer.Start(time, TimesUp, null, null); timers[timer] = new CallbackStruct(callback, param);; }
public PlayerState_Locked(Player p) { player = p; lockedForCountdown = new CountdownTimer (); lockedForCountdown.Start (0.5f); }
private void Start() { CountdownTimer = new CountdownTimer(SelectedTimerDuration); CountdownTimer.Start(); }