示例#1
0
        public List<Affector> InitAffectors(EffectNode node)
        {
            List<Affector> AffectorList = new List<Affector>();

            if (UVAffectorEnable)
            {
                UVAnimation uvAnim = new UVAnimation();
                if (UVType == 1)
                {
                    float perWidth = OriUVDimensions.x / Cols;
                    float perHeight = Mathf.Abs(OriUVDimensions.y / Rows);
                    Vector2 cellSize = new Vector2(perWidth, perHeight);
                    uvAnim.BuildUVAnim(OriTopLeftUV, cellSize, Cols, Rows, Cols * Rows);
                }
                UVDimension = uvAnim.UVDimensions[0];
                UVTopLeft = uvAnim.frames[0];

                if (uvAnim.frames.Length != 1)
                {
                    uvAnim.loopCycles = LoopCircles;
                    Affector aft = new UVAffector(uvAnim, UVTime, node, RandomStartFrame);
                    AffectorList.Add(aft);
                }
            }
            else
            {
                UVDimension = OriUVDimensions;
                UVTopLeft = OriTopLeftUV;
            }


            if (RotAffectorEnable && RotateType != RSTYPE.NONE)
            {
                Affector aft;
                if (RotateType == RSTYPE.NONE)
                    aft = new RotateAffector(DeltaRot, node);
                else
                    aft = new RotateAffector(RotateType, node);
                AffectorList.Add(aft);
            }
            if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE)
            {
                Affector aft;

                if (ScaleType == RSTYPE.NONE)
                    aft = new ScaleAffector(DeltaScaleX, DeltaScaleY, node);
                else
                    aft = new ScaleAffector(ScaleType, node);

                AffectorList.Add(aft);
            }
            if (ColorAffectorEnable /*&& ColorAffectType != 0*/)
            {
                ColorAffector aft = new ColorAffector(this, node);
                AffectorList.Add(aft);
            }
            if (JetAffectorEnable)
            {
                Affector aft = new JetAffector(JetMag, JetMagType, JetCurve, node);
                AffectorList.Add(aft);
            }
            if (VortexAffectorEnable)
            {
                Affector aft;
                aft = new VortexAffector(VortexObj, VortexDirection, VortexInheritRotation, node);

                AffectorList.Add(aft);
            }
            if (UVRotAffectorEnable)
            {
                Affector aft;

                float xscroll = UVRotXSpeed;
                float yscroll = UVRotYSpeed;
                if (RandomUVRotateSpeed)
                {
                    xscroll = Random.Range(UVRotXSpeed, UVRotXSpeedMax);
                    yscroll = Random.Range(UVRotYSpeed, UVRotYSpeedMax);
                }

                aft = new UVRotAffector(xscroll, yscroll, node);
                AffectorList.Add(aft);
            }

            if (UVScaleAffectorEnable)
            {
                Affector aft = new UVScaleAffector(node);
                AffectorList.Add(aft);
            }

            if (GravityAffectorEnable)
            {
                Affector aft;
                aft = new GravityAffector(GravityObject, GravityAftType, IsGravityAccelerate, GravityDirection, node);
                AffectorList.Add(aft);

                if (GravityAftType == GAFTTYPE.Spherical && GravityObject == null)
                {
                    Debug.LogWarning("Gravity Object is missing, automatically set to effect layer self:" + gameObject.name);
                    GravityObject = transform;
                }

            }
            if (AirAffectorEnable)
            {
                Affector aft = new AirFieldAffector(AirObject, AirDirection, AirAttenuation, AirUseMaxDistance,
                    AirMaxDistance, AirEnableSpread, AirSpread, AirInheritVelocity, AirInheritRotation, node);
                AffectorList.Add(aft);
            }
            if (BombAffectorEnable)
            {
                Affector aft = new BombAffector(BombObject, BombType, BombDecayType, BombMagnitude, BombDecay, BombAxis, node);
                AffectorList.Add(aft);
            }
            if (TurbulenceAffectorEnable)
            {
                Affector aft = new TurbulenceFieldAffector(TurbulenceObject, TurbulenceAttenuation, TurbulenceUseMaxDistance, TurbulenceMaxDistance, node);
                AffectorList.Add(aft);
            }
            if (DragAffectorEnable)
            {
                Affector aft = new DragAffector(DragObj, DragUseDir, DragDir, DragMag, DragUseMaxDist, DragMaxDist, DragAtten, node);
                AffectorList.Add(aft);
            }

            if (SineAffectorEnable)
            {
                Affector aft = new SineAffector(node);
                AffectorList.Add(aft);
            }
            return AffectorList;
        }
示例#2
0
        public List <Affector> InitAffectors(EffectNode node)
        {
            List <Affector> AffectorList = new List <Affector>();

            if (UVAffectorEnable)
            {
                UVAnimation uvAnim = new UVAnimation();
                if (UVType == 1)
                {
                    float   perWidth  = OriUVDimensions.x / Cols;
                    float   perHeight = Mathf.Abs(OriUVDimensions.y / Rows);
                    Vector2 cellSize  = new Vector2(perWidth, perHeight);
                    uvAnim.BuildUVAnim(OriTopLeftUV, cellSize, Cols, Rows, Cols * Rows);
                }
                UVDimension = uvAnim.UVDimensions[0];
                UVTopLeft   = uvAnim.frames[0];

                if (uvAnim.frames.Length != 1)
                {
                    uvAnim.loopCycles = LoopCircles;
                    Affector aft = new UVAffector(uvAnim, UVTime, node, RandomStartFrame);
                    AffectorList.Add(aft);
                }
            }
            else
            {
                UVDimension = OriUVDimensions;
                UVTopLeft   = OriTopLeftUV;
            }


            if (RotAffectorEnable && RotateType != RSTYPE.NONE)
            {
                Affector aft;
                if (RotateType == RSTYPE.NONE)
                {
                    aft = new RotateAffector(DeltaRot, node);
                }
                else
                {
                    aft = new RotateAffector(RotateType, node);
                }
                AffectorList.Add(aft);
            }
            if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE)
            {
                Affector aft;

                if (ScaleType == RSTYPE.NONE)
                {
                    aft = new ScaleAffector(DeltaScaleX, DeltaScaleY, node);
                }
                else
                {
                    aft = new ScaleAffector(ScaleType, node);
                }

                AffectorList.Add(aft);
            }
            if (ColorAffectorEnable /*&& ColorAffectType != 0*/)
            {
                ColorAffector aft = new ColorAffector(this, node);
                AffectorList.Add(aft);
            }
            if (JetAffectorEnable)
            {
                Affector aft = new JetAffector(JetMag, JetMagType, JetCurve, node);
                AffectorList.Add(aft);
            }
            if (VortexAffectorEnable)
            {
                Affector aft;
                aft = new VortexAffector(VortexObj, VortexDirection, VortexInheritRotation, node);

                AffectorList.Add(aft);
            }
            if (UVRotAffectorEnable)
            {
                Affector aft;

                float xscroll = UVRotXSpeed;
                float yscroll = UVRotYSpeed;
                if (RandomUVRotateSpeed)
                {
                    xscroll = Random.Range(UVRotXSpeed, UVRotXSpeedMax);
                    yscroll = Random.Range(UVRotYSpeed, UVRotYSpeedMax);
                }

                aft = new UVRotAffector(xscroll, yscroll, node);
                AffectorList.Add(aft);
            }

            if (UVScaleAffectorEnable)
            {
                Affector aft = new UVScaleAffector(node);
                AffectorList.Add(aft);
            }

            if (GravityAffectorEnable)
            {
                Affector aft;
                aft = new GravityAffector(GravityObject, GravityAftType, IsGravityAccelerate, GravityDirection, node);
                AffectorList.Add(aft);

                if (GravityAftType == GAFTTYPE.Spherical && GravityObject == null)
                {
                    Debug.LogWarning("Gravity Object is missing, automatically set to effect layer self:" + gameObject.name);
                    GravityObject = transform;
                }
            }
            if (AirAffectorEnable)
            {
                Affector aft = new AirFieldAffector(AirObject, AirDirection, AirAttenuation, AirUseMaxDistance,
                                                    AirMaxDistance, AirEnableSpread, AirSpread, AirInheritVelocity, AirInheritRotation, node);
                AffectorList.Add(aft);
            }
            if (BombAffectorEnable)
            {
                Affector aft = new BombAffector(BombObject, BombType, BombDecayType, BombMagnitude, BombDecay, BombAxis, node);
                AffectorList.Add(aft);
            }
            if (TurbulenceAffectorEnable)
            {
                Affector aft = new TurbulenceFieldAffector(TurbulenceObject, TurbulenceAttenuation, TurbulenceUseMaxDistance, TurbulenceMaxDistance, node);
                AffectorList.Add(aft);
            }
            if (DragAffectorEnable)
            {
                Affector aft = new DragAffector(DragObj, DragUseDir, DragDir, DragMag, DragUseMaxDist, DragMaxDist, DragAtten, node);
                AffectorList.Add(aft);
            }

            if (SineAffectorEnable)
            {
                Affector aft = new SineAffector(node);
                AffectorList.Add(aft);
            }
            return(AffectorList);
        }