Ejemplo n.º 1
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            StartLifetime.Read(reader);
            StartSpeed.Read(reader);
            StartColor.Read(reader);
            StartSize.Read(reader);
            if (IsReadSizeAxes(reader.Version))
            {
                StartSizeY.Read(reader);
                StartSizeZ.Read(reader);
            }
            if (IsReadRotationAxes(reader.Version))
            {
                StartRotationX.Read(reader);
                StartRotationY.Read(reader);
            }
            StartRotation.Read(reader);

            if (IsReadRandomizeRotationDirection(reader.Version))
            {
                RandomizeRotationDirection = reader.ReadSingle();
            }
            if (IsReadGravityModifierSingle(reader.Version))
            {
                float gravityModifier = reader.ReadSingle();
                GravityModifier = new MinMaxCurve(gravityModifier);
            }
            if (IsReadInheritVelocity(reader.Version))
            {
                InheritVelocity = reader.ReadSingle();
            }
            MaxNumParticles = reader.ReadInt32();
            if (IsReadSize3D(reader.Version))
            {
                Size3D = reader.ReadBoolean();
            }
            if (IsReadRotation3D(reader.Version))
            {
                Rotation3D = reader.ReadBoolean();
                reader.AlignStream(AlignType.Align4);
            }

            if (!IsReadGravityModifierSingle(reader.Version))
            {
                GravityModifier.Read(reader);
            }
        }
Ejemplo n.º 2
0
        public override void Read(AssetStream stream)
        {
            base.Read(stream);

            StartLifetime.Read(stream);
            StartSpeed.Read(stream);
            StartColor.Read(stream);
            StartSize.Read(stream);
            if (IsReadSizeAxes(stream.Version))
            {
                StartSizeY.Read(stream);
                StartSizeZ.Read(stream);
            }
            if (IsReadRotationAxes(stream.Version))
            {
                StartRotationX.Read(stream);
                StartRotationY.Read(stream);
            }
            StartRotation.Read(stream);

            if (IsReadRandomizeRotationDirection(stream.Version))
            {
                RandomizeRotationDirection = stream.ReadSingle();
            }
            if (IsReadGravityModifierSingle(stream.Version))
            {
                GravityModifierSingle = stream.ReadSingle();
            }
            if (IsReadInheritVelocity(stream.Version))
            {
                InheritVelocity = stream.ReadSingle();
            }
            MaxNumParticles = stream.ReadInt32();
            if (IsReadSize3D(stream.Version))
            {
                Size3D = stream.ReadBoolean();
            }
            if (IsReadRotation3D(stream.Version))
            {
                Rotation3D = stream.ReadBoolean();
                stream.AlignStream(AlignType.Align4);
            }

            if (!IsReadGravityModifierSingle(stream.Version))
            {
                GravityModifier.Read(stream);
            }
        }
Ejemplo n.º 3
0
        public override void StartKinetic(VisualPayload payload, Func <float, float> translateTime)
        {
            var startRotation         = StartRotation.GetFirstValue(payload.Data);
            var endRotation           = EndRotation.GetFirstValue(payload.Data);
            var transitionTimeInverse = 1f / TransitionTime.GetFirstValue(payload.Data);
            var startTime             = Time.time;

            var bound = payload.VisualData.Bound.CreateDependingBound("Lerp Rotation");

            bound.transform.parent = payload.VisualData.Bound.transform.parent;

            payload.VisualData.Bound.transform.parent = bound.transform;

            var rotationSatellite =
                bound.gameObject.AddComponent <BoundMovementSatellite>();

            var newPayload = new VisualPayload(payload.Data, new VisualDescription(bound));

            rotationSatellite.MovementFunc = (trans) =>
            {
                float proportion = (Time.time - startTime) * transitionTimeInverse;

                if (proportion >= 1)
                {
                    trans.rotation = endRotation;

                    rotationSatellite.Cleanup();
                    return;
                }

                proportion = translateTime(proportion);

                trans.rotation = Quaternion.Lerp(startRotation, endRotation, proportion);
            };

            rotationSatellite.CleanupFunc = (trans) =>
            {
                JobManager.Instance.StartJob(
                    Finished.Transmit(newPayload), jobName: "Kinetic Finished", startImmediately: true, maxExecutionsPerFrame: 1);
            };

            // execute first step immediately to set initial position
            rotationSatellite.MovementFunc(rotationSatellite.transform);

            //throw new System.NotImplementedException();
        }
Ejemplo n.º 4
0
        public override YAMLNode ExportYAML(IAssetsExporter exporter)
        {
#warning TODO: values acording to read version (current 2017.3.0f3)
            YAMLMappingNode node = (YAMLMappingNode)base.ExportYAML(exporter);
            node.InsertSerializedVersion(GetSerializedVersion(exporter.Version));
            node.Add("startLifetime", StartLifetime.ExportYAML(exporter));
            node.Add("startSpeed", StartSpeed.ExportYAML(exporter));
            node.Add("startColor", StartColor.ExportYAML(exporter));
            node.Add("startSize", StartSize.ExportYAML(exporter));
            node.Add("startSizeY", StartSizeY.ExportYAML(exporter));
            node.Add("startSizeZ", StartSizeZ.ExportYAML(exporter));
            node.Add("startRotationX", StartRotationX.ExportYAML(exporter));
            node.Add("startRotationY", StartRotationY.ExportYAML(exporter));
            node.Add("startRotation", StartRotation.ExportYAML(exporter));
            node.Add("randomizeRotationDirection", RandomizeRotationDirection);
            node.Add("maxNumParticles", MaxNumParticles);
            node.Add("size3D", Size3D);
            node.Add("rotation3D", Rotation3D);
            node.Add("gravityModifier", GravityModifier.ExportYAML(exporter));
            return(node);
        }
Ejemplo n.º 5
0
        public override YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = (YAMLMappingNode)base.ExportYAML(container);

            node.InsertSerializedVersion(GetSerializedVersion(container.Version));
            node.Add("startLifetime", StartLifetime.ExportYAML(container));
            node.Add("startSpeed", StartSpeed.ExportYAML(container));
            node.Add("startColor", StartColor.ExportYAML(container));
            node.Add("startSize", StartSize.ExportYAML(container));
            node.Add("startSizeY", GetStartSizeY(container.Version).ExportYAML(container));
            node.Add("startSizeZ", GetStartSizeZ(container.Version).ExportYAML(container));
            node.Add("startRotationX", GetStartRotationX(container.Version).ExportYAML(container));
            node.Add("startRotationY", GetStartRotationY(container.Version).ExportYAML(container));
            node.Add("startRotation", StartRotation.ExportYAML(container));
            node.Add("randomizeRotationDirection", RandomizeRotationDirection);
            node.Add("maxNumParticles", MaxNumParticles);
            node.Add("size3D", Size3D);
            node.Add("rotation3D", Rotation3D);
            node.Add("gravityModifier", GravityModifier.ExportYAML(container));
            return(node);
        }
Ejemplo n.º 6
0
        public override YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = (YAMLMappingNode)base.ExportYAML(container);

            node.InsertSerializedVersion(ToSerializedVersion(container.ExportVersion));
            node.Add(StartLifetimeName, StartLifetime.ExportYAML(container));
            node.Add(StartSpeedName, StartSpeed.ExportYAML(container));
            node.Add(StartColorName, StartColor.ExportYAML(container));
            node.Add(StartSizeName, StartSize.ExportYAML(container));
            node.Add(StartSizeYName, GetStartSizeY(container.Version).ExportYAML(container));
            node.Add(StartSizeZName, GetStartSizeZ(container.Version).ExportYAML(container));
            node.Add(StartRotationXName, GetStartRotationX(container.Version).ExportYAML(container));
            node.Add(StartRotationYName, GetStartRotationY(container.Version).ExportYAML(container));
            node.Add(StartRotationName, StartRotation.ExportYAML(container));
            node.Add(RandomizeRotationDirectionName, RandomizeRotationDirection);
            node.Add(MaxNumParticlesName, MaxNumParticles);
            node.Add(Size3DName, Size3D);
            node.Add(Rotation3DName, Rotation3D);
            node.Add(GravityModifierName, GravityModifier.ExportYAML(container));
            return(node);
        }