Example #1
0
        // COPY PROPERTY //
        //
        override public void CopyProperty(BaseProperty originalProperty, AmpsBlueprint theOwnerBlueprint)
        {
            base.CopyProperty(originalProperty, theOwnerBlueprint);

            ColorProperty originalColorProperty = originalProperty as ColorProperty;

            constant  = originalColorProperty.constant;
            randomMin = originalColorProperty.randomMin;
            randomMax = originalColorProperty.randomMax;
            curve     = ScriptableObject.CreateInstance <VectorCurve>();
            curve.Initialize(originalColorProperty.curve);
            curveMin = ScriptableObject.CreateInstance <VectorCurve>();
            curveMin.Initialize(originalColorProperty.curveMin);
            curveMax = ScriptableObject.CreateInstance <VectorCurve>();
            curveMax.Initialize(originalColorProperty.curveMax);
            usePerComponentRandom = originalColorProperty.usePerComponentRandom;
            Randomize();

            dummyTexture = new Texture2D(1, 1);
        }
Example #2
0
//============================================================================//
        #region Module management

        // DELETE MODULE FROM ASSET //
        //
        public void DeleteModuleFromAsset(BaseModule theModule)
        {
            for (int i = 0; i < theModule.properties.Count; i++)
            {
                if (theModule.properties[i].GetType() == typeof(ScalarProperty))
                {
                    ScalarProperty sp = theModule.properties[i] as ScalarProperty;
                    UnityEngine.Object.DestroyImmediate(sp.curve, true);
                    UnityEngine.Object.DestroyImmediate(sp.curveMin, true);
                    UnityEngine.Object.DestroyImmediate(sp.curveMax, true);
                }

                if (theModule.properties[i].GetType() == typeof(VectorProperty))
                {
                    VectorProperty vp = theModule.properties[i] as VectorProperty;
                    UnityEngine.Object.DestroyImmediate(vp.curve, true);
                    UnityEngine.Object.DestroyImmediate(vp.curveMin, true);
                    UnityEngine.Object.DestroyImmediate(vp.curveMax, true);
                }

                if (theModule.properties[i].GetType() == typeof(ColorProperty))
                {
                    ColorProperty cp = theModule.properties[i] as ColorProperty;
                    UnityEngine.Object.DestroyImmediate(cp.curve, true);
                    UnityEngine.Object.DestroyImmediate(cp.curveMin, true);
                    UnityEngine.Object.DestroyImmediate(cp.curveMax, true);
                }

                if (string.IsNullOrEmpty(AssetDatabase.GetAssetPath(theModule.properties[i].reference)) == false)
                {
                    UnityEngine.Object.DestroyImmediate(theModule.properties[i].reference, true);
                }
                UnityEngine.Object.DestroyImmediate(theModule.properties[i], true);
            }
            UnityEngine.Object.DestroyImmediate(theModule, true);
            AssetDatabase.SaveAssets();
            ownerBlueprint.ownerEmitter.SoftReset();
        }
Example #3
0
        private Texture2D dummyTexture;         // Empty texture asset for drawing EditorGUI.DrawPreviewTexture().
#endif
//============================================================================//

        // GET VALUE //
        //
        // GetValue when particle index is NOT known.
        public Vector4 GetValue()
        {
            Vector4 returnValue    = Vector4.zero;
            Vector4 curveMinResult = Vector4.zero;
            Vector4 curveMaxResult = Vector4.zero;

            System.Random theRandom = new System.Random(ownerBlueprint.ownerEmitter.randomSeed + randomSeed);

#if UNITY_EDITOR
            CheckReferences();
#endif

            switch (dataMode)
            {
            case eDataMode.Constant:
                returnValue = constant;
                break;

            case eDataMode.RandomConstant:
                if (usePerComponentRandom)
                {
                    returnValue.x = Mathf.Lerp(randomMin.x, randomMax.x, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.y = Mathf.Lerp(randomMin.y, randomMax.y, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.z = Mathf.Lerp(randomMin.z, randomMax.z, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.w = Mathf.Lerp(randomMin.w, randomMax.w, (float)theRandom.NextDouble());
                }
                else
                {
                    returnValue = Vector4.Lerp(randomMin, randomMax, (float)theRandom.NextDouble());
                }
                break;

            case eDataMode.Curve:
                returnValue = curve.Evaluate(ownerBlueprint.ownerEmitter);
                break;

            case eDataMode.RandomCurve:
                if (usePerComponentRandom)
                {
                    curveMinResult = curveMin.Evaluate(ownerBlueprint.ownerEmitter);
                    curveMaxResult = curveMax.Evaluate(ownerBlueprint.ownerEmitter);

                    returnValue.x = Mathf.Lerp(curveMinResult.x, curveMaxResult.x, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.y = Mathf.Lerp(curveMinResult.y, curveMaxResult.y, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.z = Mathf.Lerp(curveMinResult.z, curveMaxResult.z, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.w = Mathf.Lerp(curveMinResult.w, curveMaxResult.w, (float)theRandom.NextDouble());
                }
                else
                {
                    returnValue = Vector4.Lerp(curveMin.Evaluate(ownerBlueprint.ownerEmitter), curveMax.Evaluate(ownerBlueprint.ownerEmitter), (float)theRandom.NextDouble());
                }
                break;

            case eDataMode.Reference:
                if (reference != null)
                {
                    ColorProperty theReference = (ColorProperty)reference.property;
                    returnValue = theReference.GetValue();
                }
                break;
            }

            if (coordSystemConversionMode != BaseProperty.eCoordSystemConversionMode.NoConversion)
            {
                returnValue = ConvertCoordinateSystem(returnValue, -1);
            }

            return(returnValue);
        }
Example #4
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = "";
            type        = "Quick setup";
            SetDefaultName();

            modifySpawnRate.value      = true;
            modifyDeathCondition.value = true;
            modifyAcceleration.value   = true;
            modifyVelocity.value       = true;
            modifyPosition.value       = true;
            modifyRotationRate.value   = true;
            modifyRotation.value       = true;
            modifyScale.value          = true;
            modifyColor.value          = true;
            modifyPivotOffset.value    = true;

            spawnRate = ScriptableObject.CreateInstance <ScalarProperty>();
            spawnRate.Initialize("Spawn rate", 5, theOwnerBlueprint);
            spawnRate.allowDataModeReference = false;
            AddProperty(spawnRate, false);

            deathCondition = ScriptableObject.CreateInstance <ScalarProperty>();
            deathCondition.Initialize("Death condition", 0, theOwnerBlueprint);
            deathCondition.allowDataModeReference = false;
            deathCondition.dataMode            = BaseProperty.eDataMode.Curve;
            deathCondition.curve.curveInput    = AmpsHelpers.eCurveInputs.ParticleTime;
            deathCondition.curve.inputRangeMin = 0;
            deathCondition.curve.inputRangeMax = 2;             // Default lifetime.
            deathCondition.curve.curve.AddKey(0, 0);
            deathCondition.curve.curve.AddKey(1, 1);
            deathCondition.curve.outputRangeMin = 0;
            deathCondition.curve.outputRangeMax = 1;
            AddProperty(deathCondition, false);

            acceleration = ScriptableObject.CreateInstance <VectorProperty>();
            acceleration.Initialize("Acceleration", new Vector4(0, -0.1f, 0, 0), theOwnerBlueprint);
            acceleration.allowDataModeReference    = false;
            acceleration.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.AsVelocity;
            acceleration.usePerComponentRandom     = true;
            acceleration.hideW = true;
            AddProperty(acceleration, false);

            velocity = ScriptableObject.CreateInstance <VectorProperty>();
            velocity.Initialize("Velocity min", new Vector4(0, 0, 0, 0), theOwnerBlueprint);
            velocity.allowDataModeReference    = false;
            velocity.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.AsVelocity;
            velocity.hideW = true;
            velocity.usePerComponentRandom = true;
            velocity.dataMode  = BaseProperty.eDataMode.RandomConstant;
            velocity.randomMin = new Vector4(-1, 1, -1, 0);
            velocity.randomMax = new Vector4(1, 2, 1, 0);
            AddProperty(velocity, false);

            position = ScriptableObject.CreateInstance <VectorProperty>();
            position.Initialize("Position", new Vector4(0, 0, 0, 0), theOwnerBlueprint);
            position.allowDataModeReference    = false;
            position.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.AsPosition;
            position.coordSystem           = AmpsHelpers.eCoordSystems.Emitter;
            position.hideW                 = true;
            position.usePerComponentRandom = true;
            AddProperty(position, false);

            rotationRate = ScriptableObject.CreateInstance <VectorProperty>();
            rotationRate.Initialize("Rotation rate", new Vector4(0, 0, 0, 0), theOwnerBlueprint);
            rotationRate.allowDataModeReference    = false;
            rotationRate.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.AsVelocity;
            rotationRate.hideW = true;
            rotationRate.usePerComponentRandom = true;
            AddProperty(rotationRate, false);

            rotation = ScriptableObject.CreateInstance <VectorProperty>();
            rotation.Initialize("Rotation", new Vector4(0, 0, 0, 0), theOwnerBlueprint);
            rotation.allowDataModeReference    = false;
            rotation.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.AsRotation;
            rotation.coordSystem           = AmpsHelpers.eCoordSystems.Emitter;
            rotation.hideW                 = true;
            rotation.usePerComponentRandom = true;
            AddProperty(rotation, false);

            scale = ScriptableObject.CreateInstance <VectorProperty>();
            scale.Initialize("Scale", new Vector4(0.2f, 0.2f, 0.2f, 0), theOwnerBlueprint);
            scale.allowDataModeReference    = false;
            scale.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.AsScale;
            scale.coordSystem           = AmpsHelpers.eCoordSystems.Emitter;
            scale.usePerComponentRandom = false;
            scale.hideW = true;
            AddProperty(scale, false);

            color = ScriptableObject.CreateInstance <ColorProperty>();
            color.Initialize("Color", new Vector4(1, 0.5f, 0.25f, 1), theOwnerBlueprint);
            color.allowDataModeReference = false;
            color.usePerComponentRandom  = false;
            AddProperty(color, false);

            pivotOffset = ScriptableObject.CreateInstance <VectorProperty>();
            pivotOffset.Initialize("Pivot offset", new Vector4(0, 0, 0, 0), theOwnerBlueprint);
            pivotOffset.allowDataModeReference    = false;
            pivotOffset.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.AsPosition;
            pivotOffset.hideW = true;
            pivotOffset.usePerComponentRandom = true;
            AddProperty(pivotOffset, false);
        }