예제 #1
0
        private void HighScoresButton_Click(object sender, RoutedEventArgs e)
        {
            MainMenuViewModel lContext = this.DataContext as MainMenuViewModel;

            if (lContext != null)
            {
                lContext.mMain.ShowHighScores();
            }
        }
예제 #2
0
        private void StopButton_Click(object sender, RoutedEventArgs e)
        {
            MainMenuViewModel lContext = this.DataContext as MainMenuViewModel;

            if (lContext != null)
            {
                lContext.mMain.RaiseStopGameEvent();
            }
        }
예제 #3
0
        public MainWindow()
        {
            InitializeComponent();

            MainWindowViewModel lContext = new MainWindowViewModel();

            lContext.StartGame += RunGame;
            lContext.StopGame  += EndGame;

            this.DataContext = lContext;

            mMainMenuViewModel    = new MainMenuViewModel(lContext);
            mMainMenu.DataContext = mMainMenuViewModel;

            mRocketBitmapFrame      = (BitmapFrame)Resources.MergedDictionaries[0]["Rocket"];
            mAsteroidBitmapFrame    = (BitmapFrame)Resources.MergedDictionaries[0]["Asteroid"];
            mAsteroid2BitmapFrame   = (BitmapFrame)Resources.MergedDictionaries[0]["Asteroid2"];
            mAsteroid3BitmapFrame   = (BitmapFrame)Resources.MergedDictionaries[0]["Asteroid3"];
            mProjectileBitmapFrame  = (BitmapFrame)Resources.MergedDictionaries[0]["Projectile"];
            mExplosionBitmapFrame   = (BitmapFrame)Resources.MergedDictionaries[0]["Explosion"];
            mExplosion2BitmapFrame  = (BitmapFrame)Resources.MergedDictionaries[0]["Explosion2"];
            mMissileBitmapFrame     = (BitmapFrame)Resources.MergedDictionaries[0]["Missile"];
            mRedSquareBitmapFrame   = (BitmapFrame)Resources.MergedDictionaries[0]["RedSquare"];
            mBonusHealthBitmapFrame = (BitmapFrame)Resources.MergedDictionaries[0]["Health"];

            mGameRoom.ControlActionEvent += InvokeAction;

            mLevelManager.Interval  = 1000;
            mLevelManager.AutoReset = true;
            mLevelManager.Elapsed  += LevelManagerElapsed;

            GenerateAsteroidTypes();
            GenerateBonusTypes();

            mLevelManager.Start();
        }