예제 #1
0
    } //  einde methode

    public override void Activate() // de abstracte die we bij activatable hebben gemaakt wordt hier nu aangemaakt
    {
        if (!IsActivated)              // is niet geactiveerd --> is dus nog niet gebruikt, de lever moet nog gebruikt worden
        {
            area = new List <Block>(); // aanmaken van een list van blocks -- hierin staan alle blokjes van u 1 kleur van waar je opstaat

            //    |  hieronder geeft een 2D array van blocks terug        |
            BlockColor color = GameController.CurrentLevel.GetPartOfGrid(Position, 1, 1)[0, 0].Color; // dit geeft de kleur van u blokje weer waar u lever op staat
            // (1,1) [0,0] er kan dus maar 1 ding in en we zetten 0,0 en daar nemen we de kleur van


            // je start op het blokje waar de lever op staat, en je moet alle blokjes van u kleur waar je opstaat (en waar de lever is) in u list krijgen
            ScanForAdjacentBlocks(GameController.CurrentLevel.GetPartOfGrid(Position, 1, 1)[0, 0], color);

            //nu zouden alle blockjes in de list moeten zitten


            foreach (Block block in area)                                    // voor elke blok in de list area (waar alle blokjes in gezet worden die dezelfde kleur hebben) wordt het volgende uitgevoerd:
            {
                block.Color = ColorSpectrum.GetComplementColor(block.Color); // de kleur van de block(jes) wordt omgezet naar hun complementaire kleur
            }

            IsActivated = true; // en op die manier zijn ze dan dus ook geactiveerd.
        }
    }
예제 #2
0
        public override void UpdateLights(EffectFrame frame)
        {
            //if (Global.Configuration.volume_overlay_settings.enabled)
            //{
            if (defaultDevice == null)
            {
                defaultDevice = devEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
            }
            Queue <EffectLayer> layers = new Queue <EffectLayer>();

            if (Global.Configuration.volume_overlay_settings.dim_background)
            {
                layers.Enqueue(new EffectLayer("Overlay - Volume Base", Global.Configuration.volume_overlay_settings.dim_color));
            }

            EffectLayer   volume_bar    = new EffectLayer("Overlay - Volume Bar");
            float         currentVolume = defaultDevice.AudioEndpointVolume.MasterVolumeLevelScalar;
            ColorSpectrum volume_spec   = new ColorSpectrum(Global.Configuration.volume_overlay_settings.low_color, Global.Configuration.volume_overlay_settings.high_color);

            volume_spec.SetColorAt(0.75f, Global.Configuration.volume_overlay_settings.med_color);

            volume_bar.PercentEffect(volume_spec, Global.Configuration.volume_overlay_settings.sequence, currentVolume, 1.0f);

            layers.Enqueue(volume_bar);

            frame.AddOverlayLayers(layers.ToArray());
            //}
        }
예제 #3
0
        public override void Draw(Graphics g, float scale = 1.0f)
        {
            RectangleF _scaledDimension = new RectangleF(_dimension.X * scale, _dimension.Y * scale, _dimension.Width * scale, _dimension.Height * scale);

            EffectBrush _newbrush = new EffectBrush(_gradientBrush);

            _newbrush.start  = new PointF(0.0f, 0.0f);
            _newbrush.end    = new PointF(1.0f, 1.0f);
            _newbrush.center = new PointF(0.5f, 0.5f);

            SortedDictionary <float, System.Drawing.Color> newColorGradients = new SortedDictionary <float, System.Drawing.Color>();
            ColorSpectrum spectrum = _newbrush.GetColorSpectrum();
            var           colors   = _newbrush.colorGradients;

            float _cutOffPoint = _width / _radius;

            if (_cutOffPoint < 1.0f)
            {
                _cutOffPoint = 1.0f - _cutOffPoint;

                foreach (var kvp in spectrum.GetSpectrumColors())
                {
                    newColorGradients.Add((1 - _cutOffPoint) * kvp.Key + _cutOffPoint, kvp.Value);
                }

                newColorGradients.Add(_cutOffPoint - 0.0001f, Color.Transparent);
                newColorGradients.Add(0.0f, Color.Transparent);

                _newbrush.colorGradients = newColorGradients;
            }
            else if (_cutOffPoint > 1.0f)
            {
                foreach (var kvp in spectrum.GetSpectrumColors())
                {
                    if (kvp.Key >= (1 - 1 / _cutOffPoint))
                    {
                        newColorGradients.Add((1 - 1 / _cutOffPoint) * kvp.Key + _cutOffPoint, kvp.Value);
                    }
                }

                newColorGradients.Add(0.0f, spectrum.GetColorAt((1 - 1 / _cutOffPoint)));
            }

            _newbrush.SetBrushType(EffectBrush.BrushType.Radial);
            Brush brush = _newbrush.GetDrawingBrush();

            if (brush is PathGradientBrush)
            {
                (brush as PathGradientBrush).TranslateTransform(_scaledDimension.X, _scaledDimension.Y);
                (brush as PathGradientBrush).ScaleTransform(_scaledDimension.Width - (2.0f), _scaledDimension.Height - (2.0f));

                Matrix rotationMatrix = new Matrix();
                rotationMatrix.RotateAt(-_angle, new PointF(_center.X * scale, _center.Y * scale), MatrixOrder.Append);

                Matrix originalMatrix = g.Transform;
                g.Transform = rotationMatrix;
                g.FillEllipse(brush, _scaledDimension);
                g.Transform = originalMatrix;
            }
        }
예제 #4
0
        public void ColorSpectrumTest()
        {
            var colorSpectrum = new ColorSpectrum();

            Assert.NotNull(colorSpectrum);

            Assert.Equal(Colors.White, colorSpectrum.Color);
            Assert.Equal(new Vector4()
            {
                X = 0.0f, Y = 0.0f, Z = 1.0f, W = 1.0f
            }, colorSpectrum.HsvColor);
            Assert.Equal(0, colorSpectrum.MinHue);
            Assert.Equal(359, colorSpectrum.MaxHue);
            Assert.Equal(0, colorSpectrum.MinSaturation);
            Assert.Equal(100, colorSpectrum.MaxSaturation);
            Assert.Equal(0, colorSpectrum.MinValue);
            Assert.Equal(100, colorSpectrum.MaxValue);
            Assert.Equal(ColorSpectrumShape.Box, colorSpectrum.Shape);
            Assert.Equal(ColorSpectrumComponents.HueSaturation, colorSpectrum.Components);

            colorSpectrum.Color         = Colors.Green;
            colorSpectrum.MinHue        = 10;
            colorSpectrum.MaxHue        = 300;
            colorSpectrum.MinSaturation = 10;
            colorSpectrum.MaxSaturation = 90;
            colorSpectrum.MinValue      = 10;
            colorSpectrum.MaxValue      = 90;
            colorSpectrum.Shape         = ColorSpectrumShape.Ring;
            colorSpectrum.Components    = ColorSpectrumComponents.HueValue;

            Assert.Equal(Colors.Green, colorSpectrum.Color);

            // We'll probably encounter some level of rounding error here,
            // so we want to check that the HSV color is *close* to what's expected,
            // not exactly equal.
            Assert.True(Math.Abs(colorSpectrum.HsvColor.X - 120.0) < 0.1);
            Assert.True(Math.Abs(colorSpectrum.HsvColor.Y - 1.0) < 0.1);
            Assert.True(Math.Abs(colorSpectrum.HsvColor.Z - 0.5) < 0.1);

            Assert.Equal(10, colorSpectrum.MinHue);
            Assert.Equal(300, colorSpectrum.MaxHue);
            Assert.Equal(10, colorSpectrum.MinSaturation);
            Assert.Equal(90, colorSpectrum.MaxSaturation);
            Assert.Equal(10, colorSpectrum.MinValue);
            Assert.Equal(90, colorSpectrum.MaxValue);
            Assert.Equal(ColorSpectrumShape.Ring, colorSpectrum.Shape);
            Assert.Equal(ColorSpectrumComponents.HueValue, colorSpectrum.Components);

            colorSpectrum.HsvColor = new Vector4()
            {
                X = 120.0f, Y = 1.0f, Z = 1.0f, W = 1.0f
            };

            Assert.Equal(Color.FromArgb(255, 0, 255, 0), colorSpectrum.Color);
            Assert.Equal(new Vector4()
            {
                X = 120.0f, Y = 1.0f, Z = 1.0f, W = 1.0f
            }, colorSpectrum.HsvColor);
        }
예제 #5
0
 private void Picker2_ColorChanged(ColorSpectrum sender, ColorChangedEventArgs args)
 {
     if (muted)
     {
         return;
     }
     Color = picker2.Color;
 }
예제 #6
0
        public input_item(Devices.DeviceKeys key, float progress, ColorSpectrum spectrum)
        {
            this.key      = key;
            this.progress = progress;
            this.spectrum = spectrum;

            type = input_type.Spectrum;
        }
예제 #7
0
        public override void UpdateLights(EffectFrame frame)
        {
            Queue <EffectLayer> layers = new Queue <EffectLayer>();

            long time = Utils.Time.GetMillisecondsSinceEpoch();

            if (Global.Configuration.skype_overlay_settings.mm_enabled)
            {
                if (_missed_messages_count > 0)
                {
                    EffectLayer skype_missed_messages = new EffectLayer("Overlay - Skype Missed Messages");

                    ColorSpectrum mm_spec = new ColorSpectrum(Global.Configuration.skype_overlay_settings.mm_color_primary, Global.Configuration.skype_overlay_settings.mm_color_secondary, Global.Configuration.skype_overlay_settings.mm_color_primary);
                    Color         color   = Color.Orange;

                    if (Global.Configuration.skype_overlay_settings.mm_blink)
                    {
                        color = mm_spec.GetColorAt((time % 2000L) / 2000.0f);
                    }
                    else
                    {
                        color = mm_spec.GetColorAt(0);
                    }

                    skype_missed_messages.Set(Global.Configuration.skype_overlay_settings.mm_sequence, color);

                    layers.Enqueue(skype_missed_messages);
                }
            }

            if (Global.Configuration.skype_overlay_settings.call_enabled)
            {
                if (_is_calling)
                {
                    EffectLayer skype_ringing_call = new EffectLayer("Overlay - Skype Ringing Call");

                    ColorSpectrum mm_spec = new ColorSpectrum(Global.Configuration.skype_overlay_settings.call_color_primary, Global.Configuration.skype_overlay_settings.call_color_secondary, Global.Configuration.skype_overlay_settings.call_color_primary);
                    Color         color   = Color.Green;

                    if (Global.Configuration.skype_overlay_settings.call_blink)
                    {
                        color = mm_spec.GetColorAt((time % 2000L) / 2000.0f);
                    }
                    else
                    {
                        color = mm_spec.GetColorAt(0);
                    }

                    skype_ringing_call.Set(Global.Configuration.skype_overlay_settings.call_sequence, color);

                    layers.Enqueue(skype_ringing_call);
                }
            }


            frame.AddOverlayLayers(layers.ToArray());
        }
예제 #8
0
        private void Picker1_ColorChanged(ColorSpectrum sender, ColorChangedEventArgs args)
        {
            if (muted)
            {
                return;
            }
            muted = true;
            var x     = sender.HsvColor;
            var color = picker2.HsvColor;

            picker2.HsvColor = new System.Numerics.Vector4(sender.HsvColor.X, color.Y, color.Z, color.W);
            Color            = picker2.Color;
            ColorChanged?.Invoke(this, new EventArgs());
            muted = false;
        }
예제 #9
0
        private int SpectrumBinarizedValue(Color color, ColorSpectrum spectrum)
        {
            Func <Color, int, int, bool> predicate;

            Threshold[] threshold;
            string      template;

            switch (spectrum)
            {
            case ColorSpectrum.Red:
                predicate = (c, l, r) => c.R > l && c.R < r;
                threshold = _redThresholds;
                template  = _redTemplate;
                break;

            case ColorSpectrum.Green:
                predicate = (c, l, r) => c.G > l && c.G < r;
                threshold = _greenThresholds;
                template  = _greenTemplate;
                break;

            case ColorSpectrum.Blue:
                predicate = (c, l, r) => c.B > l && c.B < r;
                threshold = _blueThresholds;
                template  = _blueTemplate;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(spectrum), spectrum, null);
            }

            var value = 0;
            var left  = -1;

            for (var index = 0; index <= threshold.Length; index++)
            {
                var right = index == threshold.Length ? 256 : threshold[index].Value;
                if (predicate(color, left, right))
                {
                    value = int.Parse(template[index].ToString()) * 255;
                    break;
                }

                left = right;
            }

            return(value);
        }
예제 #10
0
        public static Bitmap GetSpectrum(this Bitmap b, ColorSpectrum cs, bool actualspectrum = false)
        {
            if (b == null)
            {
                return(b);
            }
            Bitmap ret = new Bitmap(b.Width, b.Height);

            for (int i = 0; i < b.Width; i++)
            {
                for (int j = 0; j < b.Height; j++)
                {
                    Color c = b.GetPixel(i, j);
                    switch (cs)
                    {
                    case ColorSpectrum.Red:
                        c = Color.FromArgb(c.A, c.R, c.R, c.R);
                        if (actualspectrum)
                        {
                            c = Color.FromArgb(c.A, c.R, 0, 0);
                        }
                        break;

                    case ColorSpectrum.Green:
                        c = Color.FromArgb(c.A, c.G, c.G, c.G);
                        if (actualspectrum)
                        {
                            c = Color.FromArgb(c.A, 0, c.G, 0);
                        }
                        break;

                    case ColorSpectrum.Blue:
                        c = Color.FromArgb(c.A, c.B, c.B, c.B);
                        if (actualspectrum)
                        {
                            c = Color.FromArgb(c.A, 0, 0, c.B);
                        }
                        break;

                    default:
                        break;
                    }
                    ret.SetPixel(i, j, c);
                }
            }
            return(ret);
        }
예제 #11
0
        private void OnHuePressed(object sender, PointerRoutedEventArgs e)
        {
            ChangeHue(e.GetCurrentPoint(ColorSpectrum).Position.Y);
            ColorSpectrum.CapturePointer(e.Pointer);

            void Moved(object s, PointerRoutedEventArgs args)
            {
                ChangeHue(args.GetCurrentPoint(ColorSpectrum).Position.Y);
            }

            void Released(object s, PointerRoutedEventArgs args)
            {
                ColorSpectrum.ReleasePointerCapture(args.Pointer);
                ChangeHue(args.GetCurrentPoint(ColorSpectrum).Position.Y);
                ColorSpectrum.PointerMoved    -= Moved;
                ColorSpectrum.PointerReleased -= Released;
            }

            ColorSpectrum.PointerMoved    += Moved;
            ColorSpectrum.PointerReleased += Released;
        }
예제 #12
0
    public EffectLayer[] UpdateLights(ScriptSettings settings, IGameState state = null)
    {
        Queue <EffectLayer> layers = new Queue <EffectLayer>();

        EffectLayer layer = new EffectLayer(this.ID);

        layer.PercentEffect(Color.Purple, Color.Green, new KeySequence(new[] { DeviceKeys.F12, DeviceKeys.F11, DeviceKeys.F10, DeviceKeys.F9, DeviceKeys.F8, DeviceKeys.F7, DeviceKeys.F6, DeviceKeys.F5, DeviceKeys.F4, DeviceKeys.F3, DeviceKeys.F2, DeviceKeys.F1 }), DateTime.Now.Second % 20D, 20D);
        layers.Enqueue(layer);

        EffectLayer layer_swirl = new EffectLayer(this.ID + " - Swirl");

        layer_swirl.PercentEffect(Color.Blue, Color.Black, new KeySequence(new[] { DeviceKeys.NUM_ONE, DeviceKeys.NUM_FOUR, DeviceKeys.NUM_SEVEN, DeviceKeys.NUM_EIGHT, DeviceKeys.NUM_NINE, DeviceKeys.NUM_SIX, DeviceKeys.NUM_THREE, DeviceKeys.NUM_TWO }), DateTime.Now.Millisecond % 500D, 500D, PercentEffectType.Progressive_Gradual);
        layers.Enqueue(layer_swirl);

        EffectLayer layer_blinking = new EffectLayer(this.ID + " - Blinking Light");

        ColorSpectrum blink_spec  = new ColorSpectrum(Color.Red, Color.Black, Color.Red);
        Color         blink_color = blink_spec.GetColorAt(DateTime.Now.Millisecond / 1000.0f);

        layer_blinking.Set(DeviceKeys.NUM_FIVE, blink_color);
        layers.Enqueue(layer_blinking);

        return(layers.ToArray());
    }
예제 #13
0
        public override void UpdateLights(EffectFrame frame)
        {
            currenttime = Utils.Time.GetMillisecondsSinceEpoch();

            Queue <EffectLayer> layers = new Queue <EffectLayer>();

            //update background
            if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_enabled)
            {
                EffectLayer bg_layer = new EffectLayer("Payday 2 - Background");

                Color bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ambient_color;

                if ((level_phase == LevelPhase.Assault || level_phase == LevelPhase.Winters) && game_state == GameStates.Ingame)
                {
                    if (level_phase == LevelPhase.Assault)
                    {
                        bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_color;
                    }
                    else if (level_phase == LevelPhase.Winters)
                    {
                        bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).winters_color;
                    }

                    double blend_percent = Math.Pow(Math.Sin(((currenttime % 1300L) / 1300.0D) * (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_speed_mult * 2.0D * Math.PI), 2.0D);

                    bg_color = Utils.ColorUtils.BlendColors((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_fade_color, bg_color, blend_percent);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_animation_enabled)
                    {
                        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:
                         *
                         * / /  ----  / /
                         *
                         */

                        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 ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                    }
                }
                else if (level_phase == LevelPhase.Stealth && game_state == GameStates.Ingame)
                {
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_show_suspicion)
                    {
                        double percentSuspicious = ((double)suspicion_amount / (double)1.0);

                        ColorSpectrum suspicion_spec = new ColorSpectrum((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).low_suspicion_color, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).high_suspicion_color);
                        suspicion_spec.SetColorAt(0.5f, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).medium_suspicion_color);

                        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, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).suspicion_effect_type);

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                        {
                            bg_layer.Set(Devices.DeviceKeys.Peripheral, suspicion_spec.GetColorAt((float)percentSuspicious));
                        }
                    }
                }
                else if (level_phase == LevelPhase.Point_of_no_return && game_state == GameStates.Ingame)
                {
                    ColorSpectrum no_return_spec = new ColorSpectrum(Color.Red, Color.Yellow);

                    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 ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, no_return_color);
                    }
                }
                else
                {
                    bg_layer.Fill(bg_color);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                    }
                }

                layers.Enqueue(bg_layer);
            }

            if (game_state == GameStates.Ingame)
            {
                if (
                    player_state == PlayerState.Mask_Off ||
                    player_state == PlayerState.Standard ||
                    player_state == PlayerState.Jerry1 ||
                    player_state == PlayerState.Jerry2 ||
                    player_state == PlayerState.Tased ||
                    player_state == PlayerState.Bipod ||
                    player_state == PlayerState.Carry
                    )
                {
                    //Update Health
                    EffectLayer hpbar_layer = new EffectLayer("Payday 2 - HP Bar");
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_enabled)
                    {
                        hpbar_layer.PercentEffect((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).healthy_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).hurt_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_sequence,
                                                  (double)health,
                                                  (double)health_max,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_effect_type);
                    }

                    layers.Enqueue(hpbar_layer);

                    //Update Health
                    EffectLayer ammobar_layer = new EffectLayer("Payday 2 - Ammo Bar");
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_enabled)
                    {
                        hpbar_layer.PercentEffect((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).noammo_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_sequence,
                                                  (double)clip,
                                                  (double)clip_max,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_effect_type);
                    }

                    layers.Enqueue(ammobar_layer);
                }
                else if (player_state == PlayerState.Incapacitated || player_state == PlayerState.Bleed_out || player_state == PlayerState.Fatal)
                {
                    int incapAlpha = (int)(down_time > 10 ? 0 : 255 * (1.0D - (double)down_time / 10.0D));

                    if (incapAlpha > 255)
                    {
                        incapAlpha = 255;
                    }
                    else if (incapAlpha < 0)
                    {
                        incapAlpha = 0;
                    }

                    Color       incapColor  = Color.FromArgb(incapAlpha, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).downed_color);
                    EffectLayer incap_layer = new EffectLayer("Payday 2 - Incapacitated", incapColor);
                    incap_layer.Set(Devices.DeviceKeys.Peripheral, incapColor);

                    layers.Enqueue(incap_layer);
                }
                else if (player_state == PlayerState.Arrested)
                {
                    Color       arrstedColor   = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).arrested_color;
                    EffectLayer arrested_layer = new EffectLayer("Payday 2 - Arrested", arrstedColor);
                    arrested_layer.Set(Devices.DeviceKeys.Peripheral, arrstedColor);

                    layers.Enqueue(arrested_layer);
                }

                if (isSwanSong && (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_enabled)
                {
                    EffectLayer swansong_layer = new EffectLayer("Payday 2 - Swansong");

                    double blend_percent = Math.Pow(Math.Cos((currenttime % 1300L) / 1300.0D * (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_speed_mult * 2.0D * Math.PI), 2.0D);

                    Color swansongColor = Utils.ColorUtils.MultiplyColorByScalar((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_color, blend_percent);

                    swansong_layer.Fill(swansongColor);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        swansong_layer.Set(Devices.DeviceKeys.Peripheral, swansongColor);
                    }

                    layers.Enqueue(swansong_layer);
                }

                //Update Flashed
                if (flashbang_amount > 0)
                {
                    EffectLayer flashed_layer = new EffectLayer("Payday 2 - Flashed");

                    Color flash_color = Utils.ColorUtils.MultiplyColorByScalar(Color.White, flashbang_amount);

                    flashed_layer.Fill(flash_color);

                    layers.Enqueue(flashed_layer);
                }
            }

            //ColorZones
            EffectLayer cz_layer = new EffectLayer("Payday 2 - Color Zones");

            cz_layer.DrawColorZones((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).lighting_areas.ToArray());
            layers.Enqueue(cz_layer);

            //Scripts
            Global.Configuration.ApplicationProfiles[profilename].UpdateEffectScripts(layers, _game_state);

            frame.AddLayers(layers.ToArray());

            lasttime = currenttime;
        }
예제 #14
0
 public HistogramBuilder([NotNull] Image image, [NotNull] ColorSpectrum spectrum = ColorSpectrum.Blue)
 {
     _image    = image;
     _spectrum = spectrum;
 }
예제 #15
0
 public HistogramBuilder Color(ColorSpectrum spectrum)
 {
     _spectrum = spectrum;
     return(this);
 }
예제 #16
0
        private input_item CreateInputItem(Devices.DeviceKeys key, PointF origin)
        {
            Color primary_c   = Properties.RandomPrimaryColor ? Utils.ColorUtils.GenerateRandomColor() : Properties.PrimaryColor;
            Color secondary_c = Properties.RandomSecondaryColor ? Utils.ColorUtils.GenerateRandomColor() : Properties.SecondaryColor;

            AnimationMix anim_mix = new AnimationMix();

            if (Properties.InteractiveEffect == InteractiveEffects.Wave)
            {
                AnimationTrack wave = new AnimationTrack("Wave effect", 1.0f);
                wave.SetFrame(0.0f,
                              new AnimationCircle(origin, 0, primary_c, Properties.EffectWidth)
                              );
                wave.SetFrame(0.80f,
                              new AnimationCircle(origin, Effects.canvas_width * 0.80f, secondary_c, Properties.EffectWidth)
                              );
                wave.SetFrame(1.00f,
                              new AnimationCircle(origin, Effects.canvas_width + (Properties.EffectWidth / 2), Color.FromArgb(0, secondary_c), Properties.EffectWidth)
                              );
                anim_mix.AddTrack(wave);
            }
            else if (Properties.InteractiveEffect == InteractiveEffects.Wave_Rainbow)
            {
                AnimationTrack rainbowWave = new AnimationTrack("Rainbow Wave", 1.0f);

                rainbowWave.SetFrame(0.0f, new AnimationGradientCircle(origin, 0, new EffectBrush(new ColorSpectrum(ColorSpectrum.Rainbow).Flip()).SetBrushType(EffectBrush.BrushType.Radial), Properties.EffectWidth));
                rainbowWave.SetFrame(1.0f, new AnimationGradientCircle(origin, Effects.canvas_width + (Properties.EffectWidth / 2), new EffectBrush(new ColorSpectrum(ColorSpectrum.Rainbow).Flip()).SetBrushType(EffectBrush.BrushType.Radial), Properties.EffectWidth));

                anim_mix.AddTrack(rainbowWave);
            }
            else if (Properties.InteractiveEffect == InteractiveEffects.Wave_Filled)
            {
                AnimationTrack wave = new AnimationTrack("Filled Wave effect", 1.0f);
                wave.SetFrame(0.0f,
                              new AnimationFilledCircle(origin, 0, primary_c, Properties.EffectWidth)
                              );
                wave.SetFrame(0.80f,
                              new AnimationFilledCircle(origin, Effects.canvas_width * 0.80f, secondary_c, Properties.EffectWidth)
                              );
                wave.SetFrame(1.00f,
                              new AnimationFilledCircle(origin, Effects.canvas_width + (Properties.EffectWidth / 2), Color.FromArgb(0, secondary_c), Properties.EffectWidth)
                              );
                anim_mix.AddTrack(wave);
            }
            else if (Properties.InteractiveEffect == InteractiveEffects.KeyPress)
            {
                ColorSpectrum spec = new ColorSpectrum(primary_c, secondary_c);
                spec = new ColorSpectrum(primary_c, Color.FromArgb(0, secondary_c));
                spec.SetColorAt(0.80f, secondary_c);

                return(new input_item(key, 0.0f, Properties.WaitOnKeyUp, spec));
            }
            else if (Properties.InteractiveEffect == InteractiveEffects.ArrowFlow)
            {
                AnimationTrack arrow = new AnimationTrack("Arrow Flow effect", 1.0f);
                arrow.SetFrame(0.0f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(origin, origin, primary_c, Properties.EffectWidth),
                    new AnimationLine(origin, origin, primary_c, Properties.EffectWidth)
                }
                                   )
                               );
                arrow.SetFrame(0.33f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(origin, new PointF(origin.X + Effects.canvas_width * 0.33f, origin.Y), Utils.ColorUtils.BlendColors(primary_c, secondary_c, 0.33D), Properties.EffectWidth),
                    new AnimationLine(origin, new PointF(origin.X - Effects.canvas_width * 0.33f, origin.Y), Utils.ColorUtils.BlendColors(primary_c, secondary_c, 0.33D), Properties.EffectWidth)
                }
                                   )
                               );
                arrow.SetFrame(0.66f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(new PointF(origin.X + Effects.canvas_width * 0.33f, origin.Y), new PointF(origin.X + Effects.canvas_width * 0.66f, origin.Y), secondary_c, Properties.EffectWidth),
                    new AnimationLine(new PointF(origin.X - Effects.canvas_width * 0.33f, origin.Y), new PointF(origin.X - Effects.canvas_width * 0.66f, origin.Y), secondary_c, Properties.EffectWidth)
                }
                                   )
                               );
                arrow.SetFrame(1.0f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(new PointF(origin.X + Effects.canvas_width * 0.66f, origin.Y), new PointF(origin.X + Effects.canvas_width, origin.Y), Color.FromArgb(0, secondary_c), Properties.EffectWidth),
                    new AnimationLine(new PointF(origin.X - Effects.canvas_width * 0.66f, origin.Y), new PointF(origin.X - Effects.canvas_width, origin.Y), Color.FromArgb(0, secondary_c), Properties.EffectWidth)
                }
                                   )
                               );
                anim_mix.AddTrack(arrow);
            }

            return(new input_item(key, 0.0f, Properties.WaitOnKeyUp, anim_mix));
        }
예제 #17
0
        public override void UpdateLights(EffectFrame frame)
        {
            previoustime = currenttime;
            currenttime  = Utils.Time.GetMillisecondsSinceEpoch();

            Queue <EffectLayer> layers = new Queue <EffectLayer>();
            EffectLayer         layer;

            effect_cfg.speed = Global.Configuration.idle_speed;

            switch (Global.Configuration.idle_type)
            {
            case IdleEffects.Dim:
                layer = new EffectLayer("Idle - Dim");

                layer.Fill(Color.FromArgb(125, 0, 0, 0));

                layers.Enqueue(layer);
                break;

            case IdleEffects.ColorBreathing:
                layer = new EffectLayer("Idle - Color Breathing");

                Color breathe_bg_color = Global.Configuration.idle_effect_secondary_color;
                layer.Fill(breathe_bg_color);

                float sine = (float)Math.Pow(Math.Sin((double)((currenttime % 10000L) / 10000.0f) * 2 * Math.PI * Global.Configuration.idle_speed), 2);

                layer.Fill(Color.FromArgb((byte)(sine * 255), Global.Configuration.idle_effect_primary_color));

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainbowShift_Horizontal:
                layer = new EffectLayer("Idle - Rainbow Shift (Horizontal)", LayerEffects.RainbowShift_Horizontal, effect_cfg);

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainbowShift_Vertical:
                layer = new EffectLayer("Idle - Rainbow Shift (Vertical)", LayerEffects.RainbowShift_Vertical, effect_cfg);

                layers.Enqueue(layer);
                break;

            case IdleEffects.StarFall:
                layer = new EffectLayer("Idle - Starfall");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (stars.ContainsKey(star))
                        {
                            stars[star] = 1.0f;
                        }
                        else
                        {
                            stars.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                Devices.DeviceKeys[] stars_keys = stars.Keys.ToArray();

                foreach (Devices.DeviceKeys star in stars_keys)
                {
                    layer.Set(star, Utils.ColorUtils.MultiplyColorByScalar(Global.Configuration.idle_effect_primary_color, stars[star]));
                    stars[star] -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainFall:
                layer = new EffectLayer("Idle - Rainfall");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (raindrops.ContainsKey(star))
                        {
                            raindrops[star] = 1.0f;
                        }
                        else
                        {
                            raindrops.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                Devices.DeviceKeys[] raindrops_keys = raindrops.Keys.ToArray();

                ColorSpectrum drop_spec = new ColorSpectrum(Global.Configuration.idle_effect_primary_color, Color.FromArgb(0, Global.Configuration.idle_effect_primary_color));

                foreach (Devices.DeviceKeys raindrop in raindrops_keys)
                {
                    PointF pt = Effects.GetBitmappingFromDeviceKey(raindrop).Center;

                    float transition_value = 1.0f - raindrops[raindrop];
                    float radius           = transition_value * Effects.canvas_biggest;

                    layer.GetGraphics().DrawEllipse(new Pen(drop_spec.GetColorAt(transition_value), 2),
                                                    pt.X - radius,
                                                    pt.Y - radius,
                                                    2 * radius,
                                                    2 * radius);

                    raindrops[raindrop] -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.Blackout:
                layer = new EffectLayer("Idle - Blackout");

                layer.Fill(Color.Black);

                layers.Enqueue(layer);
                break;

            case IdleEffects.Matrix:
                layer = new EffectLayer("Idle - Matrix");

                if (nextstarset < currenttime)
                {
                    Color darker_primary = Utils.ColorUtils.MultiplyColorByScalar(Global.Configuration.idle_effect_primary_color, 0.50);

                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        int   width_start = randomizer.Next(Effects.canvas_width);
                        float delay       = randomizer.Next(550) / 100.0f;
                        int   random_id   = randomizer.Next(125536789);

                        //Create animation
                        AnimationTrack matrix_line =
                            new AnimationTrack("Matrix Line (Head) " + random_id, 0.0f).SetFrame(
                                0.0f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, -3, width_start, 0, Global.Configuration.idle_effect_primary_color, 3)).SetFrame(
                                0.5f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height, width_start, Effects.canvas_height + 3, Global.Configuration.idle_effect_primary_color, 3)).SetShift(
                                (currenttime % 1000000L) / 1000.0f + delay
                                );

                        AnimationTrack matrix_line_trail =
                            new AnimationTrack("Matrix Line (Trail) " + random_id, 0.0f).SetFrame(
                                0.0f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, -12, width_start, -3, darker_primary, 3)).SetFrame(
                                0.5f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height - 12, width_start, Effects.canvas_height, darker_primary, 3)).SetFrame(
                                0.75f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height, width_start, Effects.canvas_height, darker_primary, 3)).SetShift(
                                (currenttime % 1000000L) / 1000.0f + delay
                                );

                        matrix_lines.AddTrack(matrix_line);
                        matrix_lines.AddTrack(matrix_line_trail);
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                using (Graphics g = layer.GetGraphics())
                {
                    matrix_lines.Draw(g, (currenttime % 1000000L) / 1000.0f);
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainFallSmooth:
                layer = new EffectLayer("Idle - RainfallSmooth");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (raindrops.ContainsKey(star))
                        {
                            raindrops[star] = 1.0f;
                        }
                        else
                        {
                            raindrops.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }
                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                ColorSpectrum drop_spec2 = new ColorSpectrum(
                    Global.Configuration.idle_effect_primary_color,
                    Color.FromArgb(0, Global.Configuration.idle_effect_primary_color));

                var drops = raindrops.Keys.ToArray().Select(d =>
                {
                    PointF pt             = Effects.GetBitmappingFromDeviceKey(d).Center;
                    float transitionValue = 1.0f - raindrops[d];
                    float radius          = transitionValue * Effects.canvas_biggest;
                    raindrops[d]         -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                    return(new Tuple <Devices.DeviceKeys, PointF, float, float>(d, pt, transitionValue, radius));
                }).Where(d => d.Item3 <= 1.5).ToArray();

                float circleHalfThickness = 1f;

                foreach (var key in allKeys)
                {
                    var keyInfo = Effects.GetBitmappingFromDeviceKey(key);

                    // For easy calculation every button considered as circle with this radius
                    var btnRadius = ((keyInfo.Width + keyInfo.Height) / 4f);
                    if (btnRadius <= 0)
                    {
                        continue;
                    }

                    foreach (var raindrop in drops)
                    {
                        float circleInEdge  = (raindrop.Item4 - circleHalfThickness);
                        float circleOutEdge = (raindrop.Item4 + circleHalfThickness);
                        circleInEdge  *= circleInEdge;
                        circleOutEdge *= circleOutEdge;

                        float xKey        = Math.Abs(keyInfo.Center.X - raindrop.Item2.X);
                        float yKey        = Math.Abs(keyInfo.Center.Y - raindrop.Item2.Y);
                        float xKeyInEdge  = xKey - btnRadius;
                        float xKeyOutEdge = xKey + btnRadius;
                        float yKeyInEdge  = yKey - btnRadius;
                        float yKeyOutEdge = yKey + btnRadius;
                        float keyInEdge   = xKeyInEdge * xKeyInEdge + yKeyInEdge * yKeyInEdge;
                        float keyOutEdge  = xKeyOutEdge * xKeyOutEdge + yKeyOutEdge * yKeyOutEdge;

                        var btnDiameter    = keyOutEdge - keyInEdge;
                        var inEdgePercent  = (circleOutEdge - keyInEdge) / btnDiameter;
                        var outEdgePercent = (keyOutEdge - circleInEdge) / btnDiameter;
                        var percent        = Math.Min(1, Math.Max(0, inEdgePercent))
                                             + Math.Min(1, Math.Max(0, outEdgePercent)) - 1f;

                        if (percent > 0)
                        {
                            layer.Set(key, (Color)EffectColor.BlendColors(
                                          new EffectColor(layer.Get(key)),
                                          new EffectColor(drop_spec2.GetColorAt(raindrop.Item3)), percent));
                        }
                    }
                }
                layers.Enqueue(layer);
                break;

            default:
                break;
            }

            frame.AddOverlayLayers(layers.ToArray());
        }
예제 #18
0
    //methoden


    //als de kleuren overeen komen mag hij bewegen in de richting die hij wilt, als ze niet overeen komen gaat hij niks doen
    //heeft coordinaten overgekregen van entity die die heeft van object in scene (overerving), gaat nu gaan checken welke kleuren er "voor" de player liggen (halve block) en beslissen of hij daarop mag staan

    public void Move(Direction direction)
    {
        //lokale variabelen

        //gaan een duidelijkere naam geven
        int         step = 1;
        Coordinates positionPlayerSpacePlusMoveSpace;
        int         widthPlayerSpacePlusMoveSpace;
        int         heightPlayerSpacePlusMoveSpace; //de hoogtes en breedtes van de ruimte die de player inneemt PLUS de ruimte waar hij naartoe gaat gaan


        //voorlopig hebben deze variabelen nog deze waardes, de oude positie, en de oude hoogte en breedte
        positionPlayerSpacePlusMoveSpace = Position; //position property van entity om de oude positie weer te geven
        widthPlayerSpacePlusMoveSpace    = Width;    //properties van entity, hoeveel ruimte de player inneemt
        heightPlayerSpacePlusMoveSpace   = Height;



        //hier krijgen deze variabelen een nieuwe waarde
        //we maken een nieuw gebied "selecteerbaar", namelijk de ruimte die de speler inneemt EN de ruimte waar hij mogelijk naartoe kan

        switch (direction)                                      //Als de direction (parameter die je meegeeft bij het oproepen van de methode) gelijk is aan..
        {
        case Direction.Up:                                      //up gaat hij..
            heightPlayerSpacePlusMoveSpace             += step; //hoogte van ruimte die de speler inneemt + 1 blockje vanboven selecteren --> hoogte is dan bv 3 ipv. 2 (2 is dan Width, originele hoogte van ruimte die speler inneemt = de originele waarde van heightPlayerSpacePlusMoveSpace) (block waar player op staat --> 4 blockjes, 2 hoog, 2 breed)
            positionPlayerSpacePlusMoveSpace.YPosition -= step; //veranderen de oude positie (altijd in de linkerbovenhoek van onze Block) -1 aangezien hoe hoger je in ons grid zit, hoe lager het getal van je positie bv 1tje naar boven --> van y positie 4 naar 3 bv. Positie van ons nieuw geselecteerd gebied ligt 1 tje hoger dan enkel de ruimte waar de speler zich bevind
            break;

        case Direction.Down:
            heightPlayerSpacePlusMoveSpace += step; //hoogte gaat hier ook 3 zijn want het is nu gwn de ruimte die de speler inneemt + 1 blockje vanonder
            //hier verandert je position niet, aangezien de positie nog altijd in de linkerbovenhoek zit van ons groot veld dat we nu beschikbaar stellen
            break;

        case Direction.Left:
            widthPlayerSpacePlusMoveSpace += step;              //breedte neemt ook met 1 toe, ruimte van player + 1 blockje aan de linkerkant
            positionPlayerSpacePlusMoveSpace.XPosition -= step; //veranderen de oude positie -1 aangezien hoe meer naar links je in ons grid zit, hoe lager het getal van je positie bv 1tje naar links --> van x positie 4 naar 3 bv. Positie van ons nieuw geselecteerd gebied ligt 1 tje meer naar links dan enkel de ruimte waar de speler zich bevind
            break;

        case Direction.Right:
            widthPlayerSpacePlusMoveSpace += step; //ruimte van player + 1 blockje aan de rechterkant
            break;

            //default niet nodig aangezien je enkel die 4 dingen kan hebben bij de enum direction
        }


        // 4 dingen checken: of hij vanboven, vanonder, links of rechts niet uit het grid valt (geen blockjes meer zijn, aan de rand van je grid zit)
        if (positionPlayerSpacePlusMoveSpace.YPosition < 0 ||                                                                           //of positie niet vanboven uit grid valt
            positionPlayerSpacePlusMoveSpace.XPosition < 0 ||                                                                           //of positie links niet uit grid valt
            positionPlayerSpacePlusMoveSpace.YPosition + heightPlayerSpacePlusMoveSpace - step >= GameController.CurrentLevel.Height || //vanonder uit grid, positie (bv positie 5 (y coordinaat) + (+, hoe meer naar onder je gaat) 3 hoog (- 1 (omdat je het deel van het grid waar je naar gaat moven ook meetelt)) = 7 (eindigt op coördinaat 7, als je grid maar 6 blokjes hoog is --> valt hij uit grid, mag niet
            positionPlayerSpacePlusMoveSpace.XPosition + widthPlayerSpacePlusMoveSpace - step >= GameController.CurrentLevel.Width)     //rechts uit grid
        {
            return;                                                                                                                     //kheb een resultaat denkt hij, stopt met de methode move --> gaat niet moven
        }


        //nieuwe variabelen aanmaken 2d array van blocks --> met methode GetPartOfGrid van level gaan we van het deel dat we nu net geselecteerd hebben,ook echt een gridje op zich maken
        Block[,] gridPlayerSpaceMoveSpace = GameController.CurrentLevel.GetPartOfGrid(positionPlayerSpacePlusMoveSpace,
                                                                                      widthPlayerSpacePlusMoveSpace,
                                                                                      heightPlayerSpacePlusMoveSpace);


        //Lijstje om alle kleuren die we uit ons gridje gaan halen gaan verzamelen --> de kleuren waar hij op staat en waar hij op wilt gaan staan
        List <BlockColor> listColorsInGrid = new List <BlockColor>();



        //we gaan nu alle blockjes in ons nieuw gridje doorlopen
        foreach (Block tempBlock in gridPlayerSpaceMoveSpace)
        {
            BlockColor colorOfBlock = tempBlock.Color; //De kleur van een bepaalde block (met coördinaten x en y) Color = property van Block, in nieuwe variabele gestoken om het korter te kunnen schrijven


            //gaan nu alle kleuren die zich in het grid bevinden verzamelen (willen geen dubbele in de lijst)

            bool isAlreadyAddedToColorList = false; //voorlopig op false zetten, we doorlopen deze code meerdere keren dus willen geen dubbele elementen in de lijst



            foreach (BlockColor blockColorList in listColorsInGrid) //listColors kunnen er al mogelijk kleuren inzitten, we willen niet 2 keer dezelfde kleur erin hebben zitten dus gaan nu checken welke kleuren er al in zitten in listColors
            {
                if (blockColorList == colorOfBlock)                 //gaan de kleur van ons blockje waar we op dit moment zitten in ons grid gaan vergelijken met alle kleuren die al in de listColors zitten
                {
                    isAlreadyAddedToColorList = true;               //als die eraan gelijk is (zit er al in dus en willen we niet nog een keer erin), dan zetten we deze op true
                }
            }//einde foreach, hebben nu een verzameling waar de kleuren in zitten die moeten worden toegevoegd



            if (!isAlreadyAddedToColorList)         //enkel als het nog niet geadd is (er nog niet in zit)
            {
                listColorsInGrid.Add(colorOfBlock); // gaan we hem toevoegen aan de listColors lijst
            }
        }//einde doorlopen grid



        if (listColorsInGrid.Count == 1 ||                                                                       //als er maar 1 kleur in zit (de kleur waar hij op staat is hetzelfde als de kleur waar hij naartoe wilt)
            (listColorsInGrid.Count == 2 && ColorSpectrum.IsAdjacent(listColorsInGrid[0], listColorsInGrid[1]))) //kleur waar hij op staat is anders dan de kleur waar hij naartoe wilt, gaat dan checken of ze adjacent zijn (index 0 en index 1 gaan nemen als de parameters --> de 2 blockcolors die je gaat vergelijken)
        {
            //dan mag hij ook effectief zich gaan verplaatsen naar waar hij wilt  --> position aan gaan passen

            Coordinates newPosition = Position; //de momentele positie hier al in steken (voorlopig), we gaan hem aanpassen

            switch (direction)
            {
            case Direction.Up:
                newPosition.YPosition -= step; //positie gaat 1tje naar boven --> boven is -
                break;

            case Direction.Down:
                newPosition.YPosition += step;
                break;

            case Direction.Left:
                newPosition.XPosition -= step;//positie gaat 1tje naar links --> links is -
                break;

            case Direction.Right:
                newPosition.XPosition += step;

                break;
            }//einde switch


            Position = newPosition; //nieuwe positie in de oude gestoken. (is vervangen nu)
        }//einde if voor de move te bepalen
    }//einde move
예제 #19
0
        public override void UpdateLights(EffectFrame frame)
        {
            Queue <EffectLayer> layers = new Queue <EffectLayer>();

            Process[] process_search = Process.GetProcessesByName("RocketLeague");

            if (process_search.Length != 0)
            {
                using (MemoryReader memread = new MemoryReader(process_search[0]))
                {
                    team = memread.ReadInt(pointers.Team.baseAddress, pointers.Team.pointers);

                    team1_score = memread.ReadInt(pointers.Orange_score.baseAddress, pointers.Orange_score.pointers); //Orange Team
                    team2_score = memread.ReadInt(pointers.Blue_score.baseAddress, pointers.Blue_score.pointers);     //Blue Team

                    boost_amount = memread.ReadFloat(pointers.Boost_amount.baseAddress, pointers.Boost_amount.pointers);
                }
            }


            if ((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_enabled)
            {
                EffectLayer bg_layer = new EffectLayer("Rocket League - Background");

                if (GameEvent_RocketLeague.team == 1 && (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_use_team_color)
                {
                    bg_layer.Fill((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_team_1);
                }
                else if (GameEvent_RocketLeague.team == 0 && (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_use_team_color)
                {
                    bg_layer.Fill((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_team_2);
                }
                else
                {
                    bg_layer.Fill((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_ambient_color);
                }

                if ((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_show_team_score_split)
                {
                    if (team1_score != 0 || team2_score != 0)
                    {
                        int total_score = team1_score + team2_score;


                        LinearGradientBrush the__split_brush =
                            new LinearGradientBrush(
                                new Point(0, 0),
                                new Point(Effects.canvas_biggest, 0),
                                Color.Red, Color.Red);
                        Color[] colors = new Color[]
                        {
                            (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_team_1,     //Orange
                            (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_team_1,     //Orange "Line"
                            (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_team_2,     //Blue "Line"
                            (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).bg_team_2      //Blue
                        };
                        int     num_colors      = colors.Length;
                        float[] blend_positions = new float[num_colors];

                        if (team1_score > team2_score)
                        {
                            blend_positions[0] = 0.0f;
                            blend_positions[1] = ((float)team1_score / (float)total_score) - 0.01f;
                            blend_positions[2] = ((float)team1_score / (float)total_score) + 0.01f;
                            blend_positions[3] = 1.0f;
                        }
                        else if (team1_score < team2_score)
                        {
                            blend_positions[0] = 0.0f;
                            blend_positions[1] = (1.0f - ((float)team2_score / (float)total_score)) - 0.01f;
                            blend_positions[2] = (1.0f - ((float)team2_score / (float)total_score)) + 0.01f;
                            blend_positions[3] = 1.0f;
                        }
                        else
                        {
                            blend_positions[0] = 0.0f;
                            blend_positions[1] = 0.49f;
                            blend_positions[2] = 0.51f;
                            blend_positions[3] = 1.0f;
                        }

                        ColorBlend color_blend = new ColorBlend();
                        color_blend.Colors    = colors;
                        color_blend.Positions = blend_positions;
                        the__split_brush.InterpolationColors = color_blend;

                        bg_layer.Fill(the__split_brush);
                    }
                }

                layers.Enqueue(bg_layer);
            }

            if ((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).boost_enabled)
            {
                EffectLayer boost_layer = new EffectLayer("Rocket League - Boost Indicator");

                double percentOccupied = boost_amount;

                ColorSpectrum boost_spec = new ColorSpectrum((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).boost_low, (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).boost_high);
                boost_spec.SetColorAt(0.75f, (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).boost_mid);

                boost_layer.PercentEffect(boost_spec, (Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).boost_sequence, percentOccupied, 1.0D, PercentEffectType.Progressive_Gradual);

                if ((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).boost_peripheral_use)
                {
                    boost_layer.Set(Devices.DeviceKeys.Peripheral, boost_spec.GetColorAt((float)Math.Round(percentOccupied, 1)));
                }

                layers.Enqueue(boost_layer);
            }

            //ColorZones
            EffectLayer cz_layer = new EffectLayer("Rocket League - Color Zones");

            cz_layer.DrawColorZones((Global.Configuration.ApplicationProfiles[profilename].Settings as RocketLeagueSettings).lighting_areas.ToArray());
            layers.Enqueue(cz_layer);

            //Scripts
            Global.Configuration.ApplicationProfiles[profilename].UpdateEffectScripts(layers);

            frame.AddLayers(layers.ToArray());
        }
예제 #20
0
        private input_item CreateInputItem(Devices.DeviceKeys key, PointF origin)
        {
            Color primary_c   = Properties.RandomPrimaryColor ? Utils.ColorUtils.GenerateRandomColor() : Properties.PrimaryColor;
            Color secondary_c = Properties.RandomSecondaryColor ? Utils.ColorUtils.GenerateRandomColor() : Properties.SecondaryColor;

            AnimationMix anim_mix = new AnimationMix();

            if (Properties.InteractiveEffect == InteractiveEffects.Wave)
            {
                AnimationTrack wave = new AnimationTrack("Wave effect", 1.0f);
                wave.SetFrame(0.0f,
                              new AnimationCircle(origin, 0, primary_c, Properties.EffectWidth)
                              );
                wave.SetFrame(0.80f,
                              new AnimationCircle(origin, Effects.canvas_width * 0.80f, secondary_c, Properties.EffectWidth)
                              );
                wave.SetFrame(1.00f,
                              new AnimationCircle(origin, Effects.canvas_width, Color.FromArgb(0, secondary_c), Properties.EffectWidth)
                              );
                anim_mix.AddTrack(wave);
            }
            else if (Properties.InteractiveEffect == InteractiveEffects.Wave_Rainbow)
            {
                float dT = (float)(Math.Sqrt((double)Properties.EffectWidth - 0.7) * Math.Sqrt(12.0)) * 0.0065f;

                AnimationTrack wave_red       = new AnimationTrack("Wave effect (red)", 1.00f - dT * 6);
                AnimationTrack wave_orange    = new AnimationTrack("Wave effect (orange)", 1.00f - dT * 5);
                AnimationTrack wave_yellow    = new AnimationTrack("Wave effect (yellow)", 1.00f - dT * 4);
                AnimationTrack wave_green     = new AnimationTrack("Wave effect (green)", 1.00f - dT * 3);
                AnimationTrack wave_lightblue = new AnimationTrack("Wave effect (light blue)", 1.00f - dT * 2);
                AnimationTrack wave_blue      = new AnimationTrack("Wave effect (blue)", 1.00f - dT * 1);
                AnimationTrack wave_purple    = new AnimationTrack("Wave effect (purple)", 1.00f);

                wave_red.SetFrame(0.0f,
                                  new AnimationCircle(origin, 0, Color.Red, Properties.EffectWidth)
                                  );
                wave_red.SetFrame(1.00f - dT * 6,
                                  new AnimationCircle(origin, Effects.canvas_width, Color.Red, Properties.EffectWidth)
                                  );

                wave_orange.SetFrame(0.0f,
                                     new AnimationCircle(origin, 0, Color.Orange, Properties.EffectWidth)
                                     );
                wave_orange.SetFrame(0.0f + dT,
                                     new AnimationCircle(origin, 0, Color.Orange, Properties.EffectWidth)
                                     );
                wave_orange.SetFrame(1.00f - dT * 5,
                                     new AnimationCircle(origin, Effects.canvas_width, Color.Orange, Properties.EffectWidth)
                                     );

                wave_yellow.SetFrame(0.0f,
                                     new AnimationCircle(origin, 0, Color.Yellow, Properties.EffectWidth)
                                     );
                wave_yellow.SetFrame(0.0f + dT * 2,
                                     new AnimationCircle(origin, 0, Color.Yellow, Properties.EffectWidth)
                                     );
                wave_yellow.SetFrame(1.00f - dT * 4,
                                     new AnimationCircle(origin, Effects.canvas_width, Color.Yellow, Properties.EffectWidth)
                                     );

                wave_green.SetFrame(0.0f,
                                    new AnimationCircle(origin, 0, Color.Green, Properties.EffectWidth)
                                    );
                wave_green.SetFrame(0.0f + dT * 3,
                                    new AnimationCircle(origin, 0, Color.Green, Properties.EffectWidth)
                                    );
                wave_green.SetFrame(1.00f - dT * 3,
                                    new AnimationCircle(origin, Effects.canvas_width, Color.Green, Properties.EffectWidth)
                                    );

                wave_lightblue.SetFrame(0.0f,
                                        new AnimationCircle(origin, 0, Color.Blue, Properties.EffectWidth)
                                        );
                wave_lightblue.SetFrame(0.0f + dT * 4,
                                        new AnimationCircle(origin, 0, Color.Blue, Properties.EffectWidth)
                                        );
                wave_lightblue.SetFrame(1.00f - dT * 2,
                                        new AnimationCircle(origin, Effects.canvas_width, Color.Blue, Properties.EffectWidth)
                                        );

                wave_blue.SetFrame(0.0f,
                                   new AnimationCircle(origin, 0, Color.DarkBlue, Properties.EffectWidth)
                                   );
                wave_blue.SetFrame(0.0f + dT * 5,
                                   new AnimationCircle(origin, 0, Color.DarkBlue, Properties.EffectWidth)
                                   );
                wave_blue.SetFrame(1.00f - dT,
                                   new AnimationCircle(origin, Effects.canvas_width, Color.DarkBlue, Properties.EffectWidth)
                                   );

                wave_purple.SetFrame(0.0f,
                                     new AnimationCircle(origin, 0, Color.Purple, Properties.EffectWidth)
                                     );
                wave_purple.SetFrame(0.0f + dT * 6,
                                     new AnimationCircle(origin, 0, Color.Purple, Properties.EffectWidth)
                                     );
                wave_purple.SetFrame(1.00f,
                                     new AnimationCircle(origin, Effects.canvas_width, Color.Purple, Properties.EffectWidth)
                                     );

                anim_mix.AddTrack(wave_red);
                anim_mix.AddTrack(wave_orange);
                anim_mix.AddTrack(wave_yellow);
                anim_mix.AddTrack(wave_green);
                anim_mix.AddTrack(wave_lightblue);
                anim_mix.AddTrack(wave_blue);
                anim_mix.AddTrack(wave_purple);
            }
            else if (Properties.InteractiveEffect == InteractiveEffects.Wave_Filled)
            {
                AnimationTrack wave = new AnimationTrack("Filled Wave effect", 1.0f);
                wave.SetFrame(0.0f,
                              new AnimationFilledCircle(origin, 0, primary_c, Properties.EffectWidth)
                              );
                wave.SetFrame(0.80f,
                              new AnimationFilledCircle(origin, Effects.canvas_width * 0.80f, secondary_c, Properties.EffectWidth)
                              );
                wave.SetFrame(1.00f,
                              new AnimationFilledCircle(origin, Effects.canvas_width, Color.FromArgb(0, secondary_c), Properties.EffectWidth)
                              );
                anim_mix.AddTrack(wave);
            }
            else if (Properties.InteractiveEffect == InteractiveEffects.KeyPress)
            {
                ColorSpectrum spec = new ColorSpectrum(primary_c, secondary_c);
                spec = new ColorSpectrum(primary_c, Color.FromArgb(0, secondary_c));
                spec.SetColorAt(0.80f, secondary_c);

                return(new input_item(key, 0.0f, spec));
            }
            else if (Properties.InteractiveEffect == InteractiveEffects.ArrowFlow)
            {
                AnimationTrack arrow = new AnimationTrack("Arrow Flow effect", 1.0f);
                arrow.SetFrame(0.0f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(origin, origin, primary_c, Properties.EffectWidth),
                    new AnimationLine(origin, origin, primary_c, Properties.EffectWidth)
                }
                                   )
                               );
                arrow.SetFrame(0.33f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(origin, new PointF(origin.X + Effects.canvas_width * 0.33f, origin.Y), Utils.ColorUtils.BlendColors(primary_c, secondary_c, 0.33D), Properties.EffectWidth),
                    new AnimationLine(origin, new PointF(origin.X - Effects.canvas_width * 0.33f, origin.Y), Utils.ColorUtils.BlendColors(primary_c, secondary_c, 0.33D), Properties.EffectWidth)
                }
                                   )
                               );
                arrow.SetFrame(0.66f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(new PointF(origin.X + Effects.canvas_width * 0.33f, origin.Y), new PointF(origin.X + Effects.canvas_width * 0.66f, origin.Y), secondary_c, Properties.EffectWidth),
                    new AnimationLine(new PointF(origin.X - Effects.canvas_width * 0.33f, origin.Y), new PointF(origin.X - Effects.canvas_width * 0.66f, origin.Y), secondary_c, Properties.EffectWidth)
                }
                                   )
                               );
                arrow.SetFrame(1.0f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(new PointF(origin.X + Effects.canvas_width * 0.66f, origin.Y), new PointF(origin.X + Effects.canvas_width, origin.Y), Color.FromArgb(0, secondary_c), Properties.EffectWidth),
                    new AnimationLine(new PointF(origin.X - Effects.canvas_width * 0.66f, origin.Y), new PointF(origin.X - Effects.canvas_width, origin.Y), Color.FromArgb(0, secondary_c), Properties.EffectWidth)
                }
                                   )
                               );
                anim_mix.AddTrack(arrow);
            }

            return(new input_item(key, 0.0f, anim_mix));
        }
예제 #21
0
 public Threshold([NotNull] ColorSpectrum spectrum, int value)
 {
     Spectrum = spectrum;
     Value    = value;
 }
예제 #22
0
        public override void UpdateLights(EffectFrame frame)
        {
            previoustime = currenttime;
            currenttime  = Utils.Time.GetMillisecondsSinceEpoch();

            Queue <EffectLayer> layers = new Queue <EffectLayer>();
            EffectLayer         layer;

            effect_cfg.speed = Global.Configuration.idle_speed;

            switch (Global.Configuration.idle_type)
            {
            case IdleEffects.Dim:
                layer = new EffectLayer("Idle - Dim");

                Color dim_color = Color.FromArgb(125, 0, 0, 0);
                layer.Fill(dim_color);

                layers.Enqueue(layer);
                break;

            case IdleEffects.ColorBreathing:
                layer = new EffectLayer("Idle - Color Breathing");

                Color breathe_bg_color = Global.Configuration.idle_effect_secondary_color;
                layer.Fill(breathe_bg_color);

                float sine = (float)Math.Pow(Math.Sin((double)((currenttime % 10000L) / 10000.0f) * 2 * Math.PI * Global.Configuration.idle_speed), 2);

                layer.Fill(Color.FromArgb((byte)(sine * 255), Global.Configuration.idle_effect_primary_color));

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainbowShift_Horizontal:
                layer = new EffectLayer("Idle - Rainbow Shift (Horizontal)", LayerEffects.RainbowShift_Horizontal, effect_cfg);

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainbowShift_Vertical:
                layer = new EffectLayer("Idle - Rainbow Shift (Vertical)", LayerEffects.RainbowShift_Vertical, effect_cfg);

                layers.Enqueue(layer);
                break;

            case IdleEffects.StarFall:
                layer = new EffectLayer("Idle - Starfall");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (stars.ContainsKey(star))
                        {
                            stars[star] = 1.0f;
                        }
                        else
                        {
                            stars.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                Devices.DeviceKeys[] stars_keys = stars.Keys.ToArray();

                foreach (Devices.DeviceKeys star in stars_keys)
                {
                    layer.Set(star, Utils.ColorUtils.MultiplyColorByScalar(Global.Configuration.idle_effect_primary_color, stars[star]));
                    stars[star] -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainFall:
                layer = new EffectLayer("Idle - Rainfall");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (raindrops.ContainsKey(star))
                        {
                            raindrops[star] = 1.0f;
                        }
                        else
                        {
                            raindrops.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                Devices.DeviceKeys[] raindrops_keys = raindrops.Keys.ToArray();

                ColorSpectrum drop_spec = new ColorSpectrum(Global.Configuration.idle_effect_primary_color, Color.FromArgb(0, Global.Configuration.idle_effect_primary_color));

                foreach (Devices.DeviceKeys raindrop in raindrops_keys)
                {
                    EffectPoint pt = Effects.GetBitmappingFromDeviceKey(raindrop).GetCenter();

                    float transition_value = 1.0f - raindrops[raindrop];
                    float radius           = transition_value * Effects.canvas_biggest;

                    layer.GetGraphics().DrawEllipse(new Pen(drop_spec.GetColorAt(transition_value), 2),
                                                    pt.X - radius,
                                                    pt.Y - radius,
                                                    2 * radius,
                                                    2 * radius);

                    raindrops[raindrop] -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                }

                layers.Enqueue(layer);
                break;

            default:
                break;
            }

            frame.AddOverlayLayers(layers.ToArray());
        }
예제 #23
0
 public Tiger(ColorSpectrum color)
 {
     TigerColor = color.ToString();
 }
예제 #24
0
 public Lion(ColorSpectrum color)
 {
     LionColor = color.ToString();
 }
예제 #25
0
        public override void UpdateLights(EffectFrame frame)
        {
            previoustime = currenttime;
            currenttime  = Utils.Time.GetMillisecondsSinceEpoch();

            Queue <EffectLayer> layers = new Queue <EffectLayer>();
            EffectLayer         layer;

            effect_cfg.speed = Global.Configuration.idle_speed;

            switch (Global.Configuration.idle_type)
            {
            case IdleEffects.Dim:
                layer = new EffectLayer("Idle - Dim");

                layer.Fill(Color.FromArgb(125, 0, 0, 0));

                layers.Enqueue(layer);
                break;

            case IdleEffects.ColorBreathing:
                layer = new EffectLayer("Idle - Color Breathing");

                Color breathe_bg_color = Global.Configuration.idle_effect_secondary_color;
                layer.Fill(breathe_bg_color);

                float sine = (float)Math.Pow(Math.Sin((double)((currenttime % 10000L) / 10000.0f) * 2 * Math.PI * Global.Configuration.idle_speed), 2);

                layer.Fill(Color.FromArgb((byte)(sine * 255), Global.Configuration.idle_effect_primary_color));

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainbowShift_Horizontal:
                layer = new EffectLayer("Idle - Rainbow Shift (Horizontal)", LayerEffects.RainbowShift_Horizontal, effect_cfg);

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainbowShift_Vertical:
                layer = new EffectLayer("Idle - Rainbow Shift (Vertical)", LayerEffects.RainbowShift_Vertical, effect_cfg);

                layers.Enqueue(layer);
                break;

            case IdleEffects.StarFall:
                layer = new EffectLayer("Idle - Starfall");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (stars.ContainsKey(star))
                        {
                            stars[star] = 1.0f;
                        }
                        else
                        {
                            stars.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                Devices.DeviceKeys[] stars_keys = stars.Keys.ToArray();

                foreach (Devices.DeviceKeys star in stars_keys)
                {
                    layer.Set(star, Utils.ColorUtils.MultiplyColorByScalar(Global.Configuration.idle_effect_primary_color, stars[star]));
                    stars[star] -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainFall:
                layer = new EffectLayer("Idle - Rainfall");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (raindrops.ContainsKey(star))
                        {
                            raindrops[star] = 1.0f;
                        }
                        else
                        {
                            raindrops.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                Devices.DeviceKeys[] raindrops_keys = raindrops.Keys.ToArray();

                ColorSpectrum drop_spec = new ColorSpectrum(Global.Configuration.idle_effect_primary_color, Color.FromArgb(0, Global.Configuration.idle_effect_primary_color));

                foreach (Devices.DeviceKeys raindrop in raindrops_keys)
                {
                    PointF pt = Effects.GetBitmappingFromDeviceKey(raindrop).Center;

                    float transition_value = 1.0f - raindrops[raindrop];
                    float radius           = transition_value * Effects.canvas_biggest;

                    layer.GetGraphics().DrawEllipse(new Pen(drop_spec.GetColorAt(transition_value), 2),
                                                    pt.X - radius,
                                                    pt.Y - radius,
                                                    2 * radius,
                                                    2 * radius);

                    raindrops[raindrop] -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.Blackout:
                layer = new EffectLayer("Idle - Blackout");

                layer.Fill(Color.Black);

                layers.Enqueue(layer);
                break;

            case IdleEffects.Matrix:
                layer = new EffectLayer("Idle - Matrix");

                if (nextstarset < currenttime)
                {
                    Color darker_primary = Utils.ColorUtils.MultiplyColorByScalar(Global.Configuration.idle_effect_primary_color, 0.50);

                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        int   width_start = randomizer.Next(Effects.canvas_width);
                        float delay       = randomizer.Next(550) / 100.0f;
                        int   random_id   = randomizer.Next(125536789);

                        //Create animation
                        AnimationTrack matrix_line =
                            new AnimationTrack("Matrix Line (Head) " + random_id, 0.0f).SetFrame(
                                0.0f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, -3, width_start, 0, Global.Configuration.idle_effect_primary_color, 3)).SetFrame(
                                0.5f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height, width_start, Effects.canvas_height + 3, Global.Configuration.idle_effect_primary_color, 3)).SetShift(
                                (currenttime % 1000000L) / 1000.0f + delay
                                );

                        AnimationTrack matrix_line_trail =
                            new AnimationTrack("Matrix Line (Trail) " + random_id, 0.0f).SetFrame(
                                0.0f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, -12, width_start, -3, darker_primary, 3)).SetFrame(
                                0.5f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height - 12, width_start, Effects.canvas_height, darker_primary, 3)).SetFrame(
                                0.75f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height, width_start, Effects.canvas_height, darker_primary, 3)).SetShift(
                                (currenttime % 1000000L) / 1000.0f + delay
                                );

                        matrix_lines.AddTrack(matrix_line);
                        matrix_lines.AddTrack(matrix_line_trail);
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                using (Graphics g = layer.GetGraphics())
                {
                    matrix_lines.Draw(g, (currenttime % 1000000L) / 1000.0f);
                }

                layers.Enqueue(layer);
                break;

            default:
                break;
            }

            frame.AddOverlayLayers(layers.ToArray());
        }
        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);
        }
예제 #27
0
        private input_item CreateInputItem(Devices.DeviceKeys key, EffectPoint origin)
        {
            Color primary_c   = (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_primary_color;
            Color secondary_c = (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_secondary_color;

            if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effects_random_primary_color)
            {
                primary_c = Utils.ColorUtils.GenerateRandomColor(primary_c);
            }

            if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effects_random_secondary_color)
            {
                secondary_c = Utils.ColorUtils.GenerateRandomColor(secondary_c);
            }

            AnimationMix anim_mix = new AnimationMix();

            if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_type == InteractiveEffects.Wave)
            {
                AnimationTrack wave = new AnimationTrack("Wave effect", 1.0f);
                wave.SetFrame(0.0f,
                              new AnimationCircle(origin.ToPointF(), 0, primary_c, (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                              );
                wave.SetFrame(0.80f,
                              new AnimationCircle(origin.ToPointF(), Effects.canvas_width * 0.80f, secondary_c, (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                              );
                wave.SetFrame(1.00f,
                              new AnimationCircle(origin.ToPointF(), Effects.canvas_width, Color.FromArgb(0, secondary_c), (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                              );
                anim_mix.AddTrack(wave);
            }
            else if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_type == InteractiveEffects.Wave_Filled)
            {
                AnimationTrack wave = new AnimationTrack("Filled Wave effect", 1.0f);
                wave.SetFrame(0.0f,
                              new AnimationFilledCircle(origin.ToPointF(), 0, primary_c, (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                              );
                wave.SetFrame(0.80f,
                              new AnimationFilledCircle(origin.ToPointF(), Effects.canvas_width * 0.80f, secondary_c, (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                              );
                wave.SetFrame(1.00f,
                              new AnimationFilledCircle(origin.ToPointF(), Effects.canvas_width, Color.FromArgb(0, secondary_c), (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                              );
                anim_mix.AddTrack(wave);
            }
            else if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_type == InteractiveEffects.KeyPress)
            {
                ColorSpectrum spec = new ColorSpectrum(primary_c, secondary_c);
                if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_type == InteractiveEffects.KeyPress)
                {
                    spec = new ColorSpectrum(primary_c, Color.FromArgb(0, secondary_c));
                    spec.SetColorAt(0.80f, secondary_c);
                }

                return(new input_item(key, 0.0f, spec));
            }
            else if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_type == InteractiveEffects.ArrowFlow)
            {
                PointF starting_pt = origin.ToPointF();

                AnimationTrack arrow = new AnimationTrack("Arrow Flow effect", 1.0f);
                arrow.SetFrame(0.0f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(starting_pt, starting_pt, primary_c, (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width),
                    new AnimationLine(starting_pt, starting_pt, primary_c, (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                }
                                   )
                               );
                arrow.SetFrame(0.33f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(starting_pt, new PointF(starting_pt.X + Effects.canvas_width * 0.33f, starting_pt.Y), Utils.ColorUtils.BlendColors(primary_c, secondary_c, 0.33D), (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width),
                    new AnimationLine(starting_pt, new PointF(starting_pt.X - Effects.canvas_width * 0.33f, starting_pt.Y), Utils.ColorUtils.BlendColors(primary_c, secondary_c, 0.33D), (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                }
                                   )
                               );
                arrow.SetFrame(0.66f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(new PointF(starting_pt.X + Effects.canvas_width * 0.33f, starting_pt.Y), new PointF(starting_pt.X + Effects.canvas_width * 0.66f, starting_pt.Y), secondary_c, (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width),
                    new AnimationLine(new PointF(starting_pt.X - Effects.canvas_width * 0.33f, starting_pt.Y), new PointF(starting_pt.X - Effects.canvas_width * 0.66f, starting_pt.Y), secondary_c, (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                }
                                   )
                               );
                arrow.SetFrame(1.0f,
                               new AnimationLines(
                                   new AnimationLine[] {
                    new AnimationLine(new PointF(starting_pt.X + Effects.canvas_width * 0.66f, starting_pt.Y), new PointF(starting_pt.X + Effects.canvas_width, starting_pt.Y), Color.FromArgb(0, secondary_c), (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width),
                    new AnimationLine(new PointF(starting_pt.X - Effects.canvas_width * 0.66f, starting_pt.Y), new PointF(starting_pt.X - Effects.canvas_width, starting_pt.Y), Color.FromArgb(0, secondary_c), (Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_width)
                }
                                   )
                               );
                anim_mix.AddTrack(arrow);
            }

            return(new input_item(key, 0.0f, anim_mix));
        }
 public FixedRange(
     Func <string> labelF, Func <float, string> colorScaleLabelerF,
     float rangeMin, float rangeMax, ColorSpectrum spectrum = null)
     : base(labelF, colorScaleLabelerF, rangeMin, rangeMax, spectrum)
 {
 }
 public NormalizedAdaptiveRange(
     Func <string> labelF, Func <float, string> colorScaleLabelerF, ColorSpectrum spectrum = null) : base(labelF, colorScaleLabelerF, spectrum)
 {
 }
 public AdaptiveRange(
     Func <string> labelF, Func <float, string> colorScaleLabelerF, ColorSpectrum spectrum = null)
     : base(labelF, colorScaleLabelerF, spectrum: spectrum)
 {
     Reset();
 }