Ejemplo n.º 1
0
        public virtual void DropItem(Item dropped)
        {
            AddItem(dropped);

            Rectangle2D bounds    = dropped.GetGraphicBounds();
            Rectangle2D ourBounds = this.Bounds;

            int x, y;

            if (bounds.Width >= ourBounds.Width)
            {
                x = (ourBounds.Width - bounds.Width) / 2;
            }
            else
            {
                x = Utility.Random(ourBounds.Width - bounds.Width);
            }

            if (bounds.Height >= ourBounds.Height)
            {
                y = (ourBounds.Height - bounds.Height) / 2;
            }
            else
            {
                y = Utility.Random(ourBounds.Height - bounds.Height);
            }

            x += ourBounds.X;
            x -= bounds.X;

            y += ourBounds.Y;
            y -= bounds.Y;

            dropped.Location = new Point3D(x, y, 0);
        }