Example #1
0
        private void _processAsteroidCollision(Asteroid asteroid)
        {
            var soundEngine = SoundEffectEngine.GetInstance();

            soundEngine.StopAirThrust();
            soundEngine.StopAirThrust(); //Can have two air thrusts going
            soundEngine.StopRocket();

            _expired = true;
        }
Example #2
0
 private void _fireProjectile()
 {
     if ((DateTime.Now.Ticks - _fireInterval) > _lastFired)
     {
         var projectileFactory = ProjectileFactory.GetInstance();
         projectileFactory.AddStandardProjectile(_location, _direction, Color.Red);
         SoundEffectEngine.GetInstance().PlayLaserShot();
         _lastFired = DateTime.Now.Ticks;
     }
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            // TODO: use this.Content to load your game content here

            RectanglePrimative.LoadTexture(Content);
            ProjectileFactory.Initiate(Content);
            AsteroidFactory.Initiate(Content);

            SoundEffectEngine.Initiate(Content);
            MusicEngine.Initiate(Content);

            gameField = GameField.Initiate(Content);
        }
Example #4
0
        /// <summary>
        /// Move our sprite based on arrow keys being pressed:
        /// </summary>
        private void _handleKeyPress(KeyboardState keyState)
        {
            if (keyState.IsKeyDown(Keys.D))
            {
                //If _isRightThrust is false, we are initiating the thrust, so play sound
                if (!_isRightThrust)
                {
                    SoundEffectEngine.GetInstance().LoopAirThrust();
                }
                _isRightThrust = true;
                _appyRotation(true);
            }
            //If _isRightThrust is true, but A is up, we are stopping our thrust.
            if (_isRightThrust && keyState.IsKeyUp(Keys.D))
            {
                SoundEffectEngine.GetInstance().StopAirThrust();
                _isRightThrust = false;
            }


            if (keyState.IsKeyDown(Keys.A))
            {
                //If _isLeftThrust is false, we are initiating the thrust, so play sound
                if (!_isLeftThrust)
                {
                    SoundEffectEngine.GetInstance().LoopAirThrust();
                }

                _isLeftThrust = true;
                _appyRotation(false);
            }

            //If _isRightThrust is true, but A is up, we are stopping our thrust.
            if (_isLeftThrust && keyState.IsKeyUp(Keys.A))
            {
                SoundEffectEngine.GetInstance().StopAirThrust();
                _isLeftThrust = false;
            }


            if (keyState.IsKeyDown(Keys.W))
            {
                if (!_isThrusting)
                {
                    SoundEffectEngine.GetInstance().LoopRocket();
                }

                _isThrusting = true;
                _applyThrust();
            }

            if (_isThrusting && keyState.IsKeyUp(Keys.W))
            {
                SoundEffectEngine.GetInstance().StopRocket();
                _isThrusting = false;
            }

            if (keyState.IsKeyDown(Keys.Space))
            {
                _fireProjectile();
            }
        }