internal static XAnimationKey Read(XFileTokenReader tokenReader) { var key = new XAnimationKey(); if (tokenReader.FileReader.GetNextToken() == XToken.Name) { key.Name = tokenReader.ReadName(); } tokenReader.ReadAssert(XToken.OpenedBrace); key.KeyType = (XAnimationKeyType)tokenReader.ReadIntegerFromList(); int keysCount = tokenReader.ReadIntegerFromList(); key.Keys.Capacity = keysCount; for (int i = 0; i < keysCount; i++) { int time = tokenReader.ReadIntegerFromList(); int valuesCount = tokenReader.ReadIntegerFromList(); float[] values = tokenReader.ReadFloatArrayFromList(valuesCount); tokenReader.ReadSeparator(); key.Keys.Add(Tuple.Create(time, values)); } tokenReader.ReadAssert(XToken.ClosedBrace); return(key); }
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); }