Пример #1
0
        public static ComponentAnimation Read(BlockReader reader, ActorComponent[] components)
        {
            ComponentAnimation componentAnimation = new ComponentAnimation();

            componentAnimation.m_ComponentIndex = reader.ReadUInt16();
            int numProperties = (int)reader.ReadUInt16();

            componentAnimation.m_Properties = new PropertyAnimation[numProperties];
            for (int i = 0; i < numProperties; i++)
            {
                componentAnimation.m_Properties[i] = PropertyAnimation.Read(reader, components[componentAnimation.m_ComponentIndex]);
            }

            return(componentAnimation);
        }
Пример #2
0
        public static PropertyAnimation Read(BlockReader reader, ActorComponent component)
        {
            BlockReader propertyBlock = reader.ReadNextBlock();

            if (propertyBlock == null)
            {
                return(null);
            }
            PropertyAnimation propertyAnimation = new PropertyAnimation();
            int type = propertyBlock.BlockType;

            if (!Enum.IsDefined(typeof(PropertyTypes), type))
            {
                return(null);
            }
            else
            {
                propertyAnimation.m_Type = (PropertyTypes)type;

                Func <BinaryReader, ActorComponent, KeyFrame> keyFrameReader = null;
                switch (propertyAnimation.m_Type)
                {
                case PropertyTypes.PosX:
                    keyFrameReader = KeyFramePosX.Read;
                    break;

                case PropertyTypes.PosY:
                    keyFrameReader = KeyFramePosY.Read;
                    break;

                case PropertyTypes.ScaleX:
                    keyFrameReader = KeyFrameScaleX.Read;
                    break;

                case PropertyTypes.ScaleY:
                    keyFrameReader = KeyFrameScaleY.Read;
                    break;

                case PropertyTypes.Rotation:
                    keyFrameReader = KeyFrameRotation.Read;
                    break;

                case PropertyTypes.Opacity:
                    keyFrameReader = KeyFrameOpacity.Read;
                    break;

                case PropertyTypes.DrawOrder:
                    keyFrameReader = KeyFrameDrawOrder.Read;
                    break;

                case PropertyTypes.Length:
                    keyFrameReader = KeyFrameLength.Read;
                    break;

                case PropertyTypes.VertexDeform:
                    keyFrameReader = KeyFrameVertexDeform.Read;
                    break;

                case PropertyTypes.ConstraintStrength:
                    keyFrameReader = KeyFrameConstraintStrength.Read;
                    break;

                case PropertyTypes.Trigger:
                    keyFrameReader = KeyFrameTrigger.Read;
                    break;

                case PropertyTypes.IntProperty:
                    keyFrameReader = KeyFrameIntProperty.Read;
                    break;

                case PropertyTypes.FloatProperty:
                    keyFrameReader = KeyFrameFloatProperty.Read;
                    break;

                case PropertyTypes.StringProperty:
                    keyFrameReader = KeyFrameStringProperty.Read;
                    break;

                case PropertyTypes.BooleanProperty:
                    keyFrameReader = KeyFrameBooleanProperty.Read;
                    break;

                case PropertyTypes.CollisionEnabled:
                    keyFrameReader = KeyFrameCollisionEnabledProperty.Read;
                    break;

                case PropertyTypes.ActiveChildIndex:
                    keyFrameReader = KeyFrameActiveChild.Read;
                    break;
                }

                int keyFrameCount = propertyBlock.ReadUInt16();
                propertyAnimation.m_KeyFrames = new KeyFrame[keyFrameCount];
                KeyFrame lastKeyFrame = null;
                for (int i = 0; i < keyFrameCount; i++)
                {
                    KeyFrame frame = keyFrameReader(propertyBlock, component);
                    propertyAnimation.m_KeyFrames[i] = frame;
                    if (lastKeyFrame != null)
                    {
                        lastKeyFrame.SetNext(frame);
                    }
                    lastKeyFrame = frame;
                }
            }

            return(propertyAnimation);
        }