public IComponentInfo Load(XElement node, Project project)
        {
            var spriteComponent = new SpriteComponentInfo();

            FilePath sheetPath = null;
            var sheetNode = node.Element("Tilesheet");
            if (sheetNode != null)
            {
                sheetPath = FilePath.FromRelative(sheetNode.Value, project.BaseDir);
                spriteComponent.SheetPath = sheetPath;
            }

            foreach (var spriteNode in node.Elements("Sprite"))
            {
                if (sheetPath == null)
                {
                    var sprite = _spriteReader.LoadSprite(spriteNode, project.BaseDir);
                    spriteComponent.Sprites.Add(sprite.Name ?? "Default", sprite);
                }
                else
                {
                    var sprite = _spriteReader.LoadSprite(spriteNode);
                    sprite.SheetPath = sheetPath;
                    spriteComponent.Sprites.Add(sprite.Name ?? "Default", sprite);
                }
            }

            if (spriteComponent.SheetPath != null || spriteComponent.Sprites.Any())
                return spriteComponent;
            else
                return null;
        }
Exemple #2
0
        private void LoadSpriteComponent(GameEntity entity, SpriteComponentInfo componentInfo)
        {
            var spritecomp = new SpriteComponent();

            entity.AddComponent(spritecomp);

            spritecomp.LoadInfo(componentInfo);
        }
Exemple #3
0
        internal void LoadInfo(SpriteComponentInfo componentInfo)
        {
            _sheetPath = componentInfo.SheetPath;

            foreach (var sprite in componentInfo.Sprites.Values)
            {
                Add(sprite.Name ?? "Default", sprite, sprite.Part);
            }
        }
Exemple #4
0
        public IComponentInfo Load(XElement node, Project project)
        {
            var spriteComponent = new SpriteComponentInfo();

            FilePath sheetPath = null;
            var      sheetNode = node.Element("Tilesheet");

            if (sheetNode != null)
            {
                sheetPath = FilePath.FromRelative(sheetNode.Value, project.BaseDir);
                spriteComponent.SheetPath = sheetPath;
            }

            foreach (var spriteNode in node.Elements("Sprite"))
            {
                if (sheetPath == null)
                {
                    var sprite = _spriteReader.LoadSprite(spriteNode, project.BaseDir);
                    spriteComponent.Sprites.Add(sprite.Name ?? "Default", sprite);
                }
                else
                {
                    var sprite = _spriteReader.LoadSprite(spriteNode);
                    sprite.SheetPath = sheetPath;
                    spriteComponent.Sprites.Add(sprite.Name ?? "Default", sprite);
                }
            }

            if (spriteComponent.SheetPath != null || spriteComponent.Sprites.Any())
            {
                return(spriteComponent);
            }
            else
            {
                return(null);
            }
        }
        private void LoadSpriteComponent(GameEntity entity, SpriteComponentInfo componentInfo)
        {
            var spritecomp = new SpriteComponent();
            entity.AddComponent(spritecomp);

            spritecomp.LoadInfo(componentInfo);
        }