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 StoryBoardTimerTimerTick(object sender, EventArgs e) { game_time_sec++; if (game_time_sec >= 60 && !gotospace) { AnimationsRace.AnimationGoToSpace(); AnimationsRace.AnimationRemoveClouds(clouds); if (stars == null) { stars = new Stars(this); } clouds.StarTimer.Stop(); gotospace = true; } if (game_time_sec >= 180 && !bossfight) { bossfight = true; Sounds.StopBackGround(); Sounds.PlayBossBackGround(); boss = new Boss(this); progressBarHealthBoss = new ProgressBar(); progressBarHealthBoss.Minimum = 0; progressBarHealthBoss.Width = MainCanvas.ActualWidth; progressBarHealthBoss.Height = 15; progressBarHealthBoss.Background = Brushes.Black; progressBarHealthBoss.Maximum = boss.BossHealthPoint; progressBarHealthBoss.Value = boss.BossHealthPoint; MainCanvas.Children.Add(progressBarHealthBoss); } }
//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(); }