Пример #1
0
 public override void updateWhenCurrentLocation(GameTime time, GameLocation environment)
 {
     if (environment != null && environment.IsMiniJukeboxPlaying())
     {
         showNextIndex.Value = true;
         if (showNote)
         {
             showNote = false;
             for (int i = 0; i < 4; i++)
             {
                 environment.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(516, 1916, 7, 10), 9999f, 1, 1, tileLocation.Value * 64f + new Vector2(Game1.random.Next(48), -80f), flicker: false, flipped: false, (tileLocation.Value.Y + 1f) * 64f / 10000f, 0.01f, Color.White, 4f, 0f, 0f, 0f)
                 {
                     xPeriodic                 = true,
                     xPeriodicLoopTime         = 1200f,
                     xPeriodicRange            = 8f,
                     motion                    = new Vector2((float)Game1.random.Next(-10, 10) / 100f, -1f),
                     delayBeforeAnimationStart = 1200 + 300 * i
                 });
             }
         }
     }
     else
     {
         showNextIndex.Value = false;
     }
     base.updateWhenCurrentLocation(time, environment);
 }
Пример #2
0
        private void UpdateTicked(object sender, UpdateTickedEventArgs e)
        {
            if (Game1.currentLocation?.Name != FARMHOUSE_NAME && Game1.currentLocation?.Name != CELLAR_NAME)
            {
                return;
            }
            if (!Game1.locations.Any(location => location.Name == CELLAR_NAME))
            {
                return;
            }

            GameLocation room          = Game1.currentLocation;
            string       otherRoomName = (room.Name == FARMHOUSE_NAME) ? CELLAR_NAME : FARMHOUSE_NAME;
            GameLocation otherRoom     = Game1.locations.First(l => l.Name == otherRoomName);

            if (!string.IsNullOrEmpty(currentlyPlaying) &&
                (Game1.player.isInBed ||
                 Game1.timeOfDay >= 2600 ||
                 Game1.player.stamina <= -15f))
            {
                // The player is in bed or exhausted
                StopJukeboxMusic();
                // There will be no music
                return;
            }
            if (!string.IsNullOrEmpty(currentlyPlaying) && room.Name == trackSource && !room.IsMiniJukeboxPlaying())
            {
                // The player has turned the jukebox off
                StopJukeboxMusic();
                // There may be other music to play
            }

            if (room.IsMiniJukeboxPlaying())
            {
                if (room.miniJukeboxTrack != currentlyPlaying)
                {
                    // The jukebox is on but the track has changed
                    StartJukeboxMusic(room);
                }
            }
            else if (otherRoom.IsMiniJukeboxPlaying())
            {
                if (otherRoom.miniJukeboxTrack != currentlyPlaying)
                {
                    // Overhear the music from the other room
                    StartJukeboxMusic(otherRoom);
                }
            }
        }