Ejemplo n.º 1
0
        /// <summary>
        /// Handles the corresponding event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ValueChangedEventArgs{T}"/> instance containing the event data.</param>
        void World_MapChanged(World sender, ValueChangedEventArgs <Map> e)
        {
            ChatBubble.ClearAll();

            // Stop all sounds
            SoundManager.Stop();

            // Set the new music
            if (!e.NewValue.MusicID.HasValue)
            {
                ScreenMusic = null;
            }
            else if (!MusicManager.Play(e.NewValue.MusicID.Value))
            {
                var musicTrack = MusicManager.GetMusicInfo(e.NewValue.MusicID.Value);
                if (musicTrack == null)
                {
                    const string errmsg = "Failed to play map music with ID `{0}`. No music with that ID could be found.";
                    if (log.IsErrorEnabled)
                    {
                        log.ErrorFormat(errmsg, e.NewValue.MusicID);
                    }
                    Debug.Fail(string.Format(errmsg, e.NewValue.MusicID));
                }

                ScreenMusic = musicTrack;
            }

            // Remove the lights from the old map
            if (e.OldValue != null)
            {
                foreach (var light in e.OldValue.Lights)
                {
                    DrawingManager.LightManager.Remove(light);
                }
            }

            // Add the lights for the new map
            foreach (var light in e.NewValue.Lights)
            {
                DrawingManager.LightManager.Add(light);
            }

            // Remove the refraction effects from the old map
            if (e.OldValue != null)
            {
                foreach (var fx in e.OldValue.RefractionEffects)
                {
                    DrawingManager.RefractionManager.Remove(fx);
                }
            }

            // Add the refraction effects for the new map
            foreach (var fx in e.NewValue.RefractionEffects)
            {
                DrawingManager.RefractionManager.Add(fx);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles screen deactivation, which occurs every time the screen changes from being
        /// the current active screen. Good place to clean up any objects created in <see cref="GameScreen.Activate"/>().
        /// </summary>
        public override void Deactivate()
        {
            ChatBubble.ClearAll();

            SoundManager.Stop3D();
            ControlBorder.RemoveGlobalColorTransformation(GlobalControlBorderTransformer);

            if (_groupForm != null)
            {
                _groupForm.GroupInfo.Clear();
            }

            base.Deactivate();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles screen activation, which occurs every time the screen becomes the current
        /// active screen. Objects in here often will want to be destroyed on <see cref="GameScreen.Deactivate"/>().
        /// </summary>
        public override void Activate()
        {
            base.Activate();

            ChatBubble.ClearAll();

            // Make sure to clear some stuff (text boxes, etc) that persists for the screen. Stuff that persists for the map only,
            // such as effects, should not need to be cleared here since it should be cleared when the map is set or changes.
            SoundManager.Stop3D();

            if (_chatForm != null)
            {
                _chatForm.ClearOutput();
                _chatForm.ClearInput();
            }

            // Set screen-specific globals
            ChatBubble.GetTopLeftCornerHandler = GetTopLeftDrawCorner;
            ControlBorder.AddGlobalColorTransformation(GlobalControlBorderTransformer);
        }