コード例 #1
0
        public void AnchorDrawing(DebugObject obj)
        {
            SpriteBatch.Draw(
                texture: TextureLoader.TheOnePixel,
                destinationRectangle: new Rectangle((int)obj.Position.X,
                                                    (int)obj.Position.Y,
                                                    (int)TextureLoader.Font.MeasureString(obj.ToString()).X,
                                                    (int)TextureLoader.Font.MeasureString(obj.ToString()).Y),
                color: Color.Black * 0.4f);

            SpriteBatch.DrawString(TextureLoader.Font, obj.ToString(), obj.Position, Color.White);
            SpriteBatch.DrawString(TextureLoader.Font, "Anchored", obj.item.Position, Color.Crimson);

            SpriteBatch.Draw(
                texture: TextureLoader.TheOnePixel,
                destinationRectangle: new Rectangle((int)obj.item.Position.X,
                                                    (int)obj.item.Position.Y,
                                                    obj.item.TextureWidth,
                                                    obj.item.TextureHeight),
                color: Color.Black * 0.4f);

            SpriteBatch.Draw(
                texture: TextureLoader.TheOnePixel,
                destinationRectangle: new Rectangle((int)obj.item.BoundingBoxX,
                                                    (int)obj.item.BoundingBoxY,
                                                    obj.item.BoundingBox.Width,
                                                    obj.item.BoundingBox.Height),
                color: Color.Black * 0.4f);
        }
コード例 #2
0
        public void AnchorDrawing(DebugObject obj)
        {
            SpriteBatch.Draw(
                texture: TextureLoader.TheOnePixel,
                destinationRectangle: new Rectangle((int)obj.Position.X,
                                        (int)obj.Position.Y,
                                        (int)TextureLoader.Font.MeasureString(obj.ToString()).X,
                                        (int)TextureLoader.Font.MeasureString(obj.ToString()).Y),
                color: Color.Black * 0.4f);

            SpriteBatch.DrawString(TextureLoader.Font, obj.ToString(), obj.Position, Color.White);
            SpriteBatch.DrawString(TextureLoader.Font, "Anchored", obj.item.Position, Color.Crimson);

            SpriteBatch.Draw(
                texture: TextureLoader.TheOnePixel,
                destinationRectangle: new Rectangle((int)obj.item.Position.X,
                                        (int)obj.item.Position.Y,
                                        obj.item.TextureWidth,
                                        obj.item.TextureHeight),
                color: Color.Black * 0.4f);

            SpriteBatch.Draw(
                texture: TextureLoader.TheOnePixel,
                destinationRectangle: new Rectangle((int)obj.item.BoundingBoxX,
                                        (int)obj.item.BoundingBoxY,
                                        obj.item.BoundingBox.Width,
                                        obj.item.BoundingBox.Height),
                color: Color.Black * 0.4f);
        }
コード例 #3
0
        public void DisplayObjectProps(IGameObject obj)
        {
            var toDraw = new DebugObject(obj);

            toDraw.Position = new Vector2(0, 0);
            SpriteBatch.Draw(
                texture: TextureLoader.TheOnePixel,
                destinationRectangle: new Rectangle((int)toDraw.Position.X,
                                                    (int)toDraw.Position.Y,
                                                    (int)TextureLoader.Font.MeasureString(toDraw.ToString()).X,
                                                    (int)TextureLoader.Font.MeasureString(toDraw.ToString()).Y),
                color: Color.Black * 0.4f);

            SpriteBatch.DrawString(TextureLoader.Font, toDraw.ToString(), toDraw.Position, Color.White);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        private void Anchor(DebugObject item)
        {
            bool contains = this.AnchoredObjects.Any(p => p.Id == item.Id);

            if (!contains)
            {
                item.Position = new Vector2(this.indent, 0);
                this.AnchoredObjects.AddLast(new LinkedListNode <DebugObject>(item));
                this.indent += (int)TextureLoader.Font.MeasureString(item.LongestLine).X;
            }
            else
            {
                var toRemove = this.AnchoredObjects.First(e => e.Id == item.Id);
                this.indent -= (int)TextureLoader.Font.MeasureString(item.LongestLine).X;
                for (var i = AnchoredObjects.Last.Value; i != AnchoredObjects.Find(toRemove).Value; i = AnchoredObjects.Find(i).Previous.Value)
                {
                    i.Position = AnchoredObjects.Find(i).Previous.Value.Position;
                }
                this.AnchoredObjects.Remove(toRemove);
            }
        }
コード例 #5
0
        //TODO: Figure a way to get mouse position relative to the current position because
        //if in window Mouse.GetState() returns point relative to the border of the window
        public void StatsOnHover()
        {
            previousMouseState = currentMouseState;
            currentMouseState  = Mouse.GetState();
            foreach (var item in Engine.Objects)
            {
                if (item.BoundingBox.Contains(this.MousePosition.ToVector2()))
                {
                    HoverDrawing(item);
                    if (currentMouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released)
                    {
                        var debugObj = new DebugObject(item);
                        Anchor(debugObj);
                    }
                }
            }

            foreach (var item in AnchoredObjects)
            {
                AnchorDrawing(item);
            }
        }
コード例 #6
0
 public void HoverDrawing(IGameObject obj)
 {
     SpriteBatch.DrawString(TextureLoader.Font, DebugObject.toString(obj), obj.Position, Color.White);
 }
コード例 #7
0
        public void DisplayObjectProps(IGameObject obj)
        {
            var toDraw = new DebugObject(obj);
            toDraw.Position = new Vector2(0,0);
            SpriteBatch.Draw(
                texture: TextureLoader.TheOnePixel,
                destinationRectangle: new Rectangle((int)toDraw.Position.X,
                                        (int)toDraw.Position.Y,
                                        (int)TextureLoader.Font.MeasureString(toDraw.ToString()).X,
                                        (int)TextureLoader.Font.MeasureString(toDraw.ToString()).Y),
                color: Color.Black * 0.4f);

            SpriteBatch.DrawString(TextureLoader.Font, toDraw.ToString(), toDraw.Position, Color.White);
        }
コード例 #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        private void Anchor(DebugObject item)
        {
            bool contains = this.AnchoredObjects.Any(p => p.Id == item.Id);
            if (!contains)
            {
                item.Position = new Vector2(this.indent, 0);
                this.AnchoredObjects.AddLast(new LinkedListNode<DebugObject>(item));
                this.indent += (int)TextureLoader.Font.MeasureString(item.LongestLine).X;

            }
            else
            {
                var toRemove = this.AnchoredObjects.First(e => e.Id == item.Id);
                this.indent -= (int)TextureLoader.Font.MeasureString(item.LongestLine).X;
                for (var i = AnchoredObjects.Last.Value; i != AnchoredObjects.Find(toRemove).Value; i = AnchoredObjects.Find(i).Previous.Value)
                {
                    i.Position = AnchoredObjects.Find(i).Previous.Value.Position;
                }
                this.AnchoredObjects.Remove(toRemove);
            }
        }
コード例 #9
0
        //TODO: Figure a way to get mouse position relative to the current position because
        //if in window Mouse.GetState() returns point relative to the border of the window
        public void StatsOnHover()
        {
            previousMouseState = currentMouseState;
            currentMouseState = Mouse.GetState();
            foreach (var item in Engine.Objects)
            {
                if (item.BoundingBox.Contains(this.MousePosition.ToVector2()))
                {
                    HoverDrawing(item);
                    if (currentMouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released)
                    {
                        var debugObj = new DebugObject(item);
                        Anchor(debugObj);
                    }
                }
            }

            foreach (var item in AnchoredObjects)
            {
                AnchorDrawing(item);
            }
        }