Пример #1
0
        public void Add(DrawNode child)
        {
            if (_items == null)
                _items = new Bag<DrawNode>();

            _items.Add(child);
            child.Parent = this;
        }
Пример #2
0
 internal void DrawNode(DrawNode node)
 {
     _layerTransform = DrawInfo.FromDrawable(SkidiGame.Camera);
     _transform = _layerTransform;
     _spriteBatch.Begin();
     InternalDrawNode(node);
     _spriteBatch.End();
 }
Пример #3
0
        public void RemoveChild(DrawNode child)
        {
            if (_items == null)
                return;

            if (_items.Remove(child))
                child.Parent = null;
        }
Пример #4
0
        private void InternalDrawNode(DrawNode node)
        {
            node.WorldPosition = _transform.Position + node.Position;
            node.ScreenPosition = node.WorldPosition - _layerCamPosition;

            if (node.Visible)
                node.Draw(this);
            else
                return;

            if (node.ChildrenCount == 0)
                return;

            var startTransform = _transform;
            _transform.Position += node.Position;

            if (node.Cascade)
            {
                _transform.Alpha *= node.Alpha;
                _transform.Color *= node.Color.ToVector3();
                _transform.Rotation += node.Rotation;
                _transform.Scale *= node.Scale;
            }

            foreach (var child in node.Children)
                InternalDrawNode(child);

            _transform = startTransform;
        }
Пример #5
0
 public void Remove(DrawNode node)
 {
     _nodes.Remove(node);
 }
Пример #6
0
 public void Add(DrawNode node)
 {
     _nodes.Add(node);
 }