public static void Initilize() { _mainInstance = new SoundEffectManager(); //instances have features like pausing and resuming (but don't stack) //effects just play (but stack on top of each other) //load instances _mainInstance._sInstance = new Dictionary <String, SoundEffectInstance>(); _mainInstance._sInstance["shift"] = SharedContentManager.Load <SoundEffect>("SoundEffects/stonescraping").CreateInstance(); _mainInstance._sInstance["shift"].IsLooped = true; _mainInstance._sInstance["shift"].Volume = 0.5f; _mainInstance._sInstance["heartbeat"] = SharedContentManager.Load <SoundEffect>("SoundEffects/heartbeat").CreateInstance(); _mainInstance._sInstance["heartbeat"].IsLooped = true; //load effects _mainInstance._sEffect = new Dictionary <String, SoundEffect>(); _mainInstance._sEffect["pistol"] = SharedContentManager.Load <SoundEffect>("SoundEffects/pistol"); _mainInstance._sEffect["grenade"] = SharedContentManager.Load <SoundEffect>("SoundEffects/grenade"); _mainInstance._sEffect["item-collect"] = SharedContentManager.Load <SoundEffect>("SoundEffects/item-collect"); _mainInstance._sEffect["impact"] = SharedContentManager.Load <SoundEffect>("SoundEffects/impact"); _mainInstance._sEffect["cinematicboom"] = SharedContentManager.Load <SoundEffect>("SoundEffects/cinematicboom"); _mainInstance._sEffect["reload"] = SharedContentManager.Load <SoundEffect>("SoundEffects/reload"); _mainInstance._sEffect["squish"] = SharedContentManager.Load <SoundEffect>("SoundEffects/squish"); }
public void Update(float deltaTime) { foreach (MapTile tile in _tiles) { tile.Update(deltaTime); } if (_shiftedOutTile != null) { _shiftedOutTile.Update(deltaTime); } //process queue if (_shiftQueue.Count > 0) { if (!_isShifting) { MapShift temp = _shiftQueue.First.Value; _shiftQueue.RemoveFirst(); if (SoundEffectManager.GetSoundState("shift") == SoundState.Stopped) { SoundEffectManager.PlaySound("shift"); } shiftTiles(temp.Index, temp.Direction, temp.TileDoors); } } else if (!_isShifting) { if (SoundEffectManager.GetSoundState("shift") == SoundState.Playing) { SoundEffectManager.StopSound("shift"); } } NervePulseTimeCount += deltaTime * 1000; }
internal void GoToFullHealth() { _currentHealth = _maxHealth; if (SoundEffectManager.GetSoundState("heartbeat") == SoundState.Playing) { SoundEffectManager.StopSound("heartbeat"); } }
public void Reload() { if (_reloadTimer.isFinished && _spareClipsLeft > 0) { SoundEffectManager.PlayEffect(_weaponType.ReloadSound, 1.0f); _spareClipsLeft--; _roundsLeftInClip = _weaponType.RoundsPerClip; _reloadTimer.Reset(); } }
public static void Update(float deltaTime) { _fadeInTimer.Update(deltaTime); if (!_playedSound) { SoundEffectManager.PlayEffect("cinematicboom", 1.0f); _playedSound = true; } }
public override void ApplyDamage(float amount) { SoundEffectManager.PlayEffect("impact", 0.1f); PainStaticMaker.AddDamage(amount); //heatbeat if ((_currentHealth / _maxHealth) < 0.3 && SoundEffectManager.GetSoundState("heartbeat") != SoundState.Playing) { SoundEffectManager.PlaySound("heartbeat"); } base.ApplyDamage(amount); }
internal static void ObjectiveWasCollected() { SoundEffectManager.PlayEffect("item-collect", 1.0f); _mainInstance._numObjectsCollected++; Program.Objects.MainPlayer.GoToFullHealth(); if (_mainInstance._numObjectsCollected >= _mainInstance._numToCollect) { _mainInstance._bossActive = true; } else { spawnNewObjective(); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.StartNewGame will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); _hudManager.Initialize(); //set up the black pixel used for clearing the screen _blackPx = new Texture2D(_graphics.GraphicsDevice, 1, 1); uint[] px = { 0xFFFFFFFF }; _blackPx.SetData <uint>(px); InputManager.Initialize(); SoundEffectManager.Initilize(); //initial menu music _backgroundMusic = new MusicController(); _backgroundMusic.Enqueue("Predatory Instincts_ElevatorRemix"); _backgroundMusic.Play(); PainStaticMaker.Initialize(); _mouseDrawer.Initialize(); CharacterType.Initialize(); ParticleType.Initialize(); LoseScreen.Initialize(); GameState.Initilize(); StartNewGame(); _shiftInterface.Initialize(_spriteBatch); base.Initialize(); }
public void Shoot(Vector2 location, Vector2 direction) { if (_roundsLeftInClip == 0 && _reloadTimer.isFinished && _shootTimer.isFinished) { Reload(); } else if (_roundsLeftInClip > 0 && _reloadTimer.isFinished && _shootTimer.isFinished) { //play weapon fire sound if (_weaponType.FireSound != null) { SoundEffectManager.PlayEffect(_weaponType.FireSound, SOUND_VOLUME); } direction += Utilities.randomNormalizedVector() * _weaponType.Inaccuracy; direction.Normalize(); //start shooting the particles at the left side of the spread Vector2 currentSpreadSweepDirection = Vector2.Transform(direction, _halfSpreadRotationMatrix); //initial rotation if an even number of projectiles if (_weaponType.FiresPerRound % 2 == 0) { Vector2.Transform(ref currentSpreadSweepDirection, ref _spreadRotationStepMatrix, out currentSpreadSweepDirection); } //Special case of one particle if (_weaponType.FiresPerRound == 1) { currentSpreadSweepDirection = direction; } for (int i = 0; i < _weaponType.FiresPerRound; i++) { //shoot the projectiles if (_weaponType.IsRaycasted) //use raycasting /* * return -1: ignore this fixture and continue * return 0: terminate the ray cast * return fraction: clip the ray to this point * return 1: don't clip the ray and continue */ { Vector2 pt = Vector2.Zero; float minFrac = float.MaxValue; //Gets the position of the closest fixture on the ray path. Program.Objects.PhysicsWorld.RayCast((fixture, point, normal, fraction) => { //check for a valid fixture if (fixture == null) { return(-1); } //check if its an enemy or a wall (and if it's closer than the previous result) if ((fixture.Body.UserData as Enemy != null || fixture.Body.UserData as MapTile != null) && fraction < minFrac) { pt = point; minFrac = fraction; return(1); } return(-1); }, location, location + currentSpreadSweepDirection * _weaponType.Range); //create a particle at the place where the ray was stopped if (pt != Vector2.Zero) { Program.Objects.Projectiles.Add(new Projectile(pt, Vector2.Zero, _weaponType.ProjectileType)); } } else //use projectiles { Program.Objects.Projectiles.Add(new Projectile(location + direction * (_weaponOwner.PhysicalEntitySize / 1.8f + _weaponType.ProjectileType.Radius), currentSpreadSweepDirection, _weaponType.ProjectileType)); } //rotate the direction to shoot the next particle in Vector2.Transform(ref currentSpreadSweepDirection, ref _spreadRotationStepMatrix, out currentSpreadSweepDirection); } _roundsLeftInClip--; _shootTimer.Reset(); } }
private void updateGameState() { //Allows the game to exit if (InputManager.IsKeyDown(Keys.Escape)) { ClearGame(); GameState.Mode = GameState.GameMode.EXITED; this.Exit(); return; } //menu screen progression if (GameState.Mode == GameState.GameMode.PREGAME && InputManager.IsMouseClicked()) { //game music _backgroundMusic.Stop(); _backgroundMusic.ClearQueue(); _backgroundMusic.Enqueue("01 Cryogenic Dreams"); _backgroundMusic.Enqueue("05 Rapid Cognition"); _backgroundMusic.Enqueue("10 Disappear"); _backgroundMusic.Play(); GameState.Mode = GameState.GameMode.NORMAL; } if ((GameState.Mode == GameState.GameMode.GAMEOVERWIN || (GameState.Mode == GameState.GameMode.GAMEOVERLOSE && LoseScreen.TimerFinished())) && InputManager.IsMouseClicked()) { ResetGame(); _backgroundMusic.Stop(); _backgroundMusic.ClearQueue(); _backgroundMusic.Enqueue("Predatory Instincts_ElevatorRemix"); _backgroundMusic.Play(); GameState.Mode = GameState.GameMode.PREGAME; } //pause/unpause if (InputManager.IsKeyClicked(Keys.P) && GameState.Mode == GameState.GameMode.PAUSED) { GameState.Mode = GameState.GameMode.NORMAL; SoundEffectManager.ResumeSound("shift"); } else if (InputManager.IsKeyClicked(Keys.P) && GameState.Mode == GameState.GameMode.NORMAL) { GameState.Mode = GameState.GameMode.PAUSED; SoundEffectManager.PauseSound("shift"); } //shifting interface if (InputManager.IsKeyClicked(Keys.Space) && GameState.Mode == GameState.GameMode.SHIFTING) { GameState.Mode = GameState.GameMode.NORMAL; SoundEffectManager.ResumeSound("shift"); } else if (InputManager.IsKeyClicked(Keys.Space) && GameState.Mode == GameState.GameMode.NORMAL) { GameState.Mode = GameState.GameMode.SHIFTING; SoundEffectManager.PauseSound("shift"); } //you died if (Objects.MainPlayer == null || Objects.MainPlayer.ShouldBeKilled) { GameState.Mode = GameState.GameMode.GAMEOVERLOSE; SoundEffectManager.StopInstances(); } if (GameState.AllObjectivesCollected) { GameState.Mode = GameState.GameMode.GAMEOVERWIN; SoundEffectManager.StopInstances(); } }