Пример #1
0
        public void DrawMap(Backend.Map map, Graphics target)
        {
            target.FillRectangle(new SolidBrush(Color.DarkGray), new Rectangle(10, 50, 4 + (_opener.Zoom + 4) * _opener.map.Width, (_opener.Zoom + 4) * _opener.map.Height + 4));
            for (int y = 0; y < map.Height; y++)
            {
                for (int x = 0; x < map.Width; x++)
                {
                    map.GetTile(x, y).Draw(target, 12 + x * (_opener.Zoom), 52 + y * (_opener.Zoom), _opener.Zoom + 4);
                    foreach (Backend.Placeable placeable in map.GetTile(x, y).placeables)
                    {
                        placeable.Draw(target, 12 + x * (_opener.Zoom), 52 + y * (_opener.Zoom), _opener.Zoom + 4);
                    }
                    foreach (Backend.Actor actor in map.GetTile(x, y).actors)
                    {
                        actor.Draw(target, 12 + x * (_opener.Zoom), 52 + y * (_opener.Zoom), _opener.Zoom + 4);
                    }
                }
            }
            if (_activeTile.X > -1)
            {
                target.DrawRectangle(new Pen(Color.Red, 2), new Rectangle(12 + _activeTile.X * (_opener.Zoom), 52 + _activeTile.Y * (_opener.Zoom), _opener.Zoom + 4, _opener.Zoom + 4));
                if (_opener.attachedImage != null)
                {
                    target.DrawImage(_opener.attachedImage,
                                     new Rectangle(12 + _activeTile.X * (_opener.Zoom), 52 + _activeTile.Y * (_opener.Zoom), _opener.Zoom + 4, _opener.Zoom + 4),

                                     new Rectangle(0, 0, 32, 32), GraphicsUnit.Pixel);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="graphics"></param>
 /// <param name="spriteBatch"></param>
 /// <param name="region"></param>
 /// <param name="mapIcons"></param>
 /// <param name="map"></param>
 public Minimap(Backend.IHandleEvent parent, SpriteBatch spriteBatch, ContentManager content, Rectangle region, Backend.Map map)
     : base(parent, spriteBatch, content, region)
 {
     _map = map;
     _mapIcon = _content.Load<Texture2D>("Minimap");
     _camera.rotate = -45.0f;
     Zoom = 0.9f;
 }
Пример #3
0
 /// <summary>
 /// Create a new event loop hooked to a Windows.Forms object and (optionally) a map
 /// </summary>
 /// <param name="opener">The Form to which Redraw events are passed</param>
 /// <param name="currentMap">(optional) map to use</param>
 public EventLoop(Dispatcher opener = null, Backend.Map currentMap = null)
 {
     _opener = opener;
     _currentMap = currentMap;
     _timer = new System.Timers.Timer(10);
     _timer.Elapsed += _timer_Elapsed;
     _timer.Start();
 }
Пример #4
0
 /// <summary>
 /// Create a new event loop hooked to a Windows.Forms object and (optionally) a map
 /// </summary>
 /// <param name="opener">The Form to which Redraw events are passed</param>
 /// <param name="currentMap">(optional) map to use</param>
 public EventLoop(Dispatcher opener = null, Backend.Map currentMap = null)
 {
     _opener         = opener;
     _currentMap     = currentMap;
     _timer          = new System.Timers.Timer(10);
     _timer.Elapsed += _timer_Elapsed;
     _timer.Start();
 }
Пример #5
0
 /// <summary>
 /// Create a new draw hooked to a Windows.Forms object and (optionally) a map
 /// </summary>
 /// <param name="opener">The Form to which Redraw events are passed</param>
 /// <param name="currentMap">(optional) map to use</param>
 public Draw(Dispatcher opener = null, Backend.Map currentMap = null)
 {
     _opener = opener;
 }
Пример #6
0
        /// <summary>
        /// Create the visible version of the game map
        /// </summary>
        /// <param name="graphics">The core graphics device manager</param>
        /// <param name="spriteBatch">A sprite batch used for drawing</param>
        /// <param name="displayArea">The area on wich the map will be placed</param>
        /// <param name="floor">The textures used for the floor</param>
        /// <param name="wall1">A set of tiles for the walls</param>
        /// <param name="wall2">A set of tiles for doors</param>
        /// <param name="map">Internal storage of map data</param>
        public Mainmap(Backend.IHandleEvent parent, SpriteBatch spriteBatch, ContentManager content, Rectangle displayArea, Backend.Map map, bool enabled = true)
            : base(parent, spriteBatch, content, displayArea)
        {
            _font = _content.Load<SpriteFont>("font");
            _map = map;
            _background = _content.Load<Texture2D>("Minimap");
            _circle = _content.Load<Texture2D>("Light2");
            _highlightedTile = new Backend.Coords(-1, -1);
            _tooltip = new TileTooltip(this, _spriteBatch, _content, _displayRect);
            // Load textures to use in environment
            // 1. Walls and floor
            _walls = new WallTiles(_content, 128, 192, "");
            _floors = new WallTiles(_content, 128, 192, "");

            // 2. Environmental objects (floor, items, traps, teleporters, chest...)
            _environment = new List<TileSet>();
            _environment.Add(new TileSet(_content, 128, 192));
            _environment[0].Load("Content\\misc.xml");
            _environment.Add(new TileSet(_content, 64, 48));
            _environment[1].Load("Content\\Arrow.xml");
            _environment.Add(new TileSet(_content, 55, 55));
            _environment[2].Load("Content\\explosion.xml");

            // 3. Moving entities (player, NPCs, enemies)
            _actors = new List<ActorView>();
            _effects = new List<MapEffect>();

            resetActors();
            _floatnumbers = new List<FloatNumber>();
            _projectiles = new List<Projectile>();
            _enabled = enabled;
        }