Пример #1
0
        private void DrawRecursive(IList <GameObject> layer)
        {
            for (int x = 0; x < layer.Count; x++)
            {
                GameObject node = layer[x];

                if (node.Visible)
                {
                    BoundingBox nodeBox = node.DrawBounds();
                    if (nodeBox.Intersects(Camera.ViewportBounds))
                    {
                        node.Draw(_SpriteBatch);
                        DrawRecursive(node.Children);
                    }
                    else
                    {
                        ++NodesCulled;
                    }
                }
            }
        }
Пример #2
0
        public void DrawBounds()
        {
            GameObject obj = new GameObject();
            obj.SetDrawSize(16, 32);
            obj.Position = new Vector2(128, 256);

            BoundingBox box = obj.DrawBounds();
            Vector3 expectedMin = new Vector3(obj.AbsolutePosition, 0);
            Vector3 expectedMax = new Vector3(obj.AbsolutePosition, 0);
            expectedMax.X += obj.DrawSize.Width;
            expectedMax.Y += obj.DrawSize.Height;
            Assert.That(box.Min, Is.EqualTo(expectedMin));
            Assert.That(box.Max, Is.EqualTo(expectedMax));

            //Rectangle bounds = new Rectangle( obj.DrawBounds.Min;
            //Assert.That(bounds.Width, Is.EqualTo(16));
            //Assert.That(bounds.Height, Is.EqualTo(32));
            //Assert.That(bounds.X, Is.EqualTo(128));
            //Assert.That(bounds.Y, Is.EqualTo(256));
        }