public void BeginExplosion(sfxManager sfx) { if (state != ShipState.Exploding) { state = ShipState.Exploding; explosion.Initialize(explosionTexture, position, 8, 65f, 1.0f, false); sfx.Effect("enemyexplosion").Play(); } }
private void ProcessInput(GameTime gameTime, KeyboardState keyState) { Vector2 direction = new Vector2(0, 0); currentKeyState = keyState; if (keyState.IsKeyDown(Keys.Space)) { player.equippedWeapon.Fire(gameTime, projectiles, soundEffects.Effect("laser1"), null); } if (keyState.IsKeyDown(Keys.Left)) { direction.X = -1; } else if (keyState.IsKeyDown(Keys.Right)) { direction.X = 1; } if (keyState.IsKeyDown(Keys.Up)) { direction.Y = -1; } else if (keyState.IsKeyDown(Keys.Down)) { direction.Y = 1; } player.ChangeDirection(direction); if (currentKeyState.IsKeyDown(Keys.Z) && previousKeyState.IsKeyUp(Keys.Z)) { // toggle equipped weapons switch (player.equippedWeapon.weapon) { case WeaponType.SingleLaser: player.equippedWeapon.changeWeapon(WeaponType.DualLaser); break; case WeaponType.DualLaser: player.equippedWeapon.changeWeapon(WeaponType.SpreadShot); break; case WeaponType.SpreadShot: player.equippedWeapon.changeWeapon(WeaponType.SingleLaser); break; default: break; } } previousKeyState = keyState; }