public EffectController()
     : base(0x1B72)
 {
     Movable = false;
     Visible = false;
     m_TriggerType = EffectTriggerType.Sequenced;
     m_EffectLayer = (EffectLayer)255;
 }
Example #2
0
 public BlessEffect( StatType stat, int sound, int eid, int speed, int duraction, int eff, EffectLayer layer )
 {
     m_Stat = stat;
     m_Snd = sound;
     m_EffIID = eid;
     m_EffSpd = speed;
     m_Dur = duraction;
     m_Eff = eff;
     m_ELayer = layer;
 }
Example #3
0
 public EffectNode(int index, Transform clienttrans, bool sync, EffectLayer owner)
 {
     Index = index;
     ClientTrans = clienttrans;
     SyncClient = sync;
     Owner = owner;
     LowerLeftUV = Vector2.zero;
     UVDimensions = Vector2.one;
     Scale = Vector2.one;
     RotateAngle = 0;
     Color = Color.white;
 }
Example #4
0
    protected void EmitterConfig(EffectLayer ctarget)
    {
        DisplayEmitterConfig = EditorGUILayout.Foldout(DisplayEmitterConfig, "Emitter Configuration");

        if (DisplayEmitterConfig)
        {
            EditorGUILayout.BeginVertical();

            ctarget.EmitType = EditorGUILayout.Popup("emitter type:", ctarget.EmitType, EmitTypes);
            if (ctarget.EmitType == 0)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("emit position:", ctarget.EmitPoint);
            }
            else if (ctarget.EmitType == 1)
            {
                ctarget.EmitPoint          = EditorGUILayout.Vector3Field("box center:", ctarget.EmitPoint);
                ctarget.BoxSize            = EditorGUILayout.Vector3Field("box size:", ctarget.BoxSize);
                ctarget.BoxInheritRotation = EditorGUILayout.Toggle("inherit rotation?", ctarget.BoxInheritRotation);
            }
            else if (ctarget.EmitType == 2)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("sphere center:", ctarget.EmitPoint);
                ctarget.Radius    = EditorGUILayout.FloatField("radius:", ctarget.Radius);
            }
            else if (ctarget.EmitType == 3)
            {
                ctarget.EmitPoint   = EditorGUILayout.Vector3Field("circle center:", ctarget.EmitPoint);
                ctarget.CircleDir   = EditorGUILayout.Vector3Field("circle direction:", ctarget.CircleDir);
                ctarget.Radius      = EditorGUILayout.FloatField("radius:", ctarget.Radius);
                ctarget.EmitUniform = EditorGUILayout.Toggle("emit uniformly?", ctarget.EmitUniform);
            }
            else if (ctarget.EmitType == 4)
            {
                ctarget.EmitPoint       = EditorGUILayout.Vector3Field("line center:", ctarget.EmitPoint);
                ctarget.LineLengthLeft  = EditorGUILayout.FloatField("line left length:", ctarget.LineLengthLeft);
                ctarget.LineLengthRight = EditorGUILayout.FloatField("line right length:", ctarget.LineLengthRight);
                EditorGUILayout.LabelField("[line direction is based on client's forward direction.]");
            }
            else if (ctarget.EmitType == 5)
            {
                ctarget.EmitMesh     = (Mesh)EditorGUILayout.ObjectField("mesh", ctarget.EmitMesh, typeof(Mesh), true);
                ctarget.EmitMeshType = EditorGUILayout.Popup("mesh emit pos:", ctarget.EmitMeshType, EmitMeshType);
                ctarget.EmitUniform  = EditorGUILayout.Toggle("emit uniform?", ctarget.EmitUniform);
            }
            EditorGUILayout.Space();

            ctarget.MaxENodes      = EditorGUILayout.IntField("max nodes:", ctarget.MaxENodes);
            ctarget.IsNodeLifeLoop = EditorGUILayout.Toggle("is node life loop:", ctarget.IsNodeLifeLoop);
            if (!ctarget.IsNodeLifeLoop)
            {
                ctarget.NodeLifeMin = EditorGUILayout.FloatField("node life min:", ctarget.NodeLifeMin);
                ctarget.NodeLifeMax = EditorGUILayout.FloatField("node life max:", ctarget.NodeLifeMax);
            }

            //ctarget.IsEmitByDistance = EditorGUILayout.Toggle("emit by distance:", ctarget.IsEmitByDistance);

            ctarget.EmitWay = (EEmitWay)EditorGUILayout.EnumPopup("emit method:", ctarget.EmitWay);

            if (ctarget.EmitWay == EEmitWay.ByDistance)
            {
                ctarget.DiffDistance = EditorGUILayout.FloatField("diff distance:", ctarget.DiffDistance);
            }
            else if (ctarget.EmitWay == EEmitWay.ByRate)
            {
                ctarget.ChanceToEmit = EditorGUILayout.Slider("chance to emit per loop:", ctarget.ChanceToEmit, 1, 100);
                ctarget.EmitDuration = EditorGUILayout.FloatField("emit duration:", ctarget.EmitDuration);
                ctarget.EmitRate     = EditorGUILayout.FloatField("emit rate:", ctarget.EmitRate);
                ctarget.EmitLoop     = EditorGUILayout.IntField("loop count(-1 is infinite):", ctarget.EmitLoop);
                ctarget.EmitDelay    = EditorGUILayout.FloatField("delay after each loop:", ctarget.EmitDelay);
            }
            else
            {
                ctarget.EmitterCurve = EditorGUILayout.CurveField("emit curve:", ctarget.EmitterCurve);
            }
            EditorGUILayout.EndVertical();
        }
    }
Example #5
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer layer = new EffectLayer("ETS2 Beacon Layer");

            if (gamestate is GameState_ETS2 && (gamestate as GameState_ETS2).Truck.lightsBeaconOn)
            {
                switch (this.Properties.BeaconStyle)
                {
                // Fades all assigned lights in and out together
                case ETS2_BeaconStyle.Simple_Flash:
                    double multiplier = Math.Pow(Math.Sin(frame * Properties.Speed * Math.PI / 10), 2);
                    layer.Set(Properties.Sequence, PrimaryColorAlpha(multiplier));
                    frame = (frame + 1) % (int)(10 / Properties.Speed);
                    break;

                // Flashes lights in a pattern similar to the ETS2 LED beacons
                // Pattern: ###------###------#-#-#----#-#-#----#-#-#---- [2x###------, 3x#-#-#----] (# = on, - = off)
                case ETS2_BeaconStyle.Fancy_Flash:
                    // To get the keyframe number we divide frame by 2 because it was too fast otherwise
                    int  m10 = (frame / 2) % 9;                   // Mod 10 of the keyframe (10 is the size of a group)
                    bool on  = (frame / 2) < 18
                            ? m10 < 4                             // When in one of the first two groups, light up for the first 4 keyframes of that group
                            : (m10 == 0 || m10 == 2 || m10 == 4); // When in the last 3 groups, light up if the keyframe is 0th, 2nd or 4th of that group

                    if (on)
                    {
                        layer.Set(Properties.Sequence, Properties.PrimaryColor);
                    }

                    frame = (frame + 1) % 90;     // 90 because there are 9 keyframes per group, 5 groups and each keyframe = 2 real frames (9 * 5 * 2)
                    break;

                // Sets half the sequence on and half off, then swaps. If odd number of keys, first half will be bigger
                case ETS2_BeaconStyle.Half_Alternating:
                    List <DeviceKeys> half;
                    if (frame < 5)
                    {
                        // First half
                        half = Properties.Sequence.keys.GetRange(0, (int)Math.Ceiling((double)Properties.Sequence.keys.Count / 2));
                    }
                    else
                    {
                        // Second half
                        half = Properties.Sequence.keys.GetRange((int)Math.Ceiling((double)Properties.Sequence.keys.Count / 2), (int)Math.Ceiling((double)Properties.Sequence.keys.Count / 2));
                    }

                    layer.Set(half.ToArray(), Properties.PrimaryColor);

                    frame = (frame + 1) % 10;
                    break;

                // The "on" key goes up and down the sequence
                case ETS2_BeaconStyle.Side_To_Side:
                    int keyCount = Properties.Sequence.keys.Count;

                    int light     = Math.Abs(((frame / 2 + 1) % (keyCount * 2 - 2)) - keyCount + 2);
                    int prevLight = Math.Abs(frame / 2 - keyCount + 2);
                    layer.Set(Properties.Sequence.keys[light], Properties.PrimaryColor);
                    layer.Set(Properties.Sequence.keys[prevLight], PrimaryColorAlpha(.5));

                    frame = (frame + 1) % ((keyCount - 1) * 4);     // *4 because we want the pattern to go up and down (*2), and also each keyframe should take 2 real frames
                    break;
                }
            }
            else    // When the beacon is off, reset the frame counter so that the animation plays from the start
            {
                frame = 0;
            }

            return(layer);
        }
Example #6
0
 public void MovingParticles( IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer, int unknown )
 {
     Effects.SendMovingParticles( this, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown );
 }
        public static void SendMovingParticles( IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer, int unknown )
        {
            if ( from is Mobile )
                ((Mobile)from).ProcessDelta();

            if ( to is Mobile )
                ((Mobile)to).ProcessDelta();

            Map map = from.Map;

            if ( map != null )
            {
                Packet particles = null, regular = null;

                IPooledEnumerable eable = map.GetClientsInRange( from.Location );

                foreach ( NetState state in eable )
                {
                    state.Mobile.ProcessDelta();

                    if ( SendParticlesTo( state ) )
                    {
                        if ( particles == null )
                            particles = Packet.Acquire( new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown ) );

                        state.Send( particles );
                    }
                    else if ( itemID > 1 )
                    {
                        if ( regular == null )
                            regular = Packet.Acquire( new MovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode ) );

                        state.Send( regular );
                    }
                }

                Packet.Release( particles );
                Packet.Release( regular );

                eable.Free();
            }

            //SendPacket( from.Location, from.Map, new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, unknown ) );
        }
Example #8
0
    protected void RibbonTrailConfig(EffectLayer ctarget)
    {
        DisplayRibbonConfig = EditorGUILayout.Foldout(DisplayRibbonConfig, "RibbonTrail Configuration");

        if (DisplayRibbonConfig)
        {
            EditorGUILayout.BeginVertical();
            ctarget.RibbonWidth = EditorGUILayout.FloatField("width:", ctarget.RibbonWidth);
            ctarget.MaxRibbonElements = EditorGUILayout.IntField("max elements:", ctarget.MaxRibbonElements);
            ctarget.RibbonLen = EditorGUILayout.FloatField("trail length:", ctarget.RibbonLen);
            ctarget.StretchType = EditorGUILayout.Popup("uv stretch type:", ctarget.StretchType,StretchTypes);
            EditorGUILayout.EndVertical();
        }
    }
Example #9
0
    protected void UVConfig(EffectLayer ctarget)
    {
        DisplayUVConfig = EditorGUILayout.Foldout(DisplayUVConfig, "UV Configuration");

        if (DisplayUVConfig)
        {
            EditorGUILayout.BeginVertical();
            ctarget.UVType = EditorGUILayout.Popup(ctarget.UVType, UVTypes);
            if (ctarget.UVType == 0)
            {
                ctarget.OriLowerLeftUV = EditorGUILayout.Vector2Field("original lower left uv:", ctarget.OriLowerLeftUV);
                ctarget.OriUVDimensions = EditorGUILayout.Vector2Field("original uv dimensions:", ctarget.OriUVDimensions);
                ctarget.UVAffectorEnable = false;
            }
            else if (ctarget.UVType == 1)
            {
                ctarget.Cols = EditorGUILayout.IntField("x tile:", ctarget.Cols);
                ctarget.Rows = EditorGUILayout.IntField("y tile:", ctarget.Rows);
                ctarget.UVTime = EditorGUILayout.FloatField("time(-1 means node life):", ctarget.UVTime);
                ctarget.LoopCircles = EditorGUILayout.IntField("loop(-1 means infinite):", ctarget.LoopCircles);
                ctarget.UVAffectorEnable = true;
            }
            else
            {// support in the future.
                ctarget.EanPath = EditorGUILayout.TextField("file name:", ctarget.EanPath);
                ctarget.EanIndex = EditorGUILayout.IntField("animation index", ctarget.EanIndex);
                ctarget.UVTime = EditorGUILayout.FloatField("animation time:", ctarget.UVTime);
                ctarget.LoopCircles = EditorGUILayout.IntField("loop(-1 means infinite):", ctarget.LoopCircles);
                ctarget.UVAffectorEnable = true;
            }
            EditorGUILayout.EndVertical();
        }
    }
Example #10
0
    public override void OnInspectorGUI()
    {
        XffectComponent ctarget = (XffectComponent)target;

        if (Application.isEditor && !EditorApplication.isPlaying)
        {
            EditorApplication.update = ctarget.Update;
        }

        EditorGUILayout.BeginVertical();
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        ctarget.LifeTime = EditorGUILayout.FloatField("life:", ctarget.LifeTime);
        EditorGUILayout.LabelField("[life -1 means infinite.]");

        EditorGUILayout.Separator();

        ctarget.Scale = EditorGUILayout.FloatField("scale:", ctarget.Scale);
        EditorGUILayout.Separator();

        if (GUILayout.Button("Add Layer"))
        {
            GameObject  layer = new GameObject(LayerName);
            EffectLayer efl   = (EffectLayer)layer.AddComponent("EffectLayer");
            layer.transform.parent = Selection.activeTransform;

            efl.transform.localPosition = Vector3.zero;
            //fixed 2012.6.25. default to effect layer object.
            efl.ClientTransform  = efl.transform;
            efl.GravityObject    = efl.transform;
            efl.BombObject       = efl.transform;
            efl.TurbulenceObject = efl.transform;
            efl.AirObject        = efl.transform;
            efl.VortexObj        = efl.transform;
            efl.DirCenter        = efl.transform;
        }

        EditorGUILayout.Separator();
        ctarget.EditView = EditorGUILayout.Toggle("update in editor?", ctarget.EditView);

        //prevent asset inspector to update.
        if (ctarget.EditView == true)
        {
            if (ctarget.gameObject.active == false)
            {
                ctarget.EditView = false;
                Debug.LogWarning("you should set the xffect object: " + ctarget.gameObject.name + " to active before update it.");
            }
        }

        if (ctarget.EditView)
        {
            ctarget.EnableEditView();
        }
        else
        {
            ctarget.DisableEditView();
        }

        if (ctarget.EditView)
        {
            if (GUILayout.Button("Reset Editor Xffect"))
            {
                ctarget.ResetEditScene();
            }
        }
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Example #11
0
    protected void EmitterConfig(EffectLayer ctarget)
    {
        DisplayEmitterConfig = EditorGUILayout.Foldout(DisplayEmitterConfig, "Emitter Configuration");

        if (DisplayEmitterConfig)
        {
            EditorGUILayout.BeginVertical();

            ctarget.EmitType = EditorGUILayout.Popup("emitter type:", ctarget.EmitType, EmitTypes);
            if (ctarget.EmitType == 0)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("emit position:", ctarget.EmitPoint);
            }
            else if (ctarget.EmitType == 1)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("box center:", ctarget.EmitPoint);
                ctarget.BoxSize = EditorGUILayout.Vector3Field("box size:", ctarget.BoxSize);
            }
            else if (ctarget.EmitType == 2)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("sphere center:", ctarget.EmitPoint);
                ctarget.Radius = EditorGUILayout.FloatField("radius:", ctarget.Radius);
            }
            else if (ctarget.EmitType == 3)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("circle center:", ctarget.EmitPoint);
                ctarget.CircleDir = EditorGUILayout.Vector3Field("circle direction:", ctarget.CircleDir);
                ctarget.Radius = EditorGUILayout.FloatField("radius:", ctarget.Radius);
            }
            else if (ctarget.EmitType == 4)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("line center:", ctarget.EmitPoint);
                ctarget.LineLengthLeft = EditorGUILayout.FloatField("line left length:", ctarget.LineLengthLeft);
                ctarget.LineLengthRight = EditorGUILayout.FloatField("line right length:", ctarget.LineLengthRight);
            }
            EditorGUILayout.Space();

            ctarget.MaxENodes = EditorGUILayout.IntField("max nodes:", ctarget.MaxENodes);
            ctarget.IsNodeLifeLoop = EditorGUILayout.Toggle("is node life loop:", ctarget.IsNodeLifeLoop);
            if (!ctarget.IsNodeLifeLoop)
            {
                ctarget.NodeLifeMin = EditorGUILayout.FloatField("node life min:", ctarget.NodeLifeMin);
                ctarget.NodeLifeMax = EditorGUILayout.FloatField("node life max:", ctarget.NodeLifeMax);
            }

            ctarget.IsEmitByDistance = EditorGUILayout.Toggle("emit by distance:", ctarget.IsEmitByDistance);
            if (ctarget.IsEmitByDistance)
            {
                ctarget.DiffDistance = EditorGUILayout.FloatField("diff distance:", ctarget.DiffDistance);
            }
            else
            {
                ctarget.ChanceToEmit = EditorGUILayout.Slider("chance to emit per loop:", ctarget.ChanceToEmit, 1, 100);
                ctarget.EmitDuration = EditorGUILayout.FloatField("emit duration:", ctarget.EmitDuration);
                ctarget.EmitRate = EditorGUILayout.IntField("emit rate,based on emit duration:", ctarget.EmitRate);
                ctarget.EmitLoop = EditorGUILayout.IntField("emit loop count,-1 means forever:", ctarget.EmitLoop);
                ctarget.EmitDelay = EditorGUILayout.FloatField("delay after each loop:", ctarget.EmitDelay);
            }
            EditorGUILayout.EndVertical();
        }
    }
Example #12
0
        public override EffectLayer Render(IGameState gamestate)
        {
            try
            {
                //if (current_device != null)
                //current_device.Dispose();
                CheckForDeviceChange();

                // The system sound as a value between 0.0 and 1.0
                float system_sound_normalized = default_device.AudioEndpointVolume.MasterVolumeLevelScalar;

                // Scale the Maximum amplitude with the system sound if enabled, so that at 100% volume the max_amp is unchanged.
                // Replaces all Properties.MaxAmplitude calls with the scaled value
                float scaled_max_amplitude = Properties.MaxAmplitude * (Properties.ScaleWithSystemVolume ? system_sound_normalized : 1);

                float[] freqs = Properties.Frequencies.ToArray(); //Defined Frequencies

                double[] freq_results = new double[freqs.Length];

                if (previous_freq_results == null || previous_freq_results.Length < freqs.Length)
                {
                    previous_freq_results = new float[freqs.Length];
                }

                //Maintain local copies of fft, to prevent data overwrite
                Complex[] _local_fft          = new List <Complex>(_ffts).ToArray();
                Complex[] _local_fft_previous = new List <Complex>(_ffts_prev).ToArray();

                EffectLayer equalizer_layer = new EffectLayer();

                bool BgEnabled = false;
                switch (Properties.BackgroundMode)
                {
                case EqualizerBackgroundMode.EnabledOnSound:
                    foreach (var bin in _local_fft)
                    {
                        if (bin.X > 0.0005 || bin.X < -0.0005)
                        {
                            BgEnabled = true;
                            break;
                        }
                    }
                    break;

                case EqualizerBackgroundMode.AlwaysOn:
                    BgEnabled = true;
                    break;
                }

                // The region in which to draw the equalizer.
                var rect = Properties.Sequence.GetAffectedRegion(); //new RectangleF(0, 0, Effects.canvas_width, Effects.canvas_height);
                if (rect.Width == 0 || rect.Height == 0)
                {
                    // No region to draw in, prevents filling log with exceptions
                    return(new EffectLayer());
                }

                if (BgEnabled)
                {
                    equalizer_layer.Set(Properties.Sequence, Properties.DimColor);
                }

                using (Graphics g = equalizer_layer.GetGraphics())
                {
                    g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;

                    int wave_step_amount = _local_fft.Length / (int)rect.Width;

                    switch (Properties.EQType)
                    {
                    case EqualizerType.Waveform:
                        for (int x = 0; x < (int)rect.Width; x++)
                        {
                            float fft_val = _local_fft.Length > x * wave_step_amount ? _local_fft[x * wave_step_amount].X : 0.0f;

                            Brush brush = GetBrush(fft_val, x, rect.Width);

                            g.DrawLine(new Pen(brush), x + rect.X, (rect.Height / 2) + rect.Y, x + rect.X, (rect.Height / 2) + rect.Y - Math.Max(Math.Min(fft_val / scaled_max_amplitude * 500.0f, rect.Height / 2), -rect.Height / 2));
                        }
                        break;

                    case EqualizerType.Waveform_Bottom:
                        for (int x = 0; x < (int)rect.Width; x++)
                        {
                            float fft_val = _local_fft.Length > x * wave_step_amount ? _local_fft[x * wave_step_amount].X : 0.0f;

                            Brush brush = GetBrush(fft_val, x, rect.Width);

                            g.DrawLine(new Pen(brush), x + rect.X, rect.Height + rect.Y, x + rect.X, rect.Height + rect.Y - Math.Min(Math.Abs(fft_val / scaled_max_amplitude) * 1000.0f, rect.Height));
                        }
                        break;

                    case EqualizerType.PowerBars:

                        //Perform FFT again to get frequencies
                        FastFourierTransform.FFT(false, (int)Math.Log(fftLength, 2.0), _local_fft);

                        while (flux_array.Count < freqs.Length)
                        {
                            flux_array.Add(0.0f);
                        }

                        int startF = 0;
                        int endF   = 0;

                        float threshhold = 300.0f;

                        for (int x = 0; x < freqs.Length - 1; x++)
                        {
                            startF = freqToBin(freqs[x]);
                            endF   = freqToBin(freqs[x + 1]);

                            float flux = 0.0f;

                            for (int j = startF; j <= endF; j++)
                            {
                                float curr_fft = (float)Math.Sqrt(_local_fft[j].X * _local_fft[j].X + _local_fft[j].Y * _local_fft[j].Y);
                                float prev_fft = (float)Math.Sqrt(_local_fft_previous[j].X * _local_fft_previous[j].X + _local_fft_previous[j].Y * _local_fft_previous[j].Y);

                                float value     = curr_fft - prev_fft;
                                float flux_calc = (value + Math.Abs(value)) / 2;
                                if (flux < flux_calc)
                                {
                                    flux = flux_calc;
                                }

                                flux = flux > threshhold ? 0.0f : flux;
                            }

                            flux_array[x] = flux;
                        }

                        //System.Diagnostics.Debug.WriteLine($"flux max: {flux_array.Max()}");

                        float bar_width = rect.Width / (float)(freqs.Length - 1);

                        for (int f_x = 0; f_x < freq_results.Length - 1; f_x++)
                        {
                            float fft_val = flux_array[f_x] / scaled_max_amplitude;

                            fft_val = Math.Min(1.0f, fft_val);

                            if (previous_freq_results[f_x] - fft_val > 0.10)
                            {
                                fft_val = previous_freq_results[f_x] - 0.15f;
                            }

                            float x      = (f_x * bar_width) + rect.X;
                            float y      = rect.Height + rect.Y;
                            float height = fft_val * rect.Height;

                            previous_freq_results[f_x] = fft_val;

                            Brush brush = GetBrush(-(f_x % 2), f_x, freq_results.Length - 1);

                            g.FillRectangle(brush, x, y - height, bar_width, height);
                        }

                        break;
                    }
                }

                var hander = NewLayerRender;
                if (hander != null)
                {
                    hander.Invoke(equalizer_layer.GetBitmap());
                }
                return(equalizer_layer);
            }
            catch (Exception exc)
            {
                Global.logger.Error("Error encountered in the Equalizer layer. Exception: " + exc.ToString());
                return(new EffectLayer());
            }
        }
Example #13
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer bg_layer = new EffectLayer("Payday 2 - Background");

            if (state is GameState_PD2)
            {
                GameState_PD2 pd2 = (GameState_PD2)state;

                Color bg_color = Properties.AmbientColor;

                long currenttime = Utils.Time.GetMillisecondsSinceEpoch();

                if ((pd2.Level.Phase == LevelPhase.Assault || pd2.Level.Phase == LevelPhase.Winters) && pd2.Game.State == GameStates.Ingame)
                {
                    if (pd2.Level.Phase == LevelPhase.Assault)
                    {
                        bg_color = Properties.AssaultColor;
                    }
                    else if (pd2.Level.Phase == LevelPhase.Winters)
                    {
                        bg_color = Properties.WintersColor;
                    }

                    double blend_percent = Math.Pow(Math.Sin(((currenttime % 1300L) / 1300.0D) * Properties.AssaultSpeedMultiplier * 2.0D * Math.PI), 2.0D);

                    bg_color = Utils.ColorUtils.BlendColors(Properties.AssaultFadeColor, bg_color, blend_percent);

                    if (Properties.AssaultAnimationEnabled)
                    {
                        Color effect_contours            = Color.FromArgb(200, Color.Black);
                        float animation_stage_yoffset    = 20.0f;
                        float animation_repeat_keyframes = 250.0f; //Effects.canvas_width * 2.0f;

                        /* Effect visual:
                         *
                         * / /  ----  / /
                         *
                         */

                        /*
                         * !!!NOTE: TO BE REWORKED INTO ANIMATIONS!!!
                         *
                         * EffectColorFunction line1_col_func = new EffectColorFunction(
                         *  new EffectLine(-1f, Effects.canvas_width + assault_yoffset + animation_stage_yoffset),
                         *  new ColorSpectrum(effect_contours),
                         *  2);
                         *
                         * EffectColorFunction line2_col_func = new EffectColorFunction(
                         *  new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 9.0f + animation_stage_yoffset),
                         *  new ColorSpectrum(effect_contours),
                         *  2);
                         *
                         * EffectColorFunction line3_col_func = new EffectColorFunction(
                         *  new EffectLine(new EffectPoint(Effects.canvas_width + assault_yoffset + 17.0f + animation_stage_yoffset, Effects.canvas_height / 2.0f), new EffectPoint(Effects.canvas_width + assault_yoffset + 34.0f + animation_stage_yoffset, Effects.canvas_height / 2.0f), true),
                         *  new ColorSpectrum(effect_contours),
                         *  6);
                         *
                         * EffectColorFunction line4_col_func = new EffectColorFunction(
                         *  new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 52.0f + animation_stage_yoffset),
                         *  new ColorSpectrum(effect_contours),
                         *  2);
                         *
                         * EffectColorFunction line5_col_func = new EffectColorFunction(
                         *  new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 61.0f + animation_stage_yoffset),
                         *  new ColorSpectrum(effect_contours),
                         *  2);
                         *
                         * assault_yoffset -= 0.50f;
                         * assault_yoffset = assault_yoffset % animation_repeat_keyframes;
                         *
                         * bg_layer.AddPostFunction(line1_col_func);
                         * bg_layer.AddPostFunction(line2_col_func);
                         * //bg_layer.AddPostFunction(line3_col_func);
                         * bg_layer.AddPostFunction(line4_col_func);
                         * bg_layer.AddPostFunction(line5_col_func);
                         *
                         */
                    }

                    bg_layer.Fill(bg_color);

                    if (Properties.PeripheralUse)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                    }
                }
                else if (pd2.Level.Phase == LevelPhase.Stealth && pd2.Game.State == GameStates.Ingame)
                {
                    if (Properties.ShowSuspicion)
                    {
                        double percentSuspicious = ((double)pd2.Players.LocalPlayer.SuspicionAmount / (double)1.0);

                        ColorSpectrum suspicion_spec = new ColorSpectrum(Properties.LowSuspicionColor, Properties.HighSuspicionColor);
                        suspicion_spec.SetColorAt(0.5f, Properties.MediumSuspicionColor);

                        Settings.KeySequence suspicionSequence = new Settings.KeySequence(new Settings.FreeFormObject(0, 0, 1.0f / (Effects.editor_to_canvas_width / Effects.canvas_width), 1.0f / (Effects.editor_to_canvas_height / Effects.canvas_height)));

                        bg_layer.PercentEffect(suspicion_spec, suspicionSequence, percentSuspicious, 1.0D, Properties.SuspicionEffectType);

                        if (Properties.PeripheralUse)
                        {
                            bg_layer.Set(Devices.DeviceKeys.Peripheral, suspicion_spec.GetColorAt((float)percentSuspicious));
                        }
                    }
                }
                else if (pd2.Level.Phase == LevelPhase.Point_of_no_return && pd2.Game.State == GameStates.Ingame)
                {
                    ColorSpectrum no_return_spec = new ColorSpectrum(Color.Red, Color.Yellow);
                    if (pd2.Level.NoReturnTime != no_return_timeleft)
                    {
                        no_return_timeleft    = pd2.Level.NoReturnTime;
                        no_return_flashamount = 1.0f;
                    }

                    Color no_return_color = no_return_spec.GetColorAt(no_return_flashamount);
                    no_return_flashamount -= 0.05f;

                    if (no_return_flashamount < 0.0f)
                    {
                        no_return_flashamount = 0.0f;
                    }

                    bg_layer.Fill(no_return_color);

                    if (Properties.PeripheralUse)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, no_return_color);
                    }
                }
                else
                {
                    bg_layer.Fill(bg_color);

                    if (Properties.PeripheralUse)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                    }
                }
            }

            return(bg_layer);
        }
        public override EffectLayer Render(IGameState state)
        {
            GameState_EliteDangerous gameState = state as GameState_EliteDangerous;

            GSI.Nodes.Controls controls = (state as GameState_EliteDangerous).Controls;

            EffectLayer          keyBindsLayer       = new EffectLayer("Elite: Dangerous - Key Binds");
            HashSet <DeviceKeys> leftoverBlendStates = new HashSet <DeviceKeys>(keyBlendStates.Keys);

            long currentTime = Utils.Time.GetMillisecondsSinceEpoch();

            if (gameState.Journal.fsdWaitingCooldown && gameState.Status.IsFlagSet(Flag.FSD_COOLDOWN))
            {
                gameState.Journal.fsdWaitingCooldown = false;
            }

            if (gameState.Journal.fsdWaitingSupercruise && gameState.Status.IsFlagSet(Flag.SUPERCRUISE))
            {
                gameState.Journal.fsdWaitingSupercruise = false;
            }

            Color newKeyColor;
            Dictionary <DeviceKeys, Color> smoothColorSets = new Dictionary <DeviceKeys, Color>();

            foreach (ControlGroupSet controlGroupSet in controlGroupSets)
            {
                if (!controlGroupSet.IsSatisfied(gameState))
                {
                    continue;
                }

                foreach (ControlGroup controlGroup in controlGroupSet.controlGroups)
                {
                    if (!controlGroup.IsSatisfied(gameState))
                    {
                        continue;
                    }

                    foreach (string command in controlGroup.commands)
                    {
                        if (!controls.commandToBind.ContainsKey(command))
                        {
                            continue;
                        }

                        bool keyWithEffect = KeyPresets.KEY_EFFECTS.ContainsKey(command);

                        foreach (Bind.Mapping mapping in controls.commandToBind[command].mappings)
                        {
                            bool allModifiersPressed = true;
                            foreach (DeviceKeys modifierKey in mapping.modifiers)
                            {
                                SetKey(keyBindsLayer, modifierKey, Properties.ShipStuffColor);
                                leftoverBlendStates.Remove(modifierKey);
                                if (Array.IndexOf(
                                        Global.InputEvents.PressedKeys,
                                        KeyUtils.GetFormsKey(modifierKey)
                                        ) == -1)
                                {
                                    allModifiersPressed = false;
                                    break;
                                }
                            }

                            if (!allModifiersPressed)
                            {
                                continue;
                            }

                            newKeyColor = Properties.GetColorByGroupName(
                                controlGroup.colorGroupName ?? CommandColors.GetColorGroupForCommand(command)
                                );

                            if (keyWithEffect)
                            {
                                SetKey(keyBindsLayer, mapping.key, KeyPresets.KEY_EFFECTS[command](newKeyColor, gameState, currentTime));
                            }
                            else
                            {
                                smoothColorSets[mapping.key] = newKeyColor;
                            }

                            leftoverBlendStates.Remove(mapping.key);
                        }
                    }
                }
            }

            //Apply smooth transitions for keys
            foreach (KeyValuePair <DeviceKeys, Color> smoothKey in smoothColorSets)
            {
                SetKeySmooth(keyBindsLayer, smoothKey.Key, smoothKey.Value);
            }

            //Fade out inactive keys
            foreach (DeviceKeys key in leftoverBlendStates)
            {
                SetKeySmooth(keyBindsLayer, key, Color.Empty);
            }

            return(keyBindsLayer);
        }
        public override EffectLayer Render(IGameState state)
        {
            GameState_EliteDangerous gameState = state as GameState_EliteDangerous;

            previousTime = currentTime;
            currentTime  = Time.GetMillisecondsSinceEpoch();

            EffectLayer animation_layer = new EffectLayer("Elite: Dangerous - Animations");

            if (gameState.Journal.ExitStarClass != StarClass.None)
            {
                RegenerateHyperspaceExitAnimation(gameState.Journal.ExitStarClass);
                gameState.Journal.ExitStarClass = StarClass.None;
                animateOnce        = EliteAnimation.HyperspaceExit;
                totalAnimationTime = 0;
                animationKeyframe  = 0;
            }

            if (animateOnce != EliteAnimation.None)
            {
                currentAnimation = animateOnce;
            }
            else if (gameState.Journal.fsdState == FSDState.Idle)
            {
                currentAnimation = EliteAnimation.None;
            }
            else if (gameState.Journal.fsdState == FSDState.CountdownSupercruise || gameState.Journal.fsdState == FSDState.CountdownHyperspace)
            {
                currentAnimation = EliteAnimation.FsdCountdowm;
            }
            else if (gameState.Journal.fsdState == FSDState.InHyperspace)
            {
                currentAnimation = EliteAnimation.Hyperspace;
            }

            if (currentAnimation == EliteAnimation.None)
            {
                animationKeyframe  = 0;
                totalAnimationTime = 0;
            }

            if ((currentAnimation != EliteAnimation.None && currentAnimation != EliteAnimation.HyperspaceExit) || gameState.Journal.fsdWaitingSupercruise)
            {
                BgFadeIn(animation_layer);
            }
            else if (layerFadeState > 0)
            {
                BgFadeOut(animation_layer);
            }

            float deltaTime = 0f, currentAnimationDuration = 0f;

            if (currentAnimation == EliteAnimation.FsdCountdowm)
            {
                currentAnimationDuration = fsd_countdown_mix.GetDuration();
                fsd_countdown_mix.Draw(animation_layer.GetGraphics(), animationKeyframe);
                deltaTime          = getDeltaTime();
                animationKeyframe += deltaTime;
            }
            else if (currentAnimation == EliteAnimation.Hyperspace)
            {
                currentAnimationDuration = hyperspace_mix.GetDuration();
                hyperspace_mix.Draw(animation_layer.GetGraphics(), animationKeyframe);
                hyperspace_mix.Draw(animation_layer.GetGraphics(), findMod(animationKeyframe + 1.2f, currentAnimationDuration));
                hyperspace_mix.Draw(animation_layer.GetGraphics(), findMod(animationKeyframe + 2.8f, currentAnimationDuration));
                deltaTime = getDeltaTime();
                //Loop the animation
                animationKeyframe = findMod(animationKeyframe + (deltaTime), currentAnimationDuration);
            }
            else if (currentAnimation == EliteAnimation.HyperspaceExit)
            {
                currentAnimationDuration = hypespace_exit_mix.GetDuration();
                hypespace_exit_mix.Draw(animation_layer.GetGraphics(), animationKeyframe);
                deltaTime = getDeltaTime();

                animationKeyframe += deltaTime;
            }

            totalAnimationTime += deltaTime;
            if (totalAnimationTime > currentAnimationDuration)
            {
                animateOnce = EliteAnimation.None;
            }

            return(animation_layer);
        }
 private void BgFadeIn(EffectLayer animation_layer)
 {
     layerFadeState = Math.Min(1, layerFadeState + 0.07f);
     animation_layer.Fill(ColorUtils.BlendColors(Color.Empty, Color.Black, layerFadeState));
 }
    void DoPatch440(EffectLayer layer)
    {
        if (layer.IsRandomStartColor)
        {
            XEditorTool.PatchColorGradient(layer.RandomColorParam, layer.RandomColorGradient);
        }

        if (layer.ColorChangeType == COLOR_CHANGE_TYPE.Gradient)
        {
            XEditorTool.PatchColorGradient(layer.ColorParam, layer.ColorGradient);
        }

    }
Example #18
0
 public static void SendTargetParticles(IEntity target, int itemID, int speed, int duration, int hue, int renderMode, int effect, EffectLayer layer)
 {
     SendTargetParticles(target, itemID, speed, duration, hue, renderMode, effect, layer, 0);
 }
Example #19
0
    protected void AttractionAffectorConfig(EffectLayer ctarget)
    {
        DisplayAttractionAffectorConfig = EditorGUILayout.Foldout(DisplayAttractionAffectorConfig, "Attraction Affector Configuration");
        if (DisplayAttractionAffectorConfig)
        {
            EditorGUILayout.BeginVertical();
            ctarget.UseAttractCurve = EditorGUILayout.Toggle("use curve?", ctarget.UseAttractCurve);
            if (ctarget.UseAttractCurve)
            {
                ctarget.AttractionCurve = EditorGUILayout.CurveField("curve:", ctarget.AttractionCurve);
                ctarget.AttractionPosition = EditorGUILayout.Vector3Field("attraction position:", ctarget.AttractionPosition);
            }
            else
            {
                ctarget.AttractMag = EditorGUILayout.FloatField("magnitude:", ctarget.AttractMag);
                ctarget.AttractionPosition = EditorGUILayout.Vector3Field("attraction position:", ctarget.AttractionPosition);
            }

            EditorGUILayout.EndVertical();
        }
    }
Example #20
0
    //in editor mode, Awake() method called twice, why?.
    public void Initialize()
    {
        if (EflList.Count > 0)
        {//already inited.
            return;
        }
        //fixed : 2012.5.25. can't add child game object during foreach..
        //ArrayList tobeAdded = new ArrayList();

        foreach (Transform child in transform)
        {
            EffectLayer el = (EffectLayer)child.GetComponent(typeof(EffectLayer));
            if (el == null)
            {
                continue;
            }

            if (el.Material == null)
            {
                Debug.LogWarning("effect layer: " + el.gameObject.name + " has no material, please assign a material first!");
                continue;
            }

            //SetActive(el.gameObject,true);

            Material mat = el.Material;
            //ver 1.2.1
            mat.renderQueue  = mat.shader.renderQueue;
            mat.renderQueue += el.Depth;
            EflList.Add(el);
            MeshFilter   Meshfilter;
            MeshRenderer Meshrenderer;

            Transform oldMesh = transform.Find("xftmesh " + mat.name);
            if (oldMesh != null)
            {//already instaniate by object cache.just recreate vertex pool.\
                Meshfilter            = (MeshFilter)oldMesh.GetComponent(typeof(MeshFilter));
                Meshrenderer          = (MeshRenderer)oldMesh.GetComponent(typeof(MeshRenderer));
                Meshfilter.sharedMesh = new Mesh();
                Meshfilter.sharedMesh.Clear();
                MatDic[mat.name] = new VertexPool(Meshfilter.sharedMesh, mat);
                //fixed 2012.7.20 if already exist, Add to MeshList too.
                if (!MeshList.Contains(oldMesh.gameObject))
                {
                    MeshList.Add(oldMesh.gameObject);
                }
            }
            if (!MatDic.ContainsKey(mat.name))
            {
                GameObject obj = new GameObject("xftmesh " + mat.name);
                //obj.layer = gameObject.layer;
                obj.layer = el.gameObject.layer;
                //obj.transform.parent = this.transform;
                //tobeAdded.Add(obj);
                MeshList.Add(obj);
                obj.AddComponent <MeshFilter>();
                obj.AddComponent <MeshRenderer>();
                SetActive(obj, IsActive(gameObject));

#if UNITY_EDITOR
                if (!EditorApplication.isPlaying)
                {
                    XffectComponent.SetActive(obj, true);
                }
#endif


                Meshfilter                  = (MeshFilter)obj.GetComponent(typeof(MeshFilter));
                Meshrenderer                = (MeshRenderer)obj.GetComponent(typeof(MeshRenderer));
                Meshrenderer.castShadows    = false;
                Meshrenderer.receiveShadows = false;
                Meshrenderer.GetComponent <Renderer>().sharedMaterial = mat;
                Meshfilter.sharedMesh = new Mesh();
                MatDic[mat.name]      = new VertexPool(Meshfilter.sharedMesh, mat);
            }
        }

        //now set each gameobject's parent.
        foreach (GameObject obj in MeshList)
        {
            obj.transform.parent = this.transform;

            //fixed 2012.6.25,
            obj.transform.position = Vector3.zero;
            obj.transform.rotation = Quaternion.identity;

            //fixed 2012.7.11, avoid the lossy scale influence the mesh object.
            Vector3 realLocalScale = Vector3.zero;
            realLocalScale.x = 1 / obj.transform.parent.lossyScale.x;
            realLocalScale.y = 1 / obj.transform.parent.lossyScale.y;
            realLocalScale.z = 1 / obj.transform.parent.lossyScale.z;

            obj.transform.localScale = realLocalScale * Scale;
        }


        //start each effect layer.
        foreach (EffectLayer efl in EflList)
        {
            efl.Vertexpool = MatDic[efl.Material.name];
        }
        //this.transform.position = Vector3.zero;
        //this.transform.rotation = Quaternion.identity;
        this.transform.localScale = Vector3.one;

        foreach (EffectLayer el in EflList)
        {
            el.StartCustom();
        }

        //add events
        EventList.Clear();
        foreach (Transform child in transform)
        {
            XftEventComponent xftevent = child.GetComponent <XftEventComponent>();
            if (xftevent == null)
            {
                continue;
            }
            EventList.Add(xftevent);
            xftevent.Initialize();
        }
        Initialized = true;
    }
Example #21
0
 protected void LinearForceAffectorConfig(EffectLayer ctarget)
 {
     DisplayLinearForceAffectorConfig = EditorGUILayout.Foldout(DisplayLinearForceAffectorConfig, "Linear Force Affector Configuration");
     if (DisplayLinearForceAffectorConfig)
     {
         EditorGUILayout.BeginVertical();
         ctarget.LinearForce = EditorGUILayout.Vector3Field("linear force:", ctarget.LinearForce);
         ctarget.LinearMagnitude = EditorGUILayout.FloatField("magnitude:", ctarget.LinearMagnitude);
         EditorGUILayout.EndVertical();
     }
 }
Example #22
0
    public void Update()
    {
        CurTime = Time.realtimeSinceStartup;
#if UNITY_EDITOR
        if (!EditorApplication.isPlaying)
        {
            if (!EditView)
            {
                return;
            }
            CurTime = EditorApplication.timeSinceStartup;
            if (!CheckEditModeInited())
            {
                ResetEditScene();
            }
        }
#endif
        float deltaTime = (float)(CurTime - LastTime);
        if (deltaTime < 0.0333f)  //Lower Update Rate
        {
            return;
        }

        //simple method to check game delay: the game must run above 20 FPS.
        if (deltaTime > 0.05f)
        {
            //deltaTime = 0.0333f;
            deltaTime = 0.05f;
        }

        if (!IgnoreTimeScale)
        {
            deltaTime *= Time.timeScale;
        }

        ElapsedTime += deltaTime;

        for (int i = 0; i < EflList.Count; i++)
        {
            if (EflList[i] == null)            //be destroyed?
            {
                return;
            }
            EffectLayer el = EflList[i];
            if (ElapsedTime > el.StartTime && IsActive(el.gameObject))
            {
                el.FixedUpdateCustom(deltaTime);
            }
        }


        for (int i = 0; i < EventList.Count; i++)
        {
            XftEventComponent e = EventList[i];
            if (IsActive(e.gameObject))
            {
                e.UpdateCustom(deltaTime);
            }
        }

        LastTime = CurTime;

#if UNITY_EDITOR
        if (!EditorApplication.isPlaying)
        {
            LateUpdate();
        }
#endif
    }
Example #23
0
    protected void ScaleConfig(EffectLayer ctarget)
    {
        DisplayScaleConfig = EditorGUILayout.Foldout(DisplayScaleConfig, "Scale Configuration");

        if (DisplayScaleConfig)
        {
            EditorGUILayout.BeginVertical();
            ctarget.RandomOriScale = EditorGUILayout.Toggle("random original scale?", ctarget.RandomOriScale);
            if (ctarget.RandomOriScale)
            {
                ctarget.OriScaleXMin  = EditorGUILayout.FloatField("original x scale min:", ctarget.OriScaleXMin);
                ctarget.OriScaleXMax = EditorGUILayout.FloatField("original x scale max:", ctarget.OriScaleXMax);
                EditorGUILayout.Space();
                ctarget.OriScaleYMin = EditorGUILayout.FloatField("original y scale min:", ctarget.OriScaleYMin);
                ctarget.OriScaleYMax = EditorGUILayout.FloatField("original y scale max:", ctarget.OriScaleYMax);
            }
            else
            {
                ctarget.OriScaleXMin = EditorGUILayout.FloatField("original x scale:", ctarget.OriScaleXMin);
                ctarget.OriScaleYMin = EditorGUILayout.FloatField("original y scale:", ctarget.OriScaleYMin);
                ctarget.OriScaleXMax = ctarget.OriScaleXMin;
                ctarget.OriScaleYMax = ctarget.OriScaleYMin;
            }
            EditorGUILayout.Space();
            ctarget.ScaleType = (RSTYPE)EditorGUILayout.Popup("scale change type:", (int)ctarget.ScaleType, ScaleTypes);
            if (ctarget.ScaleType == RSTYPE.NONE)
            {
                ctarget.ScaleAffectorEnable = false;
            }
            else if (ctarget.ScaleType == RSTYPE.SIMPLE)
            {
                ctarget.ScaleAffectorEnable = true;
                ctarget.DeltaScaleX = EditorGUILayout.FloatField("delta scaleX per second:", ctarget.DeltaScaleX);
                ctarget.DeltaScaleY = EditorGUILayout.FloatField("delta scaleY per second:", ctarget.DeltaScaleY);
            }
            else
            {
                ctarget.ScaleAffectorEnable = true;
                ctarget.ScaleXCurve = EditorGUILayout.CurveField("scaleX curve:", ctarget.ScaleXCurve);
                ctarget.ScaleYCurve = EditorGUILayout.CurveField("scaleY curve:", ctarget.ScaleYCurve);
            }
            EditorGUILayout.EndVertical();
        }
    }
Example #24
0
        public static void SendMovingParticles(
            IEntity from,
            IEntity to,
            int itemID,
            int speed,
            int duration,
            bool fixedDirection,
            bool explodes,
            int hue,
            int renderMode,
            int effect,
            int explodeEffect,
            int explodeSound,
            EffectLayer layer,
            int unknown)
        {
            if (from is Mobile)
            {
                ((Mobile)from).ProcessDelta();
            }

            if (to is Mobile)
            {
                ((Mobile)to).ProcessDelta();
            }

            Map map = from.Map;

            if (map != null)
            {
                Packet particles = null, regular = null;

                var eable = map.GetClientsInRange(from.Location);

                foreach (NetState state in eable)
                {
                    state.Mobile.ProcessDelta();

                    if (SendParticlesTo(state))
                    {
                        if (particles == null)
                        {
                            particles =
                                Packet.Acquire(
                                    new MovingParticleEffect(
                                        from,
                                        to,
                                        itemID,
                                        speed,
                                        duration,
                                        fixedDirection,
                                        explodes,
                                        hue,
                                        renderMode,
                                        effect,
                                        explodeEffect,
                                        explodeSound,
                                        layer,
                                        unknown));
                        }

                        state.Send(particles);
                    }
                    else if (itemID > 1)
                    {
                        if (regular == null)
                        {
                            regular =
                                Packet.Acquire(new MovingEffect(from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode));
                        }

                        state.Send(regular);
                    }
                }

                Packet.Release(particles);
                Packet.Release(regular);

                eable.Free();
            }

            //SendPacket( from.Location, from.Map, new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, unknown ) );
        }
Example #25
0
 public void FixedParticles( int itemID, int speed, int duration, int effect, int hue, int renderMode, EffectLayer layer )
 {
     Effects.SendTargetParticles( this, itemID, speed, duration, hue, renderMode, effect, layer, 0 );
 }
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer sirens_layer = new EffectLayer("GTA 5 - Police Sirens");

            if (state is GameState_GTA5)
            {
                GameState_GTA5 gta5state = state as GameState_GTA5;

                if (gta5state.HasCops)
                {
                    if (left_siren_color != gta5state.LeftSirenColor && right_siren_color != gta5state.RightSirenColor)
                    {
                        siren_keyframe++;
                    }

                    left_siren_color  = gta5state.LeftSirenColor;
                    right_siren_color = gta5state.RightSirenColor;

                    Color lefts  = Properties.LeftSirenColor;
                    Color rights = Properties.RightSirenColor;

                    //Switch sirens
                    switch (Properties.SirenType)
                    {
                    case GTA5_PoliceEffects.Alt_Full:
                        switch (siren_keyframe % 2)
                        {
                        case 1:
                            rights = lefts;
                            break;

                        default:
                            lefts = rights;
                            break;
                        }
                        siren_keyframe = siren_keyframe % 2;

                        if (Properties.PeripheralUse)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                        }
                        break;

                    case GTA5_PoliceEffects.Alt_Half:
                        switch (siren_keyframe % 2)
                        {
                        case 1:
                            rights = lefts;
                            lefts  = Color.Black;

                            if (Properties.PeripheralUse)
                            {
                                sirens_layer.Set(Devices.DeviceKeys.Peripheral, rights);
                            }
                            break;

                        default:
                            lefts  = rights;
                            rights = Color.Black;

                            if (Properties.PeripheralUse)
                            {
                                sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                            }
                            break;
                        }
                        siren_keyframe = siren_keyframe % 2;
                        break;

                    case GTA5_PoliceEffects.Alt_Full_Blink:
                        switch (siren_keyframe % 4)
                        {
                        case 2:
                            rights = lefts;
                            break;

                        case 0:
                            lefts = rights;
                            break;

                        default:
                            lefts  = Color.Black;
                            rights = Color.Black;
                            break;
                        }
                        siren_keyframe = siren_keyframe % 4;

                        if (Properties.PeripheralUse)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                        }
                        break;

                    case GTA5_PoliceEffects.Alt_Half_Blink:
                        switch (siren_keyframe % 8)
                        {
                        case 6:
                            rights = lefts;
                            lefts  = Color.Black;

                            if (Properties.PeripheralUse)
                            {
                                sirens_layer.Set(Devices.DeviceKeys.Peripheral, rights);
                            }
                            break;

                        case 4:
                            rights = lefts;
                            lefts  = Color.Black;

                            if (Properties.PeripheralUse)
                            {
                                sirens_layer.Set(Devices.DeviceKeys.Peripheral, rights);
                            }
                            break;

                        case 2:
                            lefts  = rights;
                            rights = Color.Black;

                            if (Properties.PeripheralUse)
                            {
                                sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                            }
                            break;

                        case 0:
                            lefts  = rights;
                            rights = Color.Black;

                            if (Properties.PeripheralUse)
                            {
                                sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                            }
                            break;

                        default:
                            rights = Color.Black;
                            lefts  = Color.Black;

                            if (Properties.PeripheralUse)
                            {
                                sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                            }
                            break;
                        }
                        siren_keyframe = siren_keyframe % 8;
                        break;

                    default:
                        switch (siren_keyframe % 2)
                        {
                        case 1:
                            Color tempc = rights;
                            rights = lefts;
                            lefts  = tempc;
                            break;

                        default:
                            break;
                        }
                        siren_keyframe = siren_keyframe % 2;

                        if (Properties.PeripheralUse)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                        }
                        break;
                    }

                    sirens_layer.Set(Properties.LeftSirenSequence, lefts);
                    sirens_layer.Set(Properties.RightSirenSequence, rights);
                }
            }

            return(sirens_layer);
        }
Example #27
0
 public Emitter(EffectLayer owner)
 {
     Layer = owner;
     EmitLoop = Layer.EmitLoop;
     LastClientPos = Layer.ClientTransform.position;
 }
Example #28
0
    protected void AffectorConfig(EffectLayer ctarget)
    {
        DisplayAffectorConfig = EditorGUILayout.Foldout(DisplayAffectorConfig, "Affector Configuration");


        DisplayJetAffectorConfig        = ctarget.JetAffectorEnable;
        DisplayVortexAffectorConfig     = ctarget.VortexAffectorEnable;
        DisplayGravityAffectorConfig    = ctarget.GravityAffectorEnable;
        DisplayAirAffectorConfig        = ctarget.AirAffectorEnable;
        DisplayBombAffectorConfig       = ctarget.BombAffectorEnable;
        DisplayTurbulenceAffectorConfig = ctarget.TurbulenceAffectorEnable;
        DisplayDragAffectorConfig       = ctarget.DragAffectorEnable;

        if (DisplayAffectorConfig)
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.PrefixLabel("affector types:");
            ctarget.AffectorIndex = EditorGUILayout.Popup(ctarget.AffectorIndex, AffectorTypes);

            AffectorIndex = ctarget.AffectorIndex;

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Affector"))
            {
                if (AffectorIndex == 0)
                {
                    DisplayGravityAffectorConfig = true;
                }
                else if (AffectorIndex == 1)
                {
                    DisplayBombAffectorConfig = true;
                }
                else if (AffectorIndex == 2)
                {
                    DisplayAirAffectorConfig = true;
                }
                else if (AffectorIndex == 3)
                {
                    DisplayVortexAffectorConfig = true;
                }
                else if (AffectorIndex == 4)
                {
                    DisplayJetAffectorConfig = true;
                }
                else if (AffectorIndex == 5)
                {
                    DisplayTurbulenceAffectorConfig = true;
                }
                else if (AffectorIndex == 6)
                {
                    DisplayDragAffectorConfig = true;
                }
            }
            if (GUILayout.Button("Delete Affector"))
            {
                if (AffectorIndex == 0)
                {
                    DisplayGravityAffectorConfig = false;
                }
                else if (AffectorIndex == 1)
                {
                    DisplayBombAffectorConfig = false;
                }
                else if (AffectorIndex == 2)
                {
                    DisplayAirAffectorConfig = false;
                }
                else if (AffectorIndex == 3)
                {
                    DisplayVortexAffectorConfig = false;
                }
                else if (AffectorIndex == 4)
                {
                    DisplayJetAffectorConfig = false;
                }
                else if (AffectorIndex == 5)
                {
                    DisplayTurbulenceAffectorConfig = false;
                }
                else if (AffectorIndex == 6)
                {
                    DisplayDragAffectorConfig = false;
                }
            }
            EditorGUILayout.EndHorizontal();

            if (DisplayGravityAffectorConfig)
            {
                GravityAffectorConfig(ctarget);
            }
            if (DisplayBombAffectorConfig)
            {
                BombAffectorConfig(ctarget);
            }
            if (DisplayAirAffectorConfig)
            {
                AirAffectorConfig(ctarget);
            }
            if (DisplayVortexAffectorConfig)
            {
                VortexAffectorConfig(ctarget);
            }
            if (DisplayJetAffectorConfig)
            {
                JetAffectorConfig(ctarget);
            }
            if (DisplayTurbulenceAffectorConfig)
            {
                TurbulenceAffectorConfig(ctarget);
            }
            if (DisplayDragAffectorConfig)
            {
                DragAffectorConfig(ctarget);
            }

            ctarget.GravityAffectorEnable    = DisplayGravityAffectorConfig;
            ctarget.AirAffectorEnable        = DisplayAirAffectorConfig;
            ctarget.BombAffectorEnable       = DisplayBombAffectorConfig;
            ctarget.JetAffectorEnable        = DisplayJetAffectorConfig;
            ctarget.VortexAffectorEnable     = DisplayVortexAffectorConfig;
            ctarget.TurbulenceAffectorEnable = DisplayTurbulenceAffectorConfig;
            ctarget.DragAffectorEnable       = DisplayDragAffectorConfig;
            EditorGUILayout.EndVertical();
        }
    }
        public static void SendTargetParticles( IEntity target, int itemID, int speed, int duration, int hue, int renderMode, int effect, EffectLayer layer, int unknown )
        {
            if ( target is Mobile )
                ((Mobile)target).ProcessDelta();

            Map map = target.Map;

            if ( map != null )
            {
                Packet particles = null, regular = null;

                IPooledEnumerable eable = map.GetClientsInRange( target.Location );

                foreach ( NetState state in eable )
                {
                    state.Mobile.ProcessDelta();

                    if ( SendParticlesTo( state ) )
                    {
                        if ( particles == null )
                            particles = Packet.Acquire( new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) );

                        state.Send( particles );
                    }
                    else if ( itemID != 0 )
                    {
                        if ( regular == null )
                            regular = Packet.Acquire( new TargetEffect( target, itemID, speed, duration, hue, renderMode ) );

                        state.Send( regular );
                    }
                }

                Packet.Release( particles );
                Packet.Release( regular );

                eable.Free();
            }

            //SendPacket( target.Location, target.Map, new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) );
        }
Example #30
0
    public static void DoPatch(EffectLayer layer)
    {
        Debug.Log("patching for effect layer:" + GetPath(layer.transform));


        if (layer.IsRandomStartColor)
        {
            XEditorTool.PatchColorGradient(layer.RandomColorParam, layer.RandomColorGradient);
        }

        if (layer.ColorChangeType == COLOR_CHANGE_TYPE.Gradient)
        {
            XEditorTool.PatchColorGradient(layer.ColorParam, layer.ColorGradient);
        }

    }
Example #31
0
        public Totem(int ItemID, string name, int hue, int maxrange, TotemType type, DateTime todelete, Mobile caster, double bonus, int effectid, int effectspeed, int effectduration, EffectLayer effectlayer, int soundid)
            : base(ItemID)
        {
            Name = name;
            Hue = hue;
            Movable = false;
            Visible = true;

            MaxRange = maxrange;
            ToDelete = todelete;
            Caster = caster;
            Bonus = bonus;
            EffectID = effectid;
            EffectSpeed = effectspeed;
            EffectDuration = effectduration;
            EffectLayer = effectlayer;
            SoundID = soundid;

            TotemType = type;

            if (m_DeleteTimer == null)
            {
                m_DeleteTimer = new DeleteTotemTimer(this);
                m_DeleteTimer.Start();
            }

            foreach (Mobile m in this.GetMobilesInRange(20))
            {
                m.InvalidateProperties();
                m.Delta(MobileDelta.Armor);
            }
        }
Example #32
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer image_layer = new EffectLayer();

            if (!String.IsNullOrWhiteSpace(Properties.ImagePath))
            {
                if (!_loaded_image_path.Equals(Properties.ImagePath))
                {
                    //Not loaded, load it!
                    if (!File.Exists(Properties.ImagePath))
                    {
                        throw new FileNotFoundException("Could not find file specified for layer: " + Properties.ImagePath);
                    }

                    _loaded_image      = new Bitmap(Properties.ImagePath);
                    _loaded_image_path = Properties.ImagePath;

                    if (Properties.ImagePath.EndsWith(".gif") && ImageAnimator.CanAnimate(_loaded_image))
                    {
                        ImageAnimator.Animate(_loaded_image, null);
                    }
                }

                if (Properties.ImagePath.EndsWith(".gif") && ImageAnimator.CanAnimate(_loaded_image))
                {
                    ImageAnimator.UpdateFrames(_loaded_image);
                }

                temp_layer = new EffectLayer("Temp Image Render");

                if (Properties.Sequence.type == KeySequenceType.Sequence)
                {
                    using (Graphics g = temp_layer.GetGraphics())
                    {
                        g.DrawImage(_loaded_image, new RectangleF(0, 0, Effects.canvas_width, Effects.canvas_height), new RectangleF(0, 0, _loaded_image.Width, _loaded_image.Height), GraphicsUnit.Pixel);
                    }

                    foreach (var key in Properties.Sequence.keys)
                    {
                        image_layer.Set(key, Utils.ColorUtils.AddColors(image_layer.Get(key), temp_layer.Get(key)));
                    }
                }
                else
                {
                    float x_pos  = (float)Math.Round((Properties.Sequence.freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
                    float y_pos  = (float)Math.Round((Properties.Sequence.freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);
                    float width  = (float)Math.Round((double)(Properties.Sequence.freeform.Width * Effects.editor_to_canvas_width));
                    float height = (float)Math.Round((double)(Properties.Sequence.freeform.Height * Effects.editor_to_canvas_height));

                    if (width < 3)
                    {
                        width = 3;
                    }
                    if (height < 3)
                    {
                        height = 3;
                    }

                    Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)width, (int)height);

                    using (Graphics g = temp_layer.GetGraphics())
                    {
                        g.DrawImage(_loaded_image, rect, new RectangleF(0, 0, _loaded_image.Width, _loaded_image.Height), GraphicsUnit.Pixel);
                    }

                    using (Graphics g = image_layer.GetGraphics())
                    {
                        PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                        Matrix myMatrix = new Matrix();
                        myMatrix.RotateAt(Properties.Sequence.freeform.Angle, rotatePoint, MatrixOrder.Append);

                        g.Transform = myMatrix;
                        g.DrawImage(temp_layer.GetBitmap(), rect, rect, GraphicsUnit.Pixel);
                    }
                }
            }

            return(image_layer);
        }
Example #33
0
    public static void DoPatch(EffectLayer layer)
    {
        Debug.Log("patching for effect layer:" + GetPath(layer.transform));


        if (layer.ColorChangeType != COLOR_CHANGE_TYPE.Constant)
        {
            layer.Color1 = Color.white;
        }


        if (layer.EmitType == 4 && layer.LineStartObj == null)
        {
            layer.LineStartObj = layer.transform;
        }

        if (!layer.UseSameScaleCurve)
        {
            layer.MaxScaleValueY = layer.MaxScaleCalue;
        }


        if (layer.RenderType == 2 || layer.RenderType == 3)
        {
            float y = layer.OriTopLeftUV.y - layer.OriUVDimensions.y;
            if (y >= 0f)
                layer.OriTopLeftUV.y = layer.OriTopLeftUV.y - layer.OriUVDimensions.y;
        }

    }
Example #34
0
 public void FixedParticles(int itemID, int speed, int duration, int effect, int hue, int renderMode, EffectLayer layer)
 {
     Effects.SendLocationEffect(this, this.Map, itemID, duration, speed, hue, renderMode);
 }
    void DoPatch415(EffectLayer layer)
    {
        if (layer.EmitLoop < 0)
        {
            layer.EmitDuration = -1f;
        }
        
        layer.EmitLoop = 1;

    }
Example #36
0
        internal virtual void UpdateWrapperLights(EffectFrame frame)
        {
            Queue <EffectLayer> layers = new Queue <EffectLayer>();

            EffectLayer colorfill_layer = new EffectLayer("Aurora Wrapper - Color Fill", GetBoostedColor(last_fill_color));

            layers.Enqueue(colorfill_layer);

            EffectLayer bitmap_layer = new EffectLayer("Aurora Wrapper - Bitmap");

            Devices.DeviceKeys[] allkeys = Enum.GetValues(typeof(Devices.DeviceKeys)).Cast <Devices.DeviceKeys>().ToArray();
            foreach (var key in allkeys)
            {
                if (extra_keys.ContainsKey(key))
                {
                    bitmap_layer.Set(key, GetBoostedColor(extra_keys[key]));
                }
                else
                {
                    Devices.Logitech.Logitech_keyboardBitmapKeys logi_key = Devices.Logitech.LogitechDevice.ToLogitechBitmap(key);

                    if (logi_key != Devices.Logitech.Logitech_keyboardBitmapKeys.UNKNOWN && bitmap.Length > 0)
                    {
                        bitmap_layer.Set(key, GetBoostedColor(Utils.ColorUtils.GetColorFromInt(bitmap[(int)logi_key / 4])));
                    }
                }
            }

            layers.Enqueue(bitmap_layer);

            EffectLayer effects_layer = new EffectLayer("Aurora Wrapper - Effects");

            Devices.DeviceKeys[] effect_keys = key_effects.Keys.ToArray();
            long currentTime = Utils.Time.GetMillisecondsSinceEpoch();

            foreach (var key in effect_keys)
            {
                if (key_effects[key].duration != 0 && key_effects[key].timeStarted + key_effects[key].duration <= currentTime)
                {
                    key_effects.Remove(key);
                }
                else
                {
                    if (key_effects[key] is LogiFlashSingleKey)
                    {
                        effects_layer.Set((key_effects[key] as LogiFlashSingleKey).key, GetBoostedColor((key_effects[key] as LogiFlashSingleKey).GetColor(currentTime - (key_effects[key] as LogiFlashSingleKey).timeStarted)));
                    }
                    else if (key_effects[key] is LogiPulseSingleKey)
                    {
                        effects_layer.Set((key_effects[key] as LogiPulseSingleKey).key, GetBoostedColor((key_effects[key] as LogiPulseSingleKey).GetColor(currentTime - (key_effects[key] as LogiPulseSingleKey).timeStarted)));
                    }
                    else
                    {
                        effects_layer.Set((key_effects[key] as KeyEffect).key, GetBoostedColor((key_effects[key] as KeyEffect).GetColor(currentTime - (key_effects[key] as KeyEffect).timeStarted)));
                    }
                }
            }

            layers.Enqueue(effects_layer);

            EffectLayer entire_effect_layer = new EffectLayer("Aurora Wrapper - EntireKB effect");

            if (current_effect != null)
            {
                if (current_effect is LogiFlashLighting)
                {
                    (current_effect as LogiFlashLighting).SetEffect(entire_effect_layer, currentTime - (current_effect as LogiFlashLighting).timeStarted);
                }
                else if (current_effect is LogiPulseLighting)
                {
                    (current_effect as LogiPulseLighting).SetEffect(entire_effect_layer, currentTime - (current_effect as LogiPulseLighting).timeStarted);
                }
                else
                {
                    current_effect.SetEffect(entire_effect_layer, currentTime - current_effect.timeStarted);
                }
            }

            layers.Enqueue(entire_effect_layer);

            frame.AddLayers(layers.ToArray());
        }
Example #37
0
    protected void AffectorConfig(EffectLayer ctarget)
    {
        DisplayAffectorConfig = EditorGUILayout.Foldout(DisplayAffectorConfig, "Affector Configuration");

        DisplayLinearForceAffectorConfig = ctarget.LinearForceAffectorEnable;
        DisplayJetAffectorConfig = ctarget.JetAffectorEnable;
        DisplayVortexAffectorConfig = ctarget.VortexAffectorEnable;
        DisplayAttractionAffectorConfig = ctarget.AttractionAffectorEnable;

        if (DisplayAffectorConfig)
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.PrefixLabel("affector types:");
            AffectorIndex = EditorGUILayout.Popup(AffectorIndex, AffectorTypes);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Affector"))
            {
                if (AffectorIndex == 0)
                    DisplayLinearForceAffectorConfig = true;
                else if (AffectorIndex == 1)
                    DisplayJetAffectorConfig = true;
                else if (AffectorIndex == 2)
                    DisplayVortexAffectorConfig = true;
                else if (AffectorIndex == 3)
                    DisplayAttractionAffectorConfig = true;
            }
            if (GUILayout.Button("Delete Affector"))
            {
                if (AffectorIndex == 0)
                    DisplayLinearForceAffectorConfig = false;
                else if (AffectorIndex == 1)
                    DisplayJetAffectorConfig = false;
                else if (AffectorIndex == 2)
                    DisplayVortexAffectorConfig = false;
                else if (AffectorIndex == 3)
                    DisplayAttractionAffectorConfig = false;
            }
            EditorGUILayout.EndHorizontal();

            if (DisplayLinearForceAffectorConfig)
                LinearForceAffectorConfig(ctarget);
            if (DisplayJetAffectorConfig)
                JetAffectorConfig(ctarget);
            if (DisplayVortexAffectorConfig)
                VortexAffectorConfig(ctarget);
            if (DisplayAttractionAffectorConfig)
                AttractionAffectorConfig(ctarget);

            ctarget.LinearForceAffectorEnable = DisplayLinearForceAffectorConfig;
            ctarget.JetAffectorEnable = DisplayJetAffectorConfig;
            ctarget.VortexAffectorEnable = DisplayVortexAffectorConfig;
            ctarget.AttractionAffectorEnable = DisplayAttractionAffectorConfig;

            EditorGUILayout.EndVertical();
        }
    }
Example #38
0
 public void SetEffect(EffectLayer layer, long time)
 {
     layer.Fill(GetCurrentColor(time));
 }
Example #39
0
    protected void ColorConfig(EffectLayer ctarget)
    {
        DisplayColorConfig = EditorGUILayout.Foldout(DisplayColorConfig, "Color Configuration");

        if (DisplayColorConfig)
        {
            EditorGUILayout.BeginVertical();

            EditorGUILayout.Space();
            ctarget.ColorAffectType = EditorGUILayout.Popup("color change type:", ctarget.ColorAffectType, ColorTypes);
            if (ctarget.ColorAffectType == 0)
            {
                ctarget.Color1 = EditorGUILayout.ColorField("original color:", ctarget.Color1);
                ctarget.ColorAffectorEnable = false;
            }
            else if (ctarget.ColorAffectType == 1)
            {
                ctarget.ColorAffectorEnable = true;
                ctarget.ColorGradualTimeLength = EditorGUILayout.FloatField("gradual time(-1 node life):", ctarget.ColorGradualTimeLength);
                ctarget.ColorGradualType = (COLOR_GRADUAL_TYPE)EditorGUILayout.Popup("gradual type:", (int)ctarget.ColorGradualType, ColorGradualTypes);
                EditorGUILayout.Space();
                ctarget.Color1 = EditorGUILayout.ColorField("color1:", ctarget.Color1);
                ctarget.Color2 = EditorGUILayout.ColorField("color2:", ctarget.Color2);
            }
            else
            {
                ctarget.ColorAffectorEnable = true;
                ctarget.ColorGradualTimeLength = EditorGUILayout.FloatField("gradual time(-1 node life):", ctarget.ColorGradualTimeLength);
                ctarget.ColorGradualType = (COLOR_GRADUAL_TYPE)EditorGUILayout.Popup("gradual type:", (int)ctarget.ColorGradualType, ColorGradualTypes);
                EditorGUILayout.Space();
                ctarget.Color1 = EditorGUILayout.ColorField("color1:", ctarget.Color1);
                ctarget.Color2 = EditorGUILayout.ColorField("color2:", ctarget.Color2);
                ctarget.Color3 = EditorGUILayout.ColorField("color3:", ctarget.Color3);
                ctarget.Color4 = EditorGUILayout.ColorField("color4:", ctarget.Color4);
            }
            EditorGUILayout.EndVertical();
        }
    }
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer bg_layer = new EffectLayer("Resident Evil 2 - Health");

            if (state is GameState_ResidentEvil2)
            {
                if (Properties.DisplayType == ResidentEvil2HealthLayerHandlerProperties.HealthDisplayType.Static)
                {
                    GameState_ResidentEvil2 re2state = state as GameState_ResidentEvil2;

                    switch (re2state.Player.Status)
                    {
                    case Player_ResidentEvil2.PlayerStatus.Fine:
                        bg_layer.Fill(Color.Green);
                        break;

                    case Player_ResidentEvil2.PlayerStatus.LiteFine:
                        bg_layer.Fill(Color.YellowGreen);
                        break;

                    case Player_ResidentEvil2.PlayerStatus.Caution:
                        bg_layer.Fill(Color.Gold);
                        break;

                    case Player_ResidentEvil2.PlayerStatus.Danger:
                        bg_layer.Fill(Color.Red);
                        break;

                    case Player_ResidentEvil2.PlayerStatus.Dead:
                        bg_layer.Fill(Color.DarkGray);
                        break;

                    default:
                        bg_layer.Fill(Color.DarkSlateBlue);
                        break;
                    }

                    return(bg_layer);
                }
                else if (Properties.DisplayType == ResidentEvil2HealthLayerHandlerProperties.HealthDisplayType.Scanning)
                {
                    previoustime = currenttime;
                    currenttime  = Utils.Time.GetMillisecondsSinceEpoch();

                    GameState_ResidentEvil2 re2state = state as GameState_ResidentEvil2;

                    switch (re2state.Player.Status)
                    {
                    case Player_ResidentEvil2.PlayerStatus.Fine:
                        bg_layer.Fill(Color.FromArgb(8, Color.Green.R, Color.Green.G, Color.Green.B));
                        heartbeat_animationTime = fullAnimTimes[0];
                        mixFine.Draw(bg_layer.GetGraphics(), heartbeat_keyframe);
                        break;

                    case Player_ResidentEvil2.PlayerStatus.LiteFine:
                        bg_layer.Fill(Color.FromArgb(8, Color.YellowGreen.R, Color.YellowGreen.G, Color.YellowGreen.B));
                        heartbeat_animationTime = fullAnimTimes[0];
                        mixLiteFine.Draw(bg_layer.GetGraphics(), heartbeat_keyframe);
                        break;

                    case Player_ResidentEvil2.PlayerStatus.Caution:
                        bg_layer.Fill(Color.FromArgb(8, Color.Gold.R, Color.Gold.G, Color.Gold.B));
                        heartbeat_animationTime = fullAnimTimes[1];
                        mixCaution.Draw(bg_layer.GetGraphics(), heartbeat_keyframe);
                        break;

                    case Player_ResidentEvil2.PlayerStatus.Danger:
                        bg_layer.Fill(Color.FromArgb(8, Color.Red.R, Color.Red.G, Color.Red.B));
                        heartbeat_animationTime = fullAnimTimes[2];
                        mixDanger.Draw(bg_layer.GetGraphics(), heartbeat_keyframe);
                        break;

                    case Player_ResidentEvil2.PlayerStatus.Dead:
                        bg_layer.Fill(Color.DarkGray);
                        break;

                    default:
                        bg_layer.Fill(Color.DarkSlateBlue);
                        break;
                    }

                    heartbeat_keyframe += (currenttime - previoustime) / 1000.0f;

                    if (heartbeat_keyframe >= heartbeat_animationTime)
                    {
                        heartbeat_keyframe = 0;
                    }

                    return(bg_layer);
                }
                else
                {
                    return(bg_layer);
                }
            }
            else
            {
                return(bg_layer);
            }
        }
Example #41
0
 protected void JetAffectorConfig(EffectLayer ctarget)
 {
     DisplayJetAffectorConfig = EditorGUILayout.Foldout(DisplayJetAffectorConfig, "Jet Force Affector Configuration");
     if (DisplayJetAffectorConfig)
     {
         EditorGUILayout.BeginVertical();
         ctarget.JetMin = EditorGUILayout.FloatField("jet min:", ctarget.JetMin);
         ctarget.JetMax = EditorGUILayout.FloatField("jet max:", ctarget.JetMax);
         EditorGUILayout.EndVertical();
     }
 }
Example #42
0
        public void PushFrame(EffectFrame frame)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            lock (bitmap_lock)
            {
                EffectLayer background = new EffectLayer("Global Background", Color.FromArgb(0, 0, 0));

                EffectLayer[] over_layers_array = frame.GetOverlayLayers().ToArray();
                EffectLayer[] layers_array      = frame.GetLayers().ToArray();

                foreach (EffectLayer layer in layers_array)
                {
                    background += layer;
                }

                foreach (EffectLayer layer in over_layers_array)
                {
                    background += layer;
                }

                //Apply Brightness
                Dictionary <DeviceKeys, Color> peripehralColors = new Dictionary <DeviceKeys, Color>();

                foreach (Devices.DeviceKeys key in possible_peripheral_keys)
                {
                    if (!peripehralColors.ContainsKey(key))
                    {
                        peripehralColors.Add(key, background.Get(key));
                    }
                }

                foreach (Devices.DeviceKeys key in possible_peripheral_keys)
                {
                    background.Set(key, Utils.ColorUtils.BlendColors(peripehralColors[key], Color.Black, (1.0f - Global.Configuration.PeripheralBrightness)));
                }

                background.Fill(Color.FromArgb((int)(255.0f * (1.0f - Global.Configuration.KeyboardBrightness)), Color.Black));

                if (Global.Configuration.UseVolumeAsBrightness)
                {
                    background *= Global.Configuration.GlobalBrightness;
                }

                if (_forcedFrame != null)
                {
                    using (Graphics g = background.GetGraphics())
                    {
                        g.Clear(Color.Black);

                        g.DrawImage(_forcedFrame, 0, 0, canvas_width, canvas_height);
                    }
                }

                Dictionary <DeviceKeys, Color> keyColors = new Dictionary <DeviceKeys, Color>();
                Devices.DeviceKeys[]           allKeys   = bitmap_map.Keys.ToArray();

                foreach (Devices.DeviceKeys key in allKeys)
                {
                    keyColors[key] = background.Get(key);
                }

                Effects.keyColors = new Dictionary <DeviceKeys, Color>(keyColors);

                pushedframes++;

                DeviceColorComposition dcc = new DeviceColorComposition()
                {
                    keyColors = new Dictionary <DeviceKeys, Color>(keyColors),
                    keyBitmap = background.GetBitmap()
                };

                Global.dev_manager.UpdateDevices(dcc);

                var hander = NewLayerRender;
                if (hander != null)
                {
                    hander.Invoke(background.GetBitmap());
                }

                if (isrecording)
                {
                    EffectLayer pizelated_render = new EffectLayer();
                    foreach (Devices.DeviceKeys key in allKeys)
                    {
                        pizelated_render.Set(key, background.Get(key));
                    }

                    using (Bitmap map = pizelated_render.GetBitmap())
                    {
                        previousframe = new Bitmap(map);
                    }
                }


                frame.Dispose();
            }

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
        }
Example #43
0
    protected void OriginalVelocityConfig(EffectLayer ctarget)
    {
        DisplayOriginalVelocityConfig = EditorGUILayout.Foldout(DisplayOriginalVelocityConfig, "Direction Configuration");

        if (DisplayOriginalVelocityConfig)
        {
            EditorGUILayout.BeginVertical();
            ctarget.IsRandomDir = EditorGUILayout.Toggle("is random direction:", ctarget.IsRandomDir);
            if (ctarget.IsRandomDir)
            {
                ctarget.OriVelocityAxis = EditorGUILayout.Vector3Field("original axis:", ctarget.OriVelocityAxis);
                ctarget.AngleAroundAxis = EditorGUILayout.IntField("angle around axis:", ctarget.AngleAroundAxis);
                ctarget.OriSpeed = EditorGUILayout.FloatField("original speed:", ctarget.OriSpeed);
            }
            else
            {
                ctarget.OriVelocityAxis = EditorGUILayout.Vector3Field("original direction:", ctarget.OriVelocityAxis);
                ctarget.OriSpeed = EditorGUILayout.FloatField("original velocity:", ctarget.OriSpeed);
            }
            if (ctarget.SpriteType == 1 || ctarget.SpriteType == 2)
                ctarget.AlongVelocity = EditorGUILayout.Toggle("dir along velocity?", ctarget.AlongVelocity);
            EditorGUILayout.EndVertical();
        }
    }
    public override void OnInspectorGUI()
    {
        XffectComponent ctarget = (XffectComponent)target;

        if (Application.isEditor && !EditorApplication.isPlaying)
        {
            EditorApplication.update = ctarget.Update;
        }

        EditorGUILayout.BeginVertical();
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        ctarget.LifeTime = EditorGUILayout.FloatField("life:", ctarget.LifeTime);
        EditorGUILayout.LabelField("[life -1 means infinite.]");

        ctarget.IgnoreTimeScale = EditorGUILayout.Toggle("ignore time scale?", ctarget.IgnoreTimeScale);

        EditorGUILayout.Separator();

        ctarget.Scale = EditorGUILayout.FloatField("scale:", ctarget.Scale);
        EditorGUILayout.Separator();

        if (GUILayout.Button("Add Layer"))
        {
            GameObject  layer = new GameObject(LayerName);
            EffectLayer efl   = (EffectLayer)layer.AddComponent <EffectLayer>();
            layer.transform.parent = Selection.activeTransform;

            efl.transform.localPosition = Vector3.zero;
            //fixed 2012.6.25. default to effect layer object.
            efl.ClientTransform  = efl.transform;
            efl.GravityObject    = efl.transform;
            efl.BombObject       = efl.transform;
            efl.TurbulenceObject = efl.transform;
            efl.AirObject        = efl.transform;
            efl.VortexObj        = efl.transform;
            efl.DirCenter        = efl.transform;
        }


        if (GUILayout.Button("Add Event"))
        {
            GameObject        layer  = new GameObject("_Event");
            XftEventComponent xevent = (XftEventComponent)layer.AddComponent <XftEventComponent>();
            xevent.transform.parent        = Selection.activeTransform;
            xevent.transform.localPosition = Vector3.zero;
            xevent.RadialBlurShader        = Shader.Find("Xffect/PP/radial_blur_new");
            xevent.GlowCompositeShader     = Shader.Find("Xffect/PP/glow_compose");
            xevent.GlowDownSampleShader    = Shader.Find("Xffect/PP/glow_downsample");
            xevent.GlowBlurShader          = Shader.Find("Xffect/PP/glow_conetap");
            xevent.RadialBlurObj           = xevent.transform;
            xevent.ColorInverseShader      = Shader.Find("Xffect/PP/color_inverse");
        }

        EditorGUILayout.Separator();
        ctarget.EditView = EditorGUILayout.Toggle("update in editor?", ctarget.EditView);

        //prevent asset inspector to update.
        if (ctarget.EditView == true)
        {
            if (!XffectComponent.IsActive(ctarget.gameObject))
            {
                ctarget.EditView = false;
                Debug.Log("you should activate the xffect object: " + ctarget.gameObject.name + " before updating it in editor.");
            }
        }

        if (ctarget.EditView)
        {
            ctarget.EnableEditView();
        }
        else
        {
            ctarget.DisableEditView();
        }

        if (ctarget.EditView)
        {
            if (GUILayout.Button("Reset Editor Xffect"))
            {
                ctarget.ResetEditScene();
            }
        }
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Example #45
0
    protected void RotateConfig(EffectLayer ctarget)
    {
        DisplayRotateConfig = EditorGUILayout.Foldout(DisplayRotateConfig, "Rotate Configuration");

        if (DisplayRotateConfig)
        {
            EditorGUILayout.BeginVertical();
            ctarget.RandomOriRot = EditorGUILayout.Toggle("random original rotation?", ctarget.RandomOriRot);
            if (ctarget.RandomOriRot)
            {
                ctarget.OriRotationMin = EditorGUILayout.IntField("original rotation min:", ctarget.OriRotationMin);
                ctarget.OriRotationMax = EditorGUILayout.IntField("original rotation max:", ctarget.OriRotationMax);
            }
            else
            {
                ctarget.OriRotationMin = EditorGUILayout.IntField("original rotation:", ctarget.OriRotationMin);
                ctarget.OriRotationMax = ctarget.OriRotationMin;
            }
            EditorGUILayout.Space();
            ctarget.RotateType = (RSTYPE)EditorGUILayout.Popup("rotate change type", (int)ctarget.RotateType, RotateTypes);
            if (ctarget.RotateType == RSTYPE.NONE)
            {
                ctarget.RotAffectorEnable = false;
            }
            else if (ctarget.RotateType == RSTYPE.SIMPLE)
            {
                ctarget.RotAffectorEnable = true;
                ctarget.DeltaRot = EditorGUILayout.FloatField("delta angle per second:", ctarget.DeltaRot);
            }
            else
            {
                ctarget.RotAffectorEnable = true;
                ctarget.RotateCurve = EditorGUILayout.CurveField("rotation curve:", ctarget.RotateCurve);
            }
            EditorGUILayout.EndVertical();
        }
    }
Example #46
0
 public static void CreateMovingParticleEffect(
     Span <byte> buffer,
     IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection,
     bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer,
     int unknown
     ) => CreateParticleEffect(
     buffer,
     EffectType.Moving,
     from.Serial,
     to.Serial,
     itemID,
     from.Location,
     to.Location,
     speed,
     duration,
     fixedDirection,
     explodes,
     hue,
     renderMode,
     effect,
     explodeEffect,
     explodeSound,
     Serial.Zero,
     (int)layer,
     unknown
     );
Example #47
0
    protected void SpriteConfig(EffectLayer ctarget)
    {
        DisplaySpriteConfig = EditorGUILayout.Foldout(DisplaySpriteConfig, "Sprite Configuration");

        //DisplaySpriteConfig = EditorGUILayout.InspectorTitlebar(DisplaySpriteConfig, SpriteTitle);

        if (DisplaySpriteConfig)
        {
            EditorGUILayout.BeginVertical();

            ctarget.SpriteType = EditorGUILayout.Popup("sprite type:",ctarget.SpriteType, SpriteTypes);
            if (ctarget.SpriteType == 1)
            {//billboard self
                ctarget.SpriteUVStretch = EditorGUILayout.Popup("uv stretch:", ctarget.SpriteUVStretch, SpriteUVStretchTypes);
            }
            ctarget.OriPoint = EditorGUILayout.Popup("original point:", ctarget.OriPoint, OriginalPoint);
            ctarget.SpriteWidth = EditorGUILayout.FloatField("width:", ctarget.SpriteWidth);
            ctarget.SpriteHeight = EditorGUILayout.FloatField("height:", ctarget.SpriteHeight);
            EditorGUILayout.EndVertical();
        }
    }
Example #48
0
        public override EffectLayer Render(IGameState gamestate)
        {
            previoustime = currenttime;
            currenttime  = Utils.Time.GetMillisecondsSinceEpoch();

            EffectLayer  layer = new EffectLayer("Goal Explosion");
            AnimationMix goal_explosion_mix = new AnimationMix();

            if (gamestate is GameState_RocketLeague)
            {
                var state = gamestate as GameState_RocketLeague;
                if (state.Game.Status == RLStatus.Undefined)
                {
                    return(layer);
                }

                if (state.YourTeam.Goals == -1 || state.OpponentTeam.Goals == -1 || previousOwnTeamGoals > state.YourTeam.Goals || previousOpponentGoals > state.OpponentTeam.Goals)
                {
                    //reset goals when game ends
                    previousOwnTeamGoals  = 0;
                    previousOpponentGoals = 0;
                }

                if (state.YourTeam.Goals > previousOwnTeamGoals)//keep track of goals even if we dont play the animation
                {
                    previousOwnTeamGoals = state.YourTeam.Goals;
                    if (Properties.ShowFriendlyGoalExplosion && state.ColorsValid())
                    {
                        Color playerColor = state.YourTeam.TeamColor;
                        this.SetTracks(playerColor);
                        goal_explosion_mix.Clear();
                        showAnimation_Explosion = true;
                    }
                }

                if (state.OpponentTeam.Goals > previousOpponentGoals)
                {
                    previousOpponentGoals = state.OpponentTeam.Goals;
                    if (Properties.ShowEnemyGoalExplosion && state.ColorsValid())
                    {
                        Color opponentColor = state.OpponentTeam.TeamColor;
                        this.SetTracks(opponentColor);
                        goal_explosion_mix.Clear();
                        showAnimation_Explosion = true;
                    }
                }

                if (showAnimation_Explosion)
                {
                    if (Properties.Background)
                    {
                        layer.Fill(Properties.PrimaryColor);
                    }

                    goal_explosion_mix = new AnimationMix(tracks);

                    goal_explosion_mix.Draw(layer.GetGraphics(), goalEffect_keyframe);
                    goalEffect_keyframe += (currenttime - previoustime) / 1000.0f;

                    if (goalEffect_keyframe >= goalEffect_animationTime)
                    {
                        showAnimation_Explosion = false;
                        goalEffect_keyframe     = 0;
                    }
                }
            }
            return(layer);
        }
Example #49
0
    protected void VortexAffectorConfig(EffectLayer ctarget)
    {
        DisplayVortexAffectorConfig = EditorGUILayout.Foldout(DisplayVortexAffectorConfig, "Vortex Affector Configuration");
        if (DisplayVortexAffectorConfig)
        {
            EditorGUILayout.BeginVertical();
            ctarget.UseVortexCurve = EditorGUILayout.Toggle("use curve?", ctarget.UseVortexCurve);
            if (ctarget.UseVortexCurve)
            {
                ctarget.VortexCurve = EditorGUILayout.CurveField("magnitude curve:", ctarget.VortexCurve);
                ctarget.VortexDirection = EditorGUILayout.Vector3Field("direction:", ctarget.VortexDirection);
            }
            else
            {
                ctarget.VortexMag = EditorGUILayout.FloatField("magnitude:", ctarget.VortexMag);
                ctarget.VortexDirection = EditorGUILayout.Vector3Field("direction:", ctarget.VortexDirection);
            }

            EditorGUILayout.EndVertical();
        }
    }
Example #50
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer burning_layer = new EffectLayer("CSGO - Burning");

            if (state is GameState_CSGO)
            {
                GameState_CSGO csgostate = state as GameState_CSGO;

                //Update Burning

                if (csgostate.Player.State.Burning > 0)
                {
                    double burning_percent = (double)csgostate.Player.State.Burning / 255.0;
                    Color  burncolor       = Properties.BurningColor;

                    if (Properties.Animated)
                    {
                        int  red_adjusted = (int)(burncolor.R + (Math.Cos((Utils.Time.GetMillisecondsSinceEpoch() + randomizer.Next(75)) / 75.0) * 0.15 * 255));
                        byte red          = 0;

                        if (red_adjusted > 255)
                        {
                            red = 255;
                        }
                        else if (red_adjusted < 0)
                        {
                            red = 0;
                        }
                        else
                        {
                            red = (byte)red_adjusted;
                        }

                        int  green_adjusted = (int)(burncolor.G + (Math.Sin((Utils.Time.GetMillisecondsSinceEpoch() + randomizer.Next(150)) / 75.0) * 0.15 * 255));
                        byte green          = 0;

                        if (green_adjusted > 255)
                        {
                            green = 255;
                        }
                        else if (green_adjusted < 0)
                        {
                            green = 0;
                        }
                        else
                        {
                            green = (byte)green_adjusted;
                        }

                        int  blue_adjusted = (int)(burncolor.B + (Math.Cos((Utils.Time.GetMillisecondsSinceEpoch() + randomizer.Next(225)) / 75.0) * 0.15 * 255));
                        byte blue          = 0;

                        if (blue_adjusted > 255)
                        {
                            blue = 255;
                        }
                        else if (blue_adjusted < 0)
                        {
                            blue = 0;
                        }
                        else
                        {
                            blue = (byte)blue_adjusted;
                        }

                        burncolor = Color.FromArgb(csgostate.Player.State.Burning, red, green, blue);
                    }

                    burning_layer.Fill(burncolor);
                }
            }

            return(burning_layer);
        }
Example #51
0
 public void FixedParticles( int itemID, int speed, int duration, int effect, EffectLayer layer )
 {
     Effects.SendTargetParticles( this, itemID, speed, duration, 0, 0, effect, layer, 0 );
 }
Example #52
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        XEditor.BeginCommonArea("xffect main config", Script.gameObject.name, this, true);

        EditorGUILayout.Space();

        XEditor.DrawToggle("update in editor?", "", EditView);

        //EditView.boolValue = EditorGUILayout.Toggle("update in editor:", EditView.boolValue,GUILayout.Height(40f));


        if (EditView.boolValue == true)
        {
            if (!XffectComponent.IsActive(Script.gameObject))
            {
                EditView.boolValue = false;
                Debug.Log("you need to activate the xffect object: " + Script.gameObject.name + " before updating it in editor.");
            }
        }

        if (EditView.boolValue)
        {
            Script.EnableEditView();
        }
        else
        {
            Script.DisableEditView();
        }

        if (EditView.boolValue)
        {
            if (GUILayout.Button("Reset"))
            {
                Script.ResetEditScene();
            }
        }

        XEditor.DrawSeparator();

        XEditor.DrawFloat("life(-1 means infinite):", "", LifeTime);
        XEditor.DrawToggle("ignore time scale?", "", IgnoreTimeScale);


        EditorGUILayout.Space();

        XEditor.DrawFloat("scale:", "change this Xffect's scale", Scale);


        if (GUILayout.Button("Add Layer"))
        {
            GameObject  layer = new GameObject(LayerName);
            EffectLayer efl   = (EffectLayer)layer.AddComponent("EffectLayer");
            layer.transform.parent      = Selection.activeTransform;
            efl.transform.localPosition = Vector3.zero;
            //default to effect layer object.
            efl.ClientTransform  = efl.transform;
            efl.GravityObject    = efl.transform;
            efl.BombObject       = efl.transform;
            efl.TurbulenceObject = efl.transform;
            efl.AirObject        = efl.transform;
            efl.VortexObj        = efl.transform;
            efl.DirCenter        = efl.transform;
            efl.Material         = AssetDatabase.LoadAssetAtPath(XEditorTool.GetXffectPath() + DefaultMatPath, typeof(Material)) as Material;

            efl.gameObject.layer = Script.gameObject.layer;

            Selection.activeGameObject = layer;
        }


        if (GUILayout.Button("Add Event"))
        {
            GameObject        obj    = new GameObject("_Event");
            XftEventComponent xevent = (XftEventComponent)obj.AddComponent("XftEventComponent");
            xevent.transform.parent        = Selection.activeTransform;
            xevent.transform.localPosition = Vector3.zero;
            xevent.RadialBlurShader        = Shader.Find("Xffect/PP/radial_blur_new");
            xevent.GlowCompositeShader     = Shader.Find("Xffect/PP/glow_compose");
            xevent.GlowDownSampleShader    = Shader.Find("Xffect/PP/glow_downsample");
            xevent.GlowBlurShader          = Shader.Find("Xffect/PP/glow_conetap");
            xevent.RadialBlurObj           = xevent.transform;
            xevent.ColorInverseShader      = Shader.Find("Xffect/PP/color_inverse");

            xevent.GlowPerObjBlendShader       = Shader.Find("Xffect/glow_per_obj/blend");
            xevent.GlowPerObjReplacementShader = Shader.Find("Xffect/glow_per_obj/replacement");

            xevent.gameObject.layer = Script.gameObject.layer;

            Selection.activeGameObject = obj;
        }


        EditorGUILayout.Space();

        XEditor.EndXArea();

        DrawInfos();

        serializedObject.ApplyModifiedProperties();
    }
    void OnEnable()
    {
        Script = target as EffectLayer;
        InitSerializedProperty();
        LoadStyle();


        if (Script.Owner == null)
        {
            Script.Owner = Script.transform.parent.gameObject.GetComponent<XffectComponent>();
        }

        if (Script.Owner == null)
            return;

        //avoid parent updating become jerky.
        if (Application.isEditor && !EditorApplication.isPlaying)
        {
            EditorApplication.update = Script.Owner.Update;
        }

    }
Example #54
0
    public override void OnInspectorGUI()
    {
        //foreach (GameObject meshobj in Script.MeshList)
        //{
        //if (meshobj != null)
        //EditorUtility.SetSelectedWireframeHidden(meshobj.renderer, true);
        //}

        serializedObject.Update();

        //check if need to upgrade.
        System.Version myVer = new System.Version(Script.MyVersion);
        if (myVer <= new System.Version("4.4.0"))
        {
            DoPatch440(Script);
            EditorUtility.SetDirty(target);
        }



        XEditor.BeginCommonArea("xffect main config", Script.gameObject.name, this, true);

        EditorGUILayout.Space();

        GUI.color = Color.yellow;
        XEditor.DrawInfo("This is a free edition of Xffect with limited function and examples.");
        if (GUILayout.Button("Go get the full version!"))
        {
            Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/content/3810");
        }

        GUI.color = Color.white;


        if (GUILayout.Button("Open Xffect Browser"))
        {
            XffectBrowser.ShowWindow();
        }

        if (EditorUtility.IsPersistent(target))
        {
            if (GUILayout.Button("Put To Scene"))
            {
                GameObject obj = PrefabUtility.InstantiatePrefab(Selection.activeObject as GameObject) as GameObject;
                Selection.activeGameObject = obj;
                if (obj != null)
                {
                    XffectComponent xobj = obj.GetComponent <XffectComponent>();
                    if (xobj != null)
                    {
                        xobj.EditView = true;
                        xobj.EnableEditView();
                    }
                }
            }
        }
        else
        {
            XEditor.DrawToggle("update in editor?", "", EditView);

            //EditView.boolValue = EditorGUILayout.Toggle("update in editor:", EditView.boolValue,GUILayout.Height(40f));


            //if (EditView.boolValue == true) {
            //if (!XffectComponent.IsActive(Script.gameObject)) {
            //EditView.boolValue = false;
            //Debug.Log ("you need to activate the xffect object: " + Script.gameObject.name + " before updating it in editor.");
            //}
            //}

            if (EditView.boolValue)
            {
                Script.EnableEditView();
            }
            else
            {
                Paused.boolValue = false;
                Script.DisableEditView();
            }
        }



        if (EditView.boolValue)
        {
            PlaybackTime.floatValue = EditorGUILayout.FloatField("Playback time: ", PlaybackTime.floatValue);

            if (PlaybackTime.floatValue < 0f)
            {
                PlaybackTime.floatValue = 0f;
            }

            string disp = "Pause";
            if (Paused.boolValue)
            {
                disp = "Play";
            }
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(disp))
            {
                Paused.boolValue = !Paused.boolValue;
            }

            if (GUILayout.Button("Reset"))
            {
                Paused.boolValue = false;
                Script.ResetEditScene();
            }

            EditorGUILayout.EndHorizontal();
        }

        XEditor.DrawSeparator();

        XEditor.DrawFloat("life(-1 means infinite):", "", LifeTime);
        XEditor.DrawToggle("ignore time scale?", "", IgnoreTimeScale);

        XEditor.DrawToggle("auto destroy?", "check on this option if you want this obj to be destroyed when finished, note this option only works in play mode.", AutoDestroy);

        XEditor.DrawToggle("merge same mesh?", "check on this option to merge the meshes with same material, can reduce drawcalls.", MergeSameMaterialMesh);

        XEditor.DrawToggle("update when offscreen?", "", UpdateWhenOffScreen);

        if (XEditor.DrawToggle("use with 2d sprite?", "", UseWith2DSprite))
        {
            XEditor.DrawText("sorting layer name:", "", SortingLayerName);
            XEditor.DrawInt("sorting order:", "", SortingOrder);
        }

        EditorGUILayout.Space();



        XEditor.DrawInt("Max Fps:", "", MaxFps);

        XEditor.DrawFloat("scale:", "change this Xffect's scale", Scale);

        if (!Mathf.Approximately(1f, Scale.floatValue))
        {
            XEditor.DrawInfo("note it's not recommended to use this function to change xffect's scale. if you encounter strange behavious, please change it back to 1.");
        }

        if (GUILayout.Button("Add Layer"))
        {
            GameObject  layer = new GameObject(LayerName);
            EffectLayer efl   = (EffectLayer)layer.AddComponent <EffectLayer>();
            layer.transform.parent      = Selection.activeTransform;
            efl.transform.localPosition = Vector3.zero;
            //default to effect layer object.
            efl.ClientTransform  = efl.transform;
            efl.GravityObject    = efl.transform;
            efl.BombObject       = efl.transform;
            efl.TurbulenceObject = efl.transform;
            efl.AirObject        = efl.transform;
            efl.VortexObj        = efl.transform;
            //efl.DirCenter = efl.transform;
            efl.Material = AssetDatabase.LoadAssetAtPath(XEditorTool.GetXffectPath() + DefaultMatPath, typeof(Material)) as Material;

            efl.gameObject.layer = Script.gameObject.layer;

            efl.LineStartObj = efl.transform;

            Selection.activeGameObject = layer;
        }


        if (GUILayout.Button("Add Event"))
        {
            GameObject        obj    = new GameObject("_Event");
            XftEventComponent xevent = (XftEventComponent)obj.AddComponent <XftEventComponent>();
            xevent.transform.parent        = Selection.activeTransform;
            xevent.transform.localPosition = Vector3.zero;
            xevent.RadialBlurShader        = Shader.Find("Xffect/PP/radial_blur");
            xevent.GlowCompositeShader     = Shader.Find("Xffect/PP/glow_compose");
            xevent.GlowDownSampleShader    = Shader.Find("Xffect/PP/glow_downsample");
            xevent.GlowBlurShader          = Shader.Find("Xffect/PP/glow_conetap");
            xevent.RadialBlurObj           = xevent.transform;
            xevent.ColorInverseShader      = Shader.Find("Xffect/PP/color_inverse");

            xevent.GlowPerObjBlendShader       = Shader.Find("Hidden/PP/Xffect/glow_per_obj/blend");
            xevent.GlowPerObjReplacementShader = Shader.Find("Hidden/PP/Xffect/glow_per_obj/replacement");
            xevent.gameObject.layer            = Script.gameObject.layer;

            Selection.activeGameObject = obj;
        }
        XEditor.EndXArea();

        DrawInfos();
        serializedObject.ApplyModifiedProperties();
    }
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 0:
                {
                    m_EffectDelay = reader.ReadTimeSpan();
                    m_TriggerDelay = reader.ReadTimeSpan();
                    m_SoundDelay = reader.ReadTimeSpan();

                    m_Source = ReadEntity( reader );
                    m_Target = ReadEntity( reader );
                    m_Trigger = reader.ReadItem() as EffectController;

                    m_FixedDirection = reader.ReadBool();
                    m_Explodes = reader.ReadBool();
                    m_PlaySoundAtTrigger = reader.ReadBool();

                    m_EffectType = (EffectType)reader.ReadEncodedInt();
                    m_EffectLayer = (EffectLayer)reader.ReadEncodedInt();
                    m_TriggerType = (EffectTriggerType)reader.ReadEncodedInt();

                    m_ItemID = reader.ReadEncodedInt();
                    m_Hue = reader.ReadEncodedInt();
                    m_RenderMode = reader.ReadEncodedInt();
                    m_Speed = reader.ReadEncodedInt();
                    m_Duration = reader.ReadEncodedInt();
                    m_ParticleEffect = reader.ReadEncodedInt();
                    m_ExplodeParticleEffect = reader.ReadEncodedInt();
                    m_ExplodeSound = reader.ReadEncodedInt();
                    m_Unknown = reader.ReadEncodedInt();
                    m_SoundID = reader.ReadEncodedInt();
                    m_TriggerRange = reader.ReadEncodedInt();

                    break;
                }
            }
        }
Example #56
0
 public static void SendTargetParticles(IEntity target, int itemID, int speed, int duration, int effect, EffectLayer layer, int unknown)
 {
     SendTargetParticles(target, itemID, speed, duration, 0, 0, effect, layer, unknown);
 }
 public static void SendTargetParticles( IEntity target, int itemID, int speed, int duration, int effect, EffectLayer layer, int unknown )
 {
     SendTargetParticles( target, itemID, speed, duration, 0, 0, effect, layer, unknown );
 }
Example #58
0
        public static void SendTargetParticles(IEntity target, int itemID, int speed, int duration, int hue, int renderMode, int effect, EffectLayer layer, int unknown)
        {
            if (target is Mobile)
            {
                ((Mobile)target).ProcessDelta();
            }

            Map map = target.Map;

            if (map != null)
            {
                Packet particles = null, regular = null;

                IPooledEnumerable eable = map.GetClientsInRange(target.Location);

                foreach (NetState state in eable)
                {
                    if (!state.Mobile.HasFilter || state.Mobile.InLOS(target.Location))
                    {
                        state.Mobile.ProcessDelta();

                        if (SendParticlesTo(state))
                        {
                            if (particles == null)
                            {
                                particles = Packet.Acquire(new TargetParticleEffect(target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown));
                            }

                            state.Send(particles);
                        }
                        else if (itemID != 0)
                        {
                            if (regular == null)
                            {
                                regular =
                                    Packet.Acquire(new TargetEffect(target, itemID, speed, duration, hue, renderMode));
                            }

                            state.Send(regular);
                        }
                    }
                }

                Packet.Release(particles);
                Packet.Release(regular);

                eable.Free();
            }

            //SendPacket( target.Location, target.Map, new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) );
        }
Example #59
0
 public MovingParticleEffect( IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer, int unknown )
     : base(EffectType.Moving, from.Serial, to.Serial, itemID, from.Location, to.Location, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, Serial.Zero, (int)layer, unknown)
 {
 }
Example #60
0
    public override void OnInspectorGUI()
    {
        EffectLayer ctarget = (EffectLayer)target;

        EditorGUIUtility.LookLikeControls(PreLableWidth);

        EditorGUILayout.BeginVertical();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("render type:");
        ctarget.RenderType = EditorGUILayout.Popup(ctarget.RenderType, RenderTypes);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("client transform:");
        ctarget.ClientTransform = (Transform)EditorGUILayout.ObjectField(ctarget.ClientTransform, typeof(Transform), true);
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("sync to client pos:");
        ctarget.SyncClient = EditorGUILayout.Toggle(ctarget.SyncClient);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("material :");
        ctarget.Material = (Material)EditorGUILayout.ObjectField(ctarget.Material, typeof(Material), false);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("render queue :");
        ctarget.Depth = EditorGUILayout.IntField(ctarget.Depth);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        ctarget.StartTime = EditorGUILayout.FloatField("delay(s):", ctarget.StartTime);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        ctarget.MaxFps = EditorGUILayout.FloatField("Max FPS:", ctarget.MaxFps);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        ctarget.DrawDebug = EditorGUILayout.Toggle("Draw Debug?", ctarget.DrawDebug);
        EditorGUILayout.EndHorizontal();

        if (ctarget.DrawDebug)
        {
            EditorGUILayout.BeginHorizontal();
            ctarget.DebugColor = EditorGUILayout.ColorField("debug color:", ctarget.DebugColor);
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        if (ctarget.RenderType == 0)
        {
            SpriteConfig(ctarget);
        }
        else if (ctarget.RenderType == 1)
        {
            RibbonTrailConfig(ctarget);
        }
        else if (ctarget.RenderType == 2)
        {
            ConeConfig(ctarget);
        }
        else if (ctarget.RenderType == 3)
        {
            CustomMeshConfig(ctarget);
        }
        if (ctarget.RenderType == 0 || ctarget.RenderType == 2 || ctarget.RenderType == 3)
        {
            EditorGUILayout.Space();
            EditorGUILayout.Separator();
            RotateConfig(ctarget);
            EditorGUILayout.Space();
            EditorGUILayout.Separator();
            ScaleConfig(ctarget);
        }
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        ColorConfig(ctarget);

        if (ctarget.RenderType != 3)
        {
            EditorGUILayout.Space();
            EditorGUILayout.Separator();
            UVConfig(ctarget);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        EmitterConfig(ctarget);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        OriginalVelocityConfig(ctarget);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        AffectorConfig(ctarget);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();

        CollisionConfig(ctarget);

        EditorGUILayout.Space();
        EditorGUILayout.Separator();

        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }