Пример #1
0
        public override Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent)
        {
            var name      = ComputeNewName(parent, "SpriteStudio");
            var component = new SpriteStudioComponent();

            return(CreateEntityWithComponent(name, component));
        }
        public SpriteStudioNodeTransformLink(SpriteStudioComponent parentModelComponent, string nodeName)
        {
            this.parentModelComponent = parentModelComponent;
            this.nodeName             = nodeName;
            sheet = parentModelComponent.Sheet;

            for (var index = 0; index < parentModelComponent.Nodes.Count; index++)
            {
                var node = parentModelComponent.Nodes[index];
                if (node.BaseNode.Name == nodeName)
                {
                    nodeIndex = index;
                    break;
                }
            }
        }
Пример #3
0
        internal static SpriteStudioNodeState InitializeNodes(SpriteStudioComponent spriteStudioComponent)
        {
            spriteStudioComponent.Nodes.Clear();

            var nodes = spriteStudioComponent.Sheet?.NodesInfo;

            if (nodes == null)
            {
                return(null);
            }

            //check if the sheet name dictionary has already been populated
            if (spriteStudioComponent.Sheet.Sprites == null)
            {
                spriteStudioComponent.Sheet.Sprites = new Sprite[spriteStudioComponent.Sheet.SpriteSheet.Sprites.Count];
                for (int i = 0; i < spriteStudioComponent.Sheet.SpriteSheet.Sprites.Count; i++)
                {
                    spriteStudioComponent.Sheet.Sprites[i] = spriteStudioComponent.Sheet.SpriteSheet.Sprites[i];
                }
            }

            foreach (var node in nodes)
            {
                var nodeState = new SpriteStudioNodeState
                {
                    Position     = node.BaseState.Position,
                    RotationZ    = node.BaseState.RotationZ,
                    Priority     = node.BaseState.Priority,
                    Scale        = node.BaseState.Scale,
                    Transparency = node.BaseState.Transparency,
                    Hide         = node.BaseState.Hide,
                    BaseNode     = node,
                    HFlipped     = node.BaseState.HFlipped,
                    VFlipped     = node.BaseState.VFlipped,
                    SpriteId     = node.BaseState.SpriteId,
                    BlendColor   = node.BaseState.BlendColor,
                    BlendType    = node.BaseState.BlendType,
                    BlendFactor  = node.BaseState.BlendFactor
                };

                nodeState.Sprite = nodeState.SpriteId != -1 ? spriteStudioComponent.Sheet.Sprites[nodeState.SpriteId] : null;

                spriteStudioComponent.Nodes.Add(nodeState);
            }

            SpriteStudioNodeState rootNode = null;

            for (var i = 0; i < nodes.Count; i++)
            {
                var nodeState = spriteStudioComponent.Nodes[i];
                var nodeAsset = nodes[i];

                if (nodeAsset.ParentId == -1)
                {
                    rootNode = nodeState;
                }
                else
                {
                    nodeState.ParentNode = spriteStudioComponent.Nodes.FirstOrDefault(x => x.BaseNode.Id == nodeAsset.ParentId);
                }

                foreach (var subNode in spriteStudioComponent.Nodes.Where(subNode => subNode.BaseNode.ParentId == nodeAsset.Id))
                {
                    nodeState.ChildrenNodes.Add(subNode);
                }
            }

            return(rootNode);
        }