public void Draw(SpriteBatch spriteBatch, Renderer renderer)
        {
            string msg = string.Format("{0} (x{1})", _model, _model.Speed);
            if (_model.Frozen) msg = string.Format("{0} (paused)", _model);

            spriteBatch.DrawString(_dateFont, msg, _pos, Color.WhiteSmoke);
        }
        private void CreateMapTexture(Renderer renderer)
        {
            var offset = new Vector2(20, 20);

            _renderTarget = new RenderTarget2D(
                renderer.Device,
                renderer.Device.PresentationParameters.BackBufferWidth,
                renderer.Device.PresentationParameters.BackBufferHeight,
                false,
                renderer.Device.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24);
            // Set the render target
            renderer.Device.SetRenderTarget(_renderTarget);

            var oldZoom = renderer.RenderState.Camera.Zoom;
            renderer.RenderState.Camera.Move(offset);
            renderer.RenderState.Camera.SetZoom(1.15f);

            renderer.Device.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };

            // Draw the scene
            renderer.Device.Clear(Color.CornflowerBlue);
            renderer.DrawToScreen(_mapView.RenderInstructons.SelectMany(x => x));

            // Restore
            renderer.Device.SetRenderTarget(null);
            renderer.RenderState.Camera.SetZoom(oldZoom);
            renderer.RenderState.Camera.Move(-offset);
            _initialized = true;
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        public void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(_gdm.GraphicsDevice);
            RenderState renderState = new RenderState(_spriteBatch.GetScreenDimensions());
            _renderer = new Renderer(_gdm.GraphicsDevice, renderState);

            _mouseCursorTexture = _content.Load<Texture2D>("cursor");
            _logFont            = _content.Load<SpriteFont>("LogFont");

            LoadFile("../../gamedata.haumea");

            foreach (IView view in _views)
            {
                view.LoadContent(_content);
            }
        }
        public void Draw(SpriteBatch spriteBatch, Renderer renderer)
        {
            Vector2 portOffset = renderer.RenderState.Camera.Offset;

            Vector2 screen = spriteBatch.GetScreenDimensions();
            const int size = 200;
            float xyratio = screen.X / screen.Y;
            Vector2 dim = new Vector2(size * xyratio, size);

            if (!_initialized && _wait-- == 0) CreateMapTexture(renderer);

            if (_initialized)
            {
                const int offset = 120;
                Rectangle target = new Rectangle((screen - dim).ToPoint(), dim.ToPoint());
                Rectangle source = new Rectangle((int)(offset * xyratio), offset,
                    (int)(screen.X - offset * xyratio), (int)screen.Y - offset);
                spriteBatch.Draw(_renderTarget, target, source, Color.White);
            }

            Debug.WriteToScreen("wait", _wait);
        }
        private void DrawUnits(SpriteBatch spriteBatch, Renderer renderer)
        {
            // Since we are generating these every time anyway,
            // we clear it so we don't have any label boxes belonging to deleted armies.
            _labelClickableBoundaries.Clear();

            // All realm id's the player is at war with.
            var playerEnemies = _wars.GetAllEnemies(Realms.PlayerID);

            foreach (var pair in _units.Armies)
            {
                AABB box = _labelBoxes[pair.Value.Location];
                AABB screenBox = new AABB(renderer.RenderState.WorldToScreenCoordinates(box.BottomRight),
                    renderer.RenderState.WorldToScreenCoordinates(box.TopLeft));

                string text = pair.Value.NUnits.ToString();

                Vector2 dim    = _unitsFont.MeasureString(text);
                Vector2 center = screenBox.Center - dim / 2;

                Vector2 p1     = (center - 5 * Vector2.UnitX);
                AABB snugBox   = new AABB(p1, p1 + (dim + 10 * Vector2.UnitX));

                Color borderColor;

                if (_unitsSelection.Set.Contains(pair.Key))
                {
                    borderColor = Color.AliceBlue;
                }
                else if (playerEnemies.Contains(pair.Value.Owner))
                {
                    borderColor = Color.Red;
                }
                else
                {
                    borderColor = Color.Black;   
                }
                    
                spriteBatch.Draw(snugBox.Borders(1), borderColor);
                spriteBatch.Draw(snugBox, Color.Black);
                spriteBatch.DrawString(_unitsFont, text, center.Floor(), Color.White);

                _labelClickableBoundaries[pair.Key] = snugBox;
            }     
        }
        public void Draw(SpriteBatch spriteBatch, Renderer renderer)
        {
            // Renders provinces
            renderer.DrawToScreen(_standardInstrs.SelectMany(x => x));

//            if (renderer.RenderState.Camera.Zoom < 1.4f)
//            {
                DrawUnits(spriteBatch, renderer);
//            }

            // Selection box
            AABB selectionRect = new AABB(_selectionBoxP1, _selectionBoxP2);
            AABB[] borders = selectionRect.Borders(1);
            spriteBatch.Draw(selectionRect, new Color(Color.Black, 0.4f));
            spriteBatch.Draw(borders, Color.CadetBlue);       
        }