Exemple #1
0
        private void UpdateIncludeAndExclude(EmissionSettingsSave emissionSettings)
        {
            ResetToDefault();

            ExcludeMember("Instructions");

            if (emissionSettings != null)
            {
                var rangeType = emissionSettings.VelocityRangeType;
                if (rangeType != RangeType.Component)
                {
                    ExcludeMember("XVelocity");
                    ExcludeMember("YVelocity");
                    ExcludeMember("ZVelocity");
                    ExcludeMember("XVelocityRange");
                    ExcludeMember("YVelocityRange");
                    ExcludeMember("ZVelocityRange");
                }
                if (rangeType != RangeType.Cone &&
                    rangeType != RangeType.Wedge)
                {
                    ExcludeMember("WedgeAngle");
                    ExcludeMember("WedgeSpread");
                }

                if (rangeType == RangeType.Component)
                {
                    ExcludeMember("RadialVelocity");
                    ExcludeMember("RadialVelocityRange");
                }


                EnumToString blendEnumToString = new EnumToString();
                blendEnumToString.EnumType = typeof(BlendOperation);

                IncludeMember(
                    "BlendOperation",
                    containingType: typeof(EmissionSettingsSave),
                    typeConverter: blendEnumToString);

                EnumToString colorEnumToString = new EnumToString();
                colorEnumToString.EnumType = typeof(ColorOperation);

                IncludeMember(
                    "ColorOperation",
                    containingType: typeof(EmissionSettingsSave),
                    typeConverter: colorEnumToString);


                IncludeMember(
                    "Texture",
                    typeof(string),
                    HandleTextureChanged,
                    () =>
                {
                    return(SettingsSaveInstance.Texture);
                },
                    null,
                    new Attribute[]
                {
                    PropertyGridDisplayer.FileWindowAttribute, CategoryAttribute("Texture and Animation")[0]
                }
                    );

                IncludeMember(
                    "AnimationChains",
                    typeof(string),
                    HandleAniimationPathChanged,
                    () =>
                {
                    return(SettingsSaveInstance.AnimationChains);
                },
                    null,
                    new Attribute[]
                {
                    PropertyGridDisplayer.FileWindowAttribute, CategoryAttribute("Texture and Animation")[0]
                }
                    );
            }
        }
Exemple #2
0
        public static EmitterSave FromEmitter(Emitter emitterToCreateFrom)
        {
            EmitterSave emitterToReturn = new EmitterSave();

            emitterToReturn.X = (float)emitterToCreateFrom.Position.X;
            emitterToReturn.Y = (float)emitterToCreateFrom.Position.Y;
            emitterToReturn.Z = (float)emitterToCreateFrom.Position.Z;

            emitterToReturn.ScaleX = emitterToCreateFrom.ScaleX;
            emitterToReturn.ScaleY = emitterToCreateFrom.ScaleY;
            emitterToReturn.ScaleZ = emitterToCreateFrom.ScaleZ;

            emitterToReturn.RotationX = emitterToCreateFrom.RotationX;
            emitterToReturn.RotationY = emitterToCreateFrom.RotationY;
            emitterToReturn.RotationZ = emitterToCreateFrom.RotationZ;

            emitterToReturn.AreaEmissionType = FlatRedBall.Graphics.GraphicalEnumerations.TranslateAreaEmissionType(
                emitterToCreateFrom.AreaEmission);

            emitterToReturn.RemovalEvent =
                FlatRedBall.Graphics.Particle.Emitter.TranslateRemovalEvent(emitterToCreateFrom.RemovalEvent);

            if (emitterToCreateFrom.Parent != null)
            {
                emitterToReturn.ParentSpriteName = emitterToCreateFrom.Parent.Name;
            }

            emitterToReturn.Name = emitterToCreateFrom.Name;

            // Justin Johnson, 04/2015 - retiring particle blueprints
            //emitterToReturn.ParticleBlueprint = SpriteSave.FromSprite(emitterToCreateFrom.ParticleBlueprint);

            // I don't think that we need to manually set the texture - the SprietSave should do it on its own
            //particleBlueprint.spriteTexture = FRB.File.FileManager.MakeRelativeToPath(
            //    particleBlueprint.spriteTexture, relativeTo);

            emitterToReturn.BoundedEmission  = emitterToCreateFrom.BoundedEmission;
            emitterToReturn.EmissionBoundary = Polygon.PolygonSave.FromPolygon(emitterToCreateFrom.EmissionBoundary);

            emitterToReturn.EmissionSettings = EmissionSettingsSave.FromEmissionSettings(emitterToCreateFrom.EmissionSettings);

            emitterToReturn.SecondFrequency   = emitterToCreateFrom.SecondFrequency;
            emitterToReturn.NumberPerEmission = emitterToCreateFrom.NumberPerEmission;
            emitterToReturn.TimedEmission     = emitterToCreateFrom.TimedEmission;

            emitterToReturn.RemovalEvent =
                Emitter.TranslateRemovalEvent(emitterToCreateFrom.RemovalEvent);
            emitterToReturn.SecondsLasting = emitterToCreateFrom.SecondsLasting;

            emitterToReturn.RelativeX = emitterToCreateFrom.RelativePosition.X;
            emitterToReturn.RelativeY = emitterToCreateFrom.RelativePosition.Y;
            emitterToReturn.RelativeZ = emitterToCreateFrom.RelativePosition.Z;

            emitterToReturn.ParentVelocityChangesEmissionVelocity = emitterToCreateFrom.ParentVelocityChangesEmissionVelocity;
            emitterToReturn.RotationChangesParticleRotation       = emitterToCreateFrom.RotationChangesParticleRotation;
            emitterToReturn.RotationChangesParticleAcceleration   = emitterToCreateFrom.RotationChangesParticleAcceleration;

            // TODO:  Need to add support for saving off instructions.

            //particleInstructionArray = emitterToCreateFrom.ParticleBlueprint.instructionArray.Clone();

            // each instruction will reference the blueprint Sprite.  When serialized, the referenced Sprite
            // will be attempted to be saved.  This will throw an error (and also would take up a lot of memory if succeeded)
            //foreach(FrbInstruction frbi in particleInstructionArray)
            //	frbi.referenceObject = null;

            return(emitterToReturn);
        }