Beispiel #1
0
        public static ShakeInfo GetShakeInfo(RifleShakeConfig shakeConfig, PlayerWeaponController controller,
                                             ShakeGroup shakeGroup = null)
        {
            shakeGroup = shakeGroup ?? GetShakeGroup(shakeConfig, controller);
            ShakeInfo shakeInfo = shakeGroup.Base;
            var       posture   = controller.RelatedCharState.GetCurrentPostureState();

            if (!controller.RelatedPlayerMove.IsGround)
            {
                shakeInfo = shakeGroup.Air;
            }
            else if (controller.RelatedPlayerMove.HorizontalVelocity > shakeConfig.FastMoveSpeed)
            {
                shakeInfo = shakeGroup.FastMove;
            }
            else if (posture == PostureInConfig.Prone)
            {
                shakeInfo = shakeGroup.Prone;
            }
            else if (posture == PostureInConfig.Crouch)
            {
                shakeInfo = shakeGroup.Duck;
            }
            return(shakeInfo);
        }
        /// <summary>
        /// TargetPunchPitchDelta => AccPunchYaw,AccPunchYawValue
        /// </summary>
        /// <param name="agent"></param>
        /// <param name="cmd"></param>

        public override void OnFrame(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
        {
            ShakeGroup shakeGroup       = FireShakeProvider.GetShakeGroup(attackProxy.WeaponConfigAssy.SRifleShakeCfg, attackProxy.Owner);
            var        runTimeComponent = attackProxy.RuntimeComponent;
            //int frameInterval = cmd.UserCmd.FrameInterval;
            var orient = attackProxy.Orientation;
            //后坐力生效时间
            var deltaTime = Mathf.Min(cmd.UserCmd.FrameInterval, cmd.UserCmd.RenderTime - runTimeComponent.LastRenderTimestamp);

            if (runTimeComponent.PunchDecayLeftInterval > 0)
            {
                float totalInterval = FireShakeProvider.GetDecayInterval(attackProxy.WeaponConfigAssy);
                float lastInterval  = runTimeComponent.PunchDecayLeftInterval;
                runTimeComponent.PunchDecayLeftInterval -= deltaTime;
                float newInterval = runTimeComponent.PunchDecayLeftInterval;

                var lastPunchPitch = FireShakeFormula.EaseOutCubic(0, runTimeComponent.TargetPunchPitchDelta,
                                                                   (totalInterval - lastInterval) / totalInterval);
                var newPunchPitch = FireShakeFormula.EaseOutCubic(0, runTimeComponent.TargetPunchPitchDelta,
                                                                  (totalInterval - newInterval) / totalInterval);

                orient.AccPunchPitch     += newPunchPitch - lastPunchPitch;
                orient.AccPunchPitchValue = orient.AccPunchPitch * shakeGroup.VPunchOffsetFactor;

                orient.AccPunchYaw     += runTimeComponent.PunchYawSpeed * deltaTime;
                orient.AccPunchYawValue = orient.AccPunchYaw * shakeGroup.HPunchOffsetFactor;

                if (GlobalConst.EnableWeaponLog)
                {
                    DebugUtil.MyLog(("orient.AccPunchPitch:" + orient.AccPunchPitch));
                }
            }
            else
            {
                UpdateOrientationAttenuation(attackProxy, cmd);
            }

            if (attackProxy.WeaponConfigAssy.S_FireRollCfg != null && runTimeComponent.CameraRotationInterval > 0)
            {
                runTimeComponent.CameraRotationInterval -= deltaTime;
                orient.FireRoll += runTimeComponent.CameraRotationSpeed * deltaTime;
            }
            else
            {
                RecoverFireRoll(attackProxy, cmd);
            }
            base.OnFrame(attackProxy, cmd);
        }
Beispiel #3
0
        public override void OnFrame(WeaponBaseAgent agent, WeaponSideCmd cmd)
        {
            var        weaponController = agent.Owner.WeaponController();
            ShakeGroup shakeGroup       = FireShakeProvider.GetShakeGroup(agent.RifleShakeCfg, weaponController);
            var        runTimeComponent = agent.RunTimeComponent;
            int        frameInterval    = cmd.UserCmd.FrameInterval;
            var        orient           = weaponController.RelatedOrientation;

            //后坐力生效时间
            if (runTimeComponent.PunchDecayLeftInterval > 0)
            {
                float totalInterval = FireShakeProvider.GetDecayInterval(agent);
                float lastInterval  = runTimeComponent.PunchDecayLeftInterval;
                runTimeComponent.PunchDecayLeftInterval -= frameInterval;
                float newInterval = runTimeComponent.PunchDecayLeftInterval;

                var lastPunchPitch = FireShakeFormula.EaseOutCubic(0, runTimeComponent.TargetPunchPitchDelta,
                                                                   (totalInterval - lastInterval) / totalInterval);
                var newPunchPitch = FireShakeFormula.EaseOutCubic(0, runTimeComponent.TargetPunchPitchDelta,
                                                                  (totalInterval - newInterval) / totalInterval);

                orient.AccPunchPitch     += newPunchPitch - lastPunchPitch;
                orient.AccPunchPitchValue = orient.AccPunchPitch * shakeGroup.VPunchOffsetFactor;


                var deltaTime = cmd.UserCmd.RenderTime - runTimeComponent.LastRenderTimestamp;

                orient.AccPunchYaw     += runTimeComponent.PunchYawSpeed * deltaTime;
                orient.AccPunchYawValue = orient.AccPunchYaw * shakeGroup.HPunchOffsetFactor;

                orient.FireRoll += runTimeComponent.CameraRotationSpeed * frameInterval;
                if (GlobalConst.EnableWeaponLog)
                {
                    DebugUtil.MyLog(("orient.AccPunchPitch:" + orient.AccPunchPitch));
                }
            }
            else
            {
                UpdateOrientationAttenuation(agent, cmd);
            }

            base.OnFrame(agent, cmd);
        }