ノードのデータ取り出し
Ejemplo n.º 1
0
 /// <summary>
 /// boolで取得
 /// </summary>
 /// <returns></returns>
 public bool AtBoolean()
 {
     return(NodeReader.IsTrue(attribute_.Value));
 }
            public Cell( NodeReader node, int textureWidth, int textureHeight )
            {
                name = node.AtText( "name" );
                int[] pos = node.AtIntegers( "pos", ' ' );
                size = node.AtIntegers( "size", ' ' );
                pivot = node.AtFloats( "pivot", ' ' );
                rotated = node.AtBoolean( "rotated" );

                float s = pos[0] / (float) textureWidth;
                float t = 1f - (pos[1] / (float) textureHeight);
                float u = s + (size[0] / (float) textureWidth);
                float v = t - (size[1] / (float) textureHeight);
                uv = new float[4] { s, v, u, t };
            }
        /// <summary>
        /// 上書き設定の生成
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        private static OverrideSettings CreateOverrideSettings( NodeReader settings )
        {
            OverrideSettings overrideSettings = new OverrideSettings();
            {
                var fps = settings.ChildOrNull( "fps" );
                var frameCount = settings.ChildOrNull( "frameCount" );
                var sortMode = settings.ChildOrNull( "sortMode" );
                var pivot = settings.ChildOrNull( "pivot" );

                overrideSettings.fps = fps != null ? (int?) fps.AtInteger() : null;
                overrideSettings.frameCount = frameCount != null ? (int?) frameCount.AtInteger() : null;
                overrideSettings.sortMode = sortMode != null ? (SortMode?) SortModeOpeartor.FromString( sortMode.AtText() ) : null;
                if ( pivot != null ) {
                    float[] pivots = pivot.AtFloats( ' ' );
                    overrideSettings.pivotX = pivots[0];
                    overrideSettings.pivotY = pivots[1];
                } else {
                    overrideSettings.pivotX = null;
                    overrideSettings.pivotY = null;
                }
            }
            return overrideSettings;
        }
            public PartAnimation( NodeReader node )
            {
                partName = node.AtText( "partName" );
                var children = node.Child( "attributes" ).Children( "attribute" );

                var results = new List<SpriteAttribute>();
                foreach ( var child in children ) {
                    string tag = child.Attribute( "tag" ).AtText();
                    var targetType = Type.GetType( "a.spritestudio.editor.attribute." + tag );
                    var attribute = (SpriteAttribute) Activator.CreateInstance( targetType );
                    attribute.Setup( child );
                    results.Add( attribute );
                }
                attributes = results.AsReadOnly();
            }
            public Part( NodeReader node )
            {
                name = node.AtText( "name" );
                index = node.AtInteger( "arrayIndex" );
                parent = node.AtInteger( "parentIndex" );
                type = NodeTypeOperator.FromString( node.AtText( "type" ) );
                boundsType = BoundsTypeOperator.FromString( node.AtText( "boundsType" ) );
                inheritType = InheritTypeOperator.FromString( node.AtText( "inheritType" ) );
                //inheritRates
                blendType = AlphaBlendTypeOperator.FromString( node.AtText( "alphaBlendType" ) );
                show = node.AtBoolean( "show" );

                var n = node.ChildOrNull( "expandAttribute" );
                expandAttribute = n != null ? n.AtText() : null;

                n = node.ChildOrNull( "expandChildren" );
                expandChildren = n != null ? n.AtText() : null;
            }
            public Animation( NodeReader node )
            {
                name = node.AtText( "name" );
                if ( node.AtBoolean( "overrideSettings" ) ) {
                    settings = CreateOverrideSettings( node.Child( "settings" ) );
                } else {
                    settings = new OverrideSettings();
                }

                var parts = node.Child( "partAnimes" ).Children( "partAnime" );
                List<PartAnimation> results = new List<PartAnimation>();
                foreach ( var part in parts ) {
                    results.Add( new PartAnimation( part ) );
                }
                this.parts = results.AsReadOnly();
            }