Exemplo n.º 1
0
        public override void UpdateLights(EffectFrame frame, GameState new_game_state)
        {
            if (new_game_state is GameState_PD2)
            {
                _game_state = new_game_state;

                GameState_PD2 gs = (new_game_state as GameState_PD2);

                try
                {
                    SetPlayerState(gs.Players.LocalPlayer.State);
                    SetHealth(gs.Players.LocalPlayer.Health.Current);
                    SetHealthMax(gs.Players.LocalPlayer.Health.Max);
                    SetArmor(gs.Players.LocalPlayer.Armor.Current);
                    SetArmorMax(gs.Players.LocalPlayer.Armor.Max);
                    SetClip(gs.Players.LocalPlayer.Weapons.SelectedWeapon.Current_Clip);
                    SetClipMax(gs.Players.LocalPlayer.Weapons.SelectedWeapon.Max_Clip);
                    SetSuspicion(gs.Players.LocalPlayer.SuspicionAmount);
                    SetLevelPhase(gs.Level.Phase);
                    SetDownTime(gs.Players.LocalPlayer.DownTime);
                    SetSwanSong(gs.Players.LocalPlayer.IsSwanSong);
                    SetFlashbangAmount(gs.Players.LocalPlayer.FlashAmount);
                    SetNoReturnTimeleft(gs.Level.NoReturnTime);
                    SetGameState(gs.Game.State);

                    UpdateLights(frame);
                }
                catch (Exception e)
                {
                    Global.logger.LogLine("Exception during OnNewGameState. Error: " + e, Logging_Level.Error);
                    Global.logger.LogLine(gs.ToString(), Logging_Level.None);
                }
            }
        }
Exemplo n.º 2
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer states_layer = new EffectLayer("Payday 2 - States");

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

                if (pd2state.Game.State == GameStates.Ingame)
                {
                    if (pd2state.LocalPlayer.State == PlayerState.Incapacitated || pd2state.LocalPlayer.State == PlayerState.Bleed_out || pd2state.LocalPlayer.State == PlayerState.Fatal)
                    {
                        int incapAlpha = (int)(pd2state.LocalPlayer.DownTime > 10 ? 0 : 255 * (1.0D - (double)pd2state.LocalPlayer.DownTime / 10.0D));

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

                        Color incapColor = Color.FromArgb(incapAlpha, Properties.DownedColor);

                        states_layer.Fill(incapColor).Set(Devices.DeviceKeys.Peripheral, incapColor);
                    }
                    else if (pd2state.LocalPlayer.State == PlayerState.Arrested)
                    {
                        states_layer.Fill(Properties.ArrestedColor).Set(Devices.DeviceKeys.Peripheral, Properties.ArrestedColor);
                    }

                    if (pd2state.LocalPlayer.IsSwanSong && Properties.ShowSwanSong)
                    {
                        double blend_percent = Math.Pow(Math.Cos((Utils.Time.GetMillisecondsSinceEpoch() % 1300L) / 1300.0D * Properties.SwanSongSpeedMultiplier * 2.0D * Math.PI), 2.0D);

                        Color swansongColor = Utils.ColorUtils.MultiplyColorByScalar(Properties.SwanSongColor, blend_percent);

                        EffectLayer swansong_layer = new EffectLayer("Payday 2 - Swansong", swansongColor).Set(Devices.DeviceKeys.Peripheral, swansongColor);

                        states_layer += swansong_layer;
                    }
                }
            }

            return(states_layer);
        }
Exemplo n.º 3
0
        public override void UpdateLights(EffectFrame frame, IGameState new_game_state)
        {
            if (new_game_state is GameState_PD2)
            {
                _game_state = new_game_state;
                GameState_PD2 gs = (new_game_state as GameState_PD2);

                try
                {
                    UpdateLights(frame);
                }
                catch (Exception e)
                {
                    Global.logger.LogLine("Exception during OnNewGameState. Error: " + e, Logging_Level.Error);
                    Global.logger.LogLine(gs.ToString(), Logging_Level.None);
                }
            }
        }
Exemplo n.º 4
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer flashed_layer = new EffectLayer("Payday 2 - Flashed");

            if (state is GameState_PD2)
            {
                GameState_PD2 pd2state = state as GameState_PD2;

                //Update Flashed
                if (pd2state.Game.State == GameStates.Ingame && pd2state.LocalPlayer.FlashAmount > 0)
                {
                    Color flash_color = Utils.ColorUtils.MultiplyColorByScalar(Properties.FlashbangColor, pd2state.LocalPlayer.FlashAmount);

                    flashed_layer.Fill(flash_color);
                }
            }

            return(flashed_layer);
        }
        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);
        }
Exemplo n.º 6
0
 public override void ResetGameState()
 {
     _game_state = new GameState_PD2();
 }