Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Targeter"/> class.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <exception cref="ArgumentNullException"><paramref name="world"/> is <c>null</c>.</exception>
        protected Targeter(World world)
        {
            if (world == null)
                throw new ArgumentNullException("world");

            _world = world;

            _mouseOverBeforeDrawHandler = MouseOver_BeforeDraw;
            _mouseOverBeforeDrawHandler = MouseOver_BeforeDraw;
            _mouseOverAfterDrawHandler = MouseOver_AfterDraw;
            _targetBeforeDrawHandler = Target_BeforeDraw;
            _targetAfterDrawHandler = Target_AfterDraw;

            _world.MapChanged += World_MapChanged;
        }
Example #2
0
 /// <summary>
 /// Handles the map change event for targeting.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="ValueChangedEventArgs{Map}"/> instance containing the event data.</param>
 void World_MapChanged(World sender, ValueChangedEventArgs<Map> e)
 {
     MouseOverTarget = null;
     _target = null;
 }
Example #3
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            _gameControls = new GameplayScreenControls(this);
            _dragDropHandler = new DragDropHandler(this);

            _socket = ClientSockets.Instance;

            _world = new World(this, new Camera2D(GameData.ScreenSize), new UserInfo(Socket));
            _world.MapChanged += World_MapChanged;

            // Create some misc goodies that require a reference to the Socket
            _equipmentInfoRequester = new EquipmentInfoRequester(UserInfo.Equipped, Socket);
            _inventoryInfoRequester = new InventoryInfoRequester(UserInfo.Inventory, Socket);

            // Other inits
            InitializeGUI();
            _characterTargeter = new CharacterTargeter(World);

            // NOTE: Test lighting
            _userLight = new Light { Size = new Vector2(512), IsEnabled = false };
            DrawingManager.LightManager.Add(_userLight);
        }
Example #4
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);
            }
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterTargeter"/> class.
 /// </summary>
 /// <param name="world">The world.</param>
 /// <exception cref="ArgumentNullException"><paramref name="world" /> is <c>null</c>.</exception>
 public CharacterTargeter(World world) : base(world)
 {
 }