internal static XAnimationSet Read(XFileTokenReader tokenReader)
        {
            var animationSet = new XAnimationSet();

            if (tokenReader.FileReader.GetNextToken() == XToken.Name)
            {
                animationSet.Name = tokenReader.ReadName();
            }

            tokenReader.ReadAssert(XToken.OpenedBrace);

            while (tokenReader.FileReader.GetNextToken() != XToken.ClosedBrace)
            {
                string identifier = tokenReader.ReadName();

                switch (identifier)
                {
                case "Animation":
                {
                    XAnimation animation = XAnimation.Read(tokenReader);
                    animationSet.Animations.Add(animation);
                    break;
                }

                default:
                    throw new InvalidDataException();
                }
            }

            tokenReader.ReadAssert(XToken.ClosedBrace);

            return(animationSet);
        }
Пример #2
0
        internal static XAnimation Read(XFileTokenReader tokenReader)
        {
            var animation = new XAnimation();

            if (tokenReader.FileReader.GetNextToken() == XToken.Name)
            {
                animation.Name = tokenReader.ReadName();
            }

            tokenReader.ReadAssert(XToken.OpenedBrace);

            XToken token;

            while ((token = tokenReader.FileReader.GetNextToken()) != XToken.ClosedBrace)
            {
                if (token == XToken.OpenedBrace)
                {
                    if (animation.FrameReference != null)
                    {
                        throw new InvalidDataException();
                    }

                    tokenReader.ReadAssert(XToken.OpenedBrace);
                    animation.FrameReference = tokenReader.ReadName();
                    tokenReader.ReadAssert(XToken.ClosedBrace);
                    continue;
                }

                string identifier = tokenReader.ReadName();

                switch (identifier)
                {
                case "AnimationKey":
                {
                    XAnimationKey key = XAnimationKey.Read(tokenReader);
                    animation.Keys.Add(key);
                    break;
                }

                case "AnimationOptions":
                {
                    if (tokenReader.FileReader.GetNextToken() == XToken.Name)
                    {
                        tokenReader.ReadName();
                    }

                    tokenReader.ReadAssert(XToken.OpenedBrace);

                    animation.OpenClosedOption      = tokenReader.ReadIntegerFromList();
                    animation.PositionQualityOption = tokenReader.ReadIntegerFromList();

                    tokenReader.ReadAssert(XToken.ClosedBrace);
                    break;
                }

                default:
                    throw new NotImplementedException();
                }
            }

            tokenReader.ReadAssert(XToken.ClosedBrace);

            return(animation);
        }