Ejemplo n.º 1
0
        private void InitGame()
        {
            show_ee_tip = false;
            for (int i = MainCanvas.Children.Count - 1; i >= 0; i--)
            {
                if ((MainCanvas.Children[i] is StackPanel) ||
                    (MainCanvas.Children[i] is Rectangle && (MainCanvas.Children[i] as Rectangle).Name == "hat"))
                {
                    MainCanvas.Children.Remove(MainCanvas.Children[i]);
                }
                if (MainCanvas.Children[i] is Rectangle && (MainCanvas.Children[i] as Rectangle).Name == "Boss" ||
                    (MainCanvas.Children[i] is Rectangle && (MainCanvas.Children[i] as Rectangle).Name == "ee_tip"))
                {
                    MainCanvas.Children.Remove(MainCanvas.Children[i]);
                }
            }
            if (ship != null)
            {
                Sounds.PlayBackGround();
            }
            Sounds.GameOverSoundStop();
            this.DataContext = null;
            ship             = null;
            boss             = null;
            bossfight        = false;
            ship             = new StarShip(this);
            game_time_sec    = 0;
            MainCanvas.Children.Remove(progressBarHealthBoss);
            //ship.HatSprite.Visual = (Visual)Application.Current.Resources[selected_hat_name];
            this.DataContext = ship;
            StoryBoardTimer.Start();
            BonusGeneratorTimer.Start();
            ObstsGeneratorTimer.Start();
            KeyTrackTimer.Start();
            CollisionTimer.Start();



            EasterEggTimer.Start();
            for (int i = 0; i < arrow_arr.Length; i++)
            {
                arrow_arr[i] = 0;
            }
        }
Ejemplo n.º 2
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ConsoleMethod.WriteToConsole("Game window loaded", Brushes.White);
            Sounds.PlayBackGround();
            clouds = new Clouds(this);

            //Image image = new Image();
            //AnimationBehavior.SetSourceUri(image, new Uri(@"J:\training\WPF\SeryojaTheGame\SeryojaTheGame\Race\bin\Debug\win_gifs\1.gif"));
            //MainCanvas.Children.Add(image);


            StarShip starShip_title = new StarShip(null);

            starShip_title.shipRectangle.Margin = new Thickness(MainCanvas.ActualWidth / 2 - starShip_title.shipRectangle.Width / 2,
                                                                MainCanvas.ActualHeight - 200,
                                                                0, 0);
            starShip_title.shipRectangle.Name = "ee_tip";
            MainCanvas.Children.Add(starShip_title.shipRectangle);
            while (show_ee_tip)
            {
                AnimationsRace.AnimationMainScreen(starShip_title, this);
                await System.Threading.Tasks.Task.Run(() => System.Threading.Thread.Sleep(23 * 500 + 3000));
            }
        }