Example #1
0
        public override void Draw(GraphicsDevice graphicsDevice)
        {
            var lineLocation3D = Position.XNAMatrix.Translation;

            lineLocation3D.X += (Position.TileX - Viewer.Camera.TileX) * 2048;
            lineLocation3D.Y += OffsetY;
            lineLocation3D.Z += (Viewer.Camera.TileZ - Position.TileZ) * 2048;

            var lineLocation2DStart = Viewer.GraphicsDevice.Viewport.Project(lineLocation3D, Viewer.Camera.XnaProjection, Viewer.Camera.XnaView, Matrix.Identity);

            if (lineLocation2DStart.Z > 1 || lineLocation2DStart.Z < 0)
            {
                return; // Out of range or behind the camera
            }
            lineLocation3D.Y += 10;
            var lineLocation2DEndY = Viewer.GraphicsDevice.Viewport.Project(lineLocation3D, Viewer.Camera.XnaProjection, Viewer.Camera.XnaView, Matrix.Identity).Y;

            var labelLocation2D = Material.GetTextLocation((int)lineLocation2DStart.X, (int)lineLocation2DEndY - Material.Font.Height, Text);

            lineLocation2DEndY = labelLocation2D.Y + Material.Font.Height;

            Material.Font.Draw(Material.SpriteBatch, labelLocation2D, Text, Color, Outline);
            Material.SpriteBatch.Draw(Material.Texture, new Vector2(lineLocation2DStart.X - 1, lineLocation2DEndY), null, Outline, 0, Vector2.Zero, new Vector2(4, lineLocation2DStart.Y - lineLocation2DEndY), SpriteEffects.None, lineLocation2DStart.Z);
            Material.SpriteBatch.Draw(Material.Texture, new Vector2(lineLocation2DStart.X, lineLocation2DEndY), null, Color, 0, Vector2.Zero, new Vector2(2, lineLocation2DStart.Y - lineLocation2DEndY), SpriteEffects.None, lineLocation2DStart.Z);
        }
Example #2
0
        public override void Draw()
        {
            Camera camera         = material.CurrentCamera;
            var    lineLocation3D = positionSource.WorldPosition.XNAMatrix.Translation;

            lineLocation3D.X += (positionSource.WorldPosition.TileX - camera.TileX) * 2048;
            lineLocation3D.Y += offsetY;
            lineLocation3D.Z += (camera.TileZ - positionSource.WorldPosition.TileZ) * 2048;

            var lineLocation2DStart = graphicsDevice.Viewport.Project(lineLocation3D, camera.XnaProjection, camera.XnaView, Matrix.Identity);

            if (lineLocation2DStart.Z > 1 || lineLocation2DStart.Z < 0)
            {
                return; // Out of range or behind the camera
            }
            lineLocation3D.Y += 10;
            var lineLocation2DEndY = graphicsDevice.Viewport.Project(lineLocation3D, camera.XnaProjection, camera.XnaView, Matrix.Identity).Y;

            var labelLocation2D = material.GetTextLocation((int)lineLocation2DStart.X, (int)lineLocation2DEndY - material.Font.Height, text);

            lineLocation2DEndY = labelLocation2D.Y + material.Font.Height;

            material.Font.Draw(material.SpriteBatch, labelLocation2D, text, color, outline);
            material.SpriteBatch.Draw(material.Texture, new Vector2(lineLocation2DStart.X - 1, lineLocation2DEndY), null, outline, 0, Vector2.Zero, new Vector2(4, lineLocation2DStart.Y - lineLocation2DEndY), SpriteEffects.None, lineLocation2DStart.Z);
            material.SpriteBatch.Draw(material.Texture, new Vector2(lineLocation2DStart.X, lineLocation2DEndY), null, color, 0, Vector2.Zero, new Vector2(2, lineLocation2DStart.Y - lineLocation2DEndY), SpriteEffects.None, lineLocation2DStart.Z);
        }