public static void InitShared() { if (Game1.soundBank != null) { if (babblingBrook == null) { babblingBrook = Game1.soundBank.GetCue("babblingBrook"); babblingBrook.Play(); babblingBrook.Pause(); } if (cracklingFire == null) { cracklingFire = Game1.soundBank.GetCue("cracklingFire"); cracklingFire.Play(); cracklingFire.Pause(); } if (engine == null) { engine = Game1.soundBank.GetCue("heavyEngine"); engine.Play(); engine.Pause(); } if (cricket == null) { cricket = Game1.soundBank.GetCue("cricketsAmbient"); cricket.Play(); cricket.Pause(); } } shortestDistanceForCue = new float[4]; }
public static void update(GameTime time) { if (sounds.Count == 0) { return; } if (volumeOverrideForLocChange < 1f) { volumeOverrideForLocChange += (float)time.ElapsedGameTime.Milliseconds * 0.0003f; } updateTimer -= time.ElapsedGameTime.Milliseconds; if (updateTimer > 0) { return; } for (int j = 0; j < shortestDistanceForCue.Length; j++) { shortestDistanceForCue[j] = 9999999f; } Vector2 farmerPosition = Game1.player.getStandingPosition(); foreach (KeyValuePair <Vector2, int> pair in sounds) { float distance = Vector2.Distance(pair.Key, farmerPosition); if (shortestDistanceForCue[pair.Value] > distance) { shortestDistanceForCue[pair.Value] = distance; } } if (volumeOverrideForLocChange >= 0f) { for (int i = 0; i < shortestDistanceForCue.Length; i++) { if (shortestDistanceForCue[i] <= (float)farthestSoundDistance) { float volume = Math.Min(volumeOverrideForLocChange, Math.Min(1f, 1f - shortestDistanceForCue[i] / (float)farthestSoundDistance)); switch (i) { case 0: if (babblingBrook != null) { babblingBrook.SetVariable("Volume", volume * 100f * Math.Min(Game1.ambientPlayerVolume, Game1.options.ambientVolumeLevel)); babblingBrook.Resume(); } break; case 1: if (cracklingFire != null) { cracklingFire.SetVariable("Volume", volume * 100f * Math.Min(Game1.ambientPlayerVolume, Game1.options.ambientVolumeLevel)); cracklingFire.Resume(); } break; case 2: if (engine != null) { engine.SetVariable("Volume", volume * 100f * Math.Min(Game1.ambientPlayerVolume, Game1.options.ambientVolumeLevel)); engine.Resume(); } break; case 3: if (cricket != null) { cricket.SetVariable("Volume", volume * 100f * Math.Min(Game1.ambientPlayerVolume, Game1.options.ambientVolumeLevel)); cricket.Resume(); } break; } continue; } switch (i) { case 0: if (babblingBrook != null) { babblingBrook.Pause(); } break; case 1: if (cracklingFire != null) { cracklingFire.Pause(); } break; case 2: if (engine != null) { engine.Pause(); } break; case 3: if (cricket != null) { cricket.Pause(); } break; } } } updateTimer = 100; }
public override void UpdateWhenCurrentLocation(GameTime time) { ICue main_player_music = Game1.currentSong; if (!Game1.game1.IsMainInstance) { main_player_music = GameRunner.instance.gameInstances[0].instanceCurrentSong; } base.UpdateWhenCurrentLocation(time); if (stopWatch == null) { return; } if (!Game1.shouldTimePass()) { if (stopWatch != null && stopWatch.IsRunning) { stopWatch.Stop(); } if (main_player_music != null && main_player_music.Name.Equals("mermaidSong") && !main_player_music.IsPaused && main_player_music.IsPlaying) { main_player_music.Pause(); } } else { if (stopWatch != null && !stopWatch.IsRunning && main_player_music != null && main_player_music.Name.Equals("mermaidSong") && main_player_music.IsPaused) { stopWatch.Start(); } if (main_player_music != null && main_player_music.Name.Equals("mermaidSong") && main_player_music.IsPaused) { main_player_music.Resume(); } } if (Game1.shouldTimePass()) { float num = showTimer; showTimer += time.ElapsedGameTime.Milliseconds; if (((main_player_music != null && main_player_music.Name.Equals("mermaidSong") && main_player_music.IsPlaying) || (Game1.options.musicVolumeLevel <= 0f && Game1.options.ambientVolumeLevel <= 0f)) && !stopWatch.IsRunning) { stopWatch.Start(); } if (curtainMovement != 0f) { curtainOpenPercent = Math.Max(0f, Math.Min(1f, curtainOpenPercent + curtainMovement * (float)time.ElapsedGameTime.Milliseconds)); } if (num < 3000f && showTimer >= 3000f) { Game1.changeMusicTrack("mermaidSong"); } if (stopWatch != null && stopWatch.ElapsedMilliseconds > 0 && stopWatch.ElapsedMilliseconds < 1000) { curtainMovement = 0.0004f; } for (int j = sparkles.Count - 1; j >= 0; j--) { if (sparkles[j].update(time)) { sparkles.RemoveAt(j); } } for (int k = alwaysFrontTempSprites.Count - 1; k >= 0; k--) { if (alwaysFrontTempSprites[k].update(time)) { alwaysFrontTempSprites.RemoveAt(k); } } if (stopWatch.ElapsedMilliseconds >= 30000 && stopWatch.ElapsedMilliseconds < 50000 && (blackBGAlpha < 1f || bigMermaidAlpha < 1f)) { blackBGAlpha += 0.01f; bigMermaidAlpha += 0.01f; } if (stopWatch.ElapsedMilliseconds > 27692 && stopWatch.ElapsedMilliseconds < 55385) { if (oldStopWatchTime % 769f > (float)(stopWatch.ElapsedMilliseconds % 769)) { bubbles.Add(new Vector2(Game1.random.Next((int)((float)Game1.graphics.GraphicsDevice.Viewport.Width / Game1.options.zoomLevel) - 64), (float)Game1.graphics.GraphicsDevice.Viewport.Height / Game1.options.zoomLevel)); } for (int l = 0; l < bubbles.Count; l++) { bubbles[l] = new Vector2(bubbles[l].X, bubbles[l].Y - 0.1f * (float)time.ElapsedGameTime.Milliseconds); } } if (oldStopWatchTime < 36923f && stopWatch.ElapsedMilliseconds >= 36923) { alwaysFrontTempSprites.Add(new TemporaryAnimatedSprite { texture = mermaidSprites, xPeriodic = true, xPeriodicLoopTime = 2000f, xPeriodicRange = 32f, motion = new Vector2(0f, -4f), sourceRectStartingPos = new Vector2(67f, 189f), sourceRect = new Microsoft.Xna.Framework.Rectangle(67, 189, 24, 53), totalNumberOfLoops = 100, animationLength = 3, pingPong = true, interval = 192f, delayBeforeAnimationStart = 0, initialPosition = new Vector2((float)Game1.graphics.GraphicsDevice.Viewport.Width / 4f, Game1.graphics.GraphicsDevice.Viewport.Height - 1), position = new Vector2((float)Game1.graphics.GraphicsDevice.Viewport.Width / Game1.options.zoomLevel / 4f, (float)Game1.graphics.GraphicsDevice.Viewport.Height / Game1.options.zoomLevel - 1f), scale = 4f, layerDepth = 1f }); } if (oldStopWatchTime < 40000f && stopWatch.ElapsedMilliseconds >= 40000) { alwaysFrontTempSprites.Add(new TemporaryAnimatedSprite { texture = mermaidSprites, xPeriodic = true, xPeriodicLoopTime = 2000f, xPeriodicRange = 32f, motion = new Vector2(0f, -4f), sourceRectStartingPos = new Vector2(67f, 189f), sourceRect = new Microsoft.Xna.Framework.Rectangle(67, 189, 24, 53), totalNumberOfLoops = 100, animationLength = 3, pingPong = true, interval = 192f, delayBeforeAnimationStart = 0, initialPosition = new Vector2((float)Game1.graphics.GraphicsDevice.Viewport.Width * 3f / 4f, Game1.graphics.GraphicsDevice.Viewport.Height - 1), position = new Vector2((float)Game1.graphics.GraphicsDevice.Viewport.Width / Game1.options.zoomLevel * 3f / 4f, (float)Game1.graphics.GraphicsDevice.Viewport.Height / Game1.options.zoomLevel - 1f), scale = 4f, layerDepth = 1f }); } if (oldStopWatchTime < 43077f && stopWatch.ElapsedMilliseconds >= 43077) { alwaysFrontTempSprites.Add(new TemporaryAnimatedSprite { texture = mermaidSprites, xPeriodic = true, xPeriodicLoopTime = 2000f, xPeriodicRange = 32f, motion = new Vector2(0f, -4f), sourceRectStartingPos = new Vector2(67f, 189f), sourceRect = new Microsoft.Xna.Framework.Rectangle(67, 189, 24, 53), totalNumberOfLoops = 100, animationLength = 3, pingPong = true, interval = 192f, delayBeforeAnimationStart = 0, initialPosition = new Vector2((float)Game1.graphics.GraphicsDevice.Viewport.Width / 4f, Game1.graphics.GraphicsDevice.Viewport.Height - 1), position = new Vector2((float)Game1.graphics.GraphicsDevice.Viewport.Width / Game1.options.zoomLevel / 4f, (float)Game1.graphics.GraphicsDevice.Viewport.Height / Game1.options.zoomLevel - 1f), scale = 4f, layerDepth = 1f }); } if (oldStopWatchTime < 46154f && stopWatch.ElapsedMilliseconds >= 46154) { alwaysFrontTempSprites.Add(new TemporaryAnimatedSprite { texture = mermaidSprites, xPeriodic = true, xPeriodicLoopTime = 2000f, xPeriodicRange = 32f, motion = new Vector2(0f, -4f), sourceRectStartingPos = new Vector2(67f, 189f), sourceRect = new Microsoft.Xna.Framework.Rectangle(67, 189, 24, 53), totalNumberOfLoops = 100, animationLength = 3, pingPong = true, interval = 192f, delayBeforeAnimationStart = 0, initialPosition = new Vector2((float)Game1.graphics.GraphicsDevice.Viewport.Width * 3f / 4f, Game1.graphics.GraphicsDevice.Viewport.Height - 1), position = new Vector2((float)Game1.graphics.GraphicsDevice.Viewport.Width / Game1.options.zoomLevel * 3f / 4f, (float)Game1.graphics.GraphicsDevice.Viewport.Height / Game1.options.zoomLevel - 1f), scale = 4f, layerDepth = 1f }); } if (stopWatch.ElapsedMilliseconds >= 52308 && (blackBGAlpha > 0f || bigMermaidAlpha > 0f)) { blackBGAlpha -= 0.01f; bigMermaidAlpha -= 0.01f; } if (stopWatch.ElapsedMilliseconds >= 58462 && stopWatch.ElapsedMilliseconds < 60000 && finalLeftMermaidAlpha < 1f) { finalLeftMermaidAlpha += 0.01f; } if (stopWatch.ElapsedMilliseconds >= 60000 && stopWatch.ElapsedMilliseconds < 62000 && finalRightMermaidAlpha < 1f) { finalRightMermaidAlpha += 0.01f; } if (stopWatch.ElapsedMilliseconds >= 61538 && stopWatch.ElapsedMilliseconds < 63538 && finalBigMermaidAlpha < 1f) { finalBigMermaidAlpha += 0.01f; } if (stopWatch.ElapsedMilliseconds >= 64615 && (finalBigMermaidAlpha < 1f || finalRightMermaidAlpha < 1f || finalLeftMermaidAlpha < 1f)) { finalBigMermaidAlpha -= 0.01f; finalRightMermaidAlpha -= 0.01f; finalLeftMermaidAlpha -= 0.01f; } if (oldStopWatchTime < 64808f && stopWatch.ElapsedMilliseconds >= 64808) { for (int i = 0; i < 200; i++) { sparkles.Add(new TemporaryAnimatedSprite { texture = mermaidSprites, sourceRect = new Microsoft.Xna.Framework.Rectangle(0, 146, 16, 13), animationLength = 9, interval = 100f, delayBeforeAnimationStart = i * 10, position = Utility.getRandomPositionOnScreenNotOnMap(), scale = 4f }); } Utility.addSprinklesToLocation(this, 5, 5, 9, 5, 2000, 100, Color.White); } if (oldStopWatchTime < 67500f && stopWatch.ElapsedMilliseconds >= 67500) { curtainMovement = -0.0003f; } oldStopWatchTime = stopWatch.ElapsedMilliseconds; } if (fairyTimer > 0f) { fairyTimer -= time.ElapsedGameTime.Milliseconds; if (fairyTimer < 200f && pearlRecipient != null && (int)pearlRecipient.facingDirection == 0) { pearlRecipient.faceDirection(1); } if (fairyTimer < 100f && pearlRecipient != null) { pearlRecipient.faceDirection(2); } if (fairyTimer <= 0f && pearlRecipient != null) { foreach (TemporaryAnimatedSprite temporarySprite in temporarySprites) { temporarySprite.alphaFade = 0.01f; } pearlRecipient.addItemByMenuIfNecessaryElseHoldUp(new Object(797, 1)); pearlRecipient.mailReceived.Add("gotPearl"); } } }