Example #1
0
 /// <summary>
 /// Constructor of the explosion effect thread.
 /// </summary>
 /// <param name="coordinates">Coordinates of the explosion</param>
 /// <param name="width">Width of the explosion effect box.</param>
 /// <param name="height">Heigth of the explosion effect box.</param>
 /// <param name="canvas">Game canvas object.</param>
 /// <param name="explosionImages">Explosion image sequence</param>
 /// <param name="repeats">Repeats to run the sequence (default=10)</param>
 public ExplosionEffectsThread(Point coordinates, int width, int height, GameCanvas canvas, Image[] explosionImages, [Optional, DefaultParameterValue(10)] int repeats)
 {
     _coordinates  = coordinates;
     _width        = width;
     _height       = height;
     _canvas       = canvas;
     _repeats      = repeats;
     _explosionImg = explosionImages;
 }
Example #2
0
        /// <summary>
        /// GameLoop constructor
        /// </summary>
        /// <param name="canvas">Canvas -object</param>
        public GameLoop(GameCanvas canvas)
        {
            for (int i = 0; i < _explosionImg.Length; i++)
            {
                _explosionImgBitmap[i]  = new BitmapImage(new Uri($"Resources\\explosion_{i + 1}.png", UriKind.Relative));
                _explosionImg[i]        = new Image();
                _explosionImg[i].Source = _explosionImgBitmap[i];
                _explosionImg[i].Width  = _explosionImgBitmap[i].Width;
                _explosionImg[i].Height = _explosionImgBitmap[i].Height;
            }

            score       = 0;
            _gameCanvas = canvas;
            _graphics   = new Graphics(this);
            SetEnemies();

            Player = new Hero();

            _graphics.DrawEnemies();
            _graphics.DrawHero();

            _enemiesDestroyed = 0;
            _difficultyLevel  = 0;
        }
Example #3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.GameCanvas1 = ((SpaceInvaders.GameCanvas)(target));

            #line 10 "..\..\GameCanvas.xaml"
                this.GameCanvas1.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.GameCanvas_PreviewKeyDown);

            #line default
            #line hidden

            #line 10 "..\..\GameCanvas.xaml"
                this.GameCanvas1.PreviewKeyUp += new System.Windows.Input.KeyEventHandler(this.GameCanvas_PreviewKeyUp);

            #line default
            #line hidden
                return;

            case 2:

            #line 12 "..\..\GameCanvas.xaml"
                ((System.Windows.Controls.Grid)(target)).Loaded += new System.Windows.RoutedEventHandler(this.GameCanvas_Loaded);

            #line default
            #line hidden
                return;

            case 3:
                this.ImgStarField = ((System.Windows.Controls.Image)(target));
                return;

            case 4:
                this.EnemyCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 5:
                this.HeroAmmoCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 6:
                this.EnemyAmmoCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 7:
                this.AmmoEffectsCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 8:
                this.HeroDamageEffectsCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 9:
                this.InformationCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 10:
                this.tbPlayerLives = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 11:
                this.tbPlayerUpText = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 12:
                this.tbScore = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 13:
                this.tbMessage = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 14:
                this.PlayerCanvas = ((System.Windows.Controls.Canvas)(target));
                return;
            }
            this._contentLoaded = true;
        }
Example #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="gl">GameLoop -object</param>
 public Graphics(GameLoop gl)
 {
     _gameLoop   = gl;
     _gameCanvas = gl.GetCanvas();
     LoadExplosionImages();
 }