private async void GameWin() { Sounds.PlaySoundOnce("win_gto.wav"); Sounds.StopBackGround(); Sounds.StopBossBackGround(); BonusGeneratorTimer.Stop(); ObstsGeneratorTimer.Stop(); KeyTrackTimer.Stop(); CollisionTimer.Stop(); stars.StarTimer.Stop(); foreach (Obstacle item in CurrentObsts) { item.ObstacleFiredAnimation(); RemoveElementAfterAnimation(item.ObstToCanvas); } CurrentObsts.Clear(); boss.StopFire = true; boss.CurrentBossAmmos.Clear(); stars.AllStars.Clear(); ship.CurrentAmmos.Clear(); AnimationsRace.AnimationBossNoMore(boss); await Task.Run(() => Thread.Sleep(TimeSpan.FromSeconds(10))); for (int i = MainCanvas.Children.Count - 1; i >= 0; i--) { MainCanvas.Children.Remove(MainCanvas.Children[i]); } ShowWinGifs(); }
//private void DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) //{ // while (pause) // { // Thread.Sleep(1000); // if (_pause.CancellationPending || !pause) // { // e.Cancel = true; // return; // } // Dispatcher.BeginInvoke((Action)(() => { // Thread.Sleep(1000); // })); // } //} private void GameOver() { Sounds.StopBackGround(); Sounds.ShipDestroySoundPlay(); Sounds.StopBossBackGround(); AnimationsRace.AnimationShipGameOver(ship); RemoveElementAfterAnimation(ship.shipRectangle); BonusGeneratorTimer.Stop(); ObstsGeneratorTimer.Stop(); KeyTrackTimer.Stop(); CollisionTimer.Stop(); foreach (Obstacle item in CurrentObsts) { item.ObstacleFiredAnimation(); RemoveElementAfterAnimation(item.ObstToCanvas); } CurrentObsts.Clear(); Sounds.GameOverSoundPlay(); AnimationsRace.AnimationGameOver(); }