Esempio n. 1
0
        private void BaseKickBack(PlayerWeaponController controller, int seed, WeaponConfigNs.Kickback kickbackParams,
                                  float hOffsetFactor, float vOffsetFactor)
        {
            var   commonFireConfig = controller.HeldWeaponAgent.CommonFireCfg;
            var   kickbackConfig   = controller.HeldWeaponAgent.RifleKickbackLogicCfg;
            var   weaponState      = controller.HeldWeaponAgent.RunTimeComponent;
            float kickUp;
            float kickLateral;

            if (weaponState.ContinuesShootCount == 1)
            {
                kickUp      = kickbackParams.UpBase;
                kickLateral = kickbackParams.LateralBase;
            }
            else
            {
                kickUp      = kickbackParams.UpBase + weaponState.ContinuesShootCount * kickbackParams.UpModifier;
                kickLateral = kickbackParams.LateralBase + weaponState.ContinuesShootCount * kickbackParams.LateralModifier;
            }

            var punchYaw   = controller.RelatedOrient.NegPunchYaw;
            var punchPitch = controller.RelatedOrient.NegPunchPitch;
            var isMaxUp    = false;

            punchPitch += kickUp;
            if (punchPitch > kickbackParams.UpMax + commonFireConfig.AttackInterval * 0.01f)
            {
                punchPitch = kickbackParams.UpMax;
                isMaxUp    = true;
            }

            if (weaponState.PunchYawLeftSide)
            {
                punchYaw += kickLateral;
                if (punchYaw > kickbackParams.LateralMax)
                {
                    punchYaw = kickbackParams.LateralMax;
                }
            }
            else
            {
                punchYaw -= kickLateral;
                if (punchYaw < -1 * kickbackParams.LateralMax)
                {
                    punchYaw = -1 * kickbackParams.LateralMax;
                }
            }

            if (UniformRandom.RandomInt(seed, 0, (int)kickbackParams.LateralTurnback) == 0)
            {
                weaponState.PunchYawLeftSide = !weaponState.PunchYawLeftSide;
            }

            //if (isMaxUp)
            weaponState.PunchDecayCdTime = GetDecayCdTime(controller);
            weaponState.PunchPitchSpeed  = (punchPitch - controller.RelatedOrient.NegPunchPitch) / weaponState.PunchDecayCdTime;
            weaponState.PunchYawSpeed    = (punchYaw - controller.RelatedOrient.NegPunchYaw) / weaponState.PunchDecayCdTime;
        }
Esempio n. 2
0
        private void BaseKickBack(IPlayerWeaponState playerWeapon, int seed, float upBase, float lateralBase,
                                  float upModifier, float lateralModifier, float upMax, float lateralMax, float directionChang,
                                  float hOffsetFactor, float vOffsetFactor)
        {
            float kickUp;
            float kickLateral;

            if (playerWeapon.ContinuesShootCount == 1)
            {
                kickUp      = upBase;
                kickLateral = lateralBase;
            }
            else
            {
                kickUp      = upBase + playerWeapon.ContinuesShootCount * upModifier;
                kickLateral = lateralBase + playerWeapon.ContinuesShootCount * lateralModifier;
            }

            var punchYaw   = playerWeapon.NegPunchYaw;
            var punchPitch = playerWeapon.NegPunchPitch;
            var isMaxUp    = false;

            punchPitch += kickUp;
            if (punchPitch > upMax + _common.AttackInterval * 0.01f)
            {
                punchPitch = upMax;
                isMaxUp    = true;
            }

            if (playerWeapon.PunchYawLeftSide)
            {
                punchYaw += kickLateral;
                if (punchYaw > lateralMax)
                {
                    punchYaw = lateralMax;
                }
            }
            else
            {
                punchYaw -= kickLateral;
                if (punchYaw < -1 * lateralMax)
                {
                    punchYaw = -1 * lateralMax;
                }
            }

            if (UniformRandom.RandomInt(seed, 0, (int)directionChang) == 0)
            {
                playerWeapon.PunchYawLeftSide = !playerWeapon.PunchYawLeftSide;
            }

            //if (isMaxUp)
            playerWeapon.PunchDecayCdTime = (int)(_common.AttackInterval * _config.DecaytimeFactor);

            playerWeapon.NegPunchYaw      = punchYaw;
            playerWeapon.NegPunchPitch    = punchPitch;
            playerWeapon.WeaponPunchPitch = punchPitch * vOffsetFactor;
            playerWeapon.WeaponPunchYaw   = punchYaw * hOffsetFactor;
            Logger.DebugFormat("yaw src {0} new {1} pithc src {2} new {3}", playerWeapon.NegPunchYaw,
                               playerWeapon.WeaponPunchYaw,
                               playerWeapon.NegPunchPitch,
                               playerWeapon.WeaponPunchPitch);
        }
        /// <summary>
        /// last/NewAccPunchPitch->TargetPunchPitchDelta
        /// </summary>
        /// <param name="heldAgent"></param>
        /// <param name="seed"></param>
        /// <param name="shakeInfo"></param>
        private void CalcBaseShake(WeaponAttackProxy attackProxy, int seed, ShakeInfo shakeInfo)
        {
            var             runTimeComponent = attackProxy.RuntimeComponent;
            var             orient           = attackProxy.Orientation;
            var             commonFireConfig = attackProxy.WeaponConfigAssy.S_CommonFireCfg;
            ShakeInfoStruct dirShakeArgs     = FireShakeProvider.GetFireUpDirShakeArgs(attackProxy, shakeInfo);
            /*计算水平,垂直震动增量*/
            float upDirShakeDelta, lateralDirShakeDelta;

            upDirShakeDelta = FireShakeFormula.CalcFireDirShakeDelta(dirShakeArgs.UpBase, dirShakeArgs.UpModifier,
                                                                     runTimeComponent.ContinuesShootCount);
            lateralDirShakeDelta = FireShakeFormula.CalcFireDirShakeDelta(dirShakeArgs.LateralBase,
                                                                          dirShakeArgs.LateralModifier, runTimeComponent.ContinuesShootCount);
            /*应用水平,垂直震动增量*/
            float punchYaw, punchPitch;

            punchYaw   = orient.AccPunchYaw;
            punchPitch = orient.AccPunchPitch;
            //垂直震动增量应用于punchPitch
            punchPitch = FireShakeFormula.CalcPunchPitch(punchPitch, upDirShakeDelta, dirShakeArgs.UpMax,
                                                         commonFireConfig.AttackInterval * 0.01f);
            runTimeComponent.TargetPunchPitchDelta = punchPitch - orient.AccPunchPitch;

            //水平震动增量应用于punchYaw
            punchYaw = FireShakeFormula.CaclPunchYaw(runTimeComponent.PunchYawLeftSide, punchYaw,
                                                     lateralDirShakeDelta, dirShakeArgs.LateralMax);
            /*应用于WeaponRuntimeComponent*/
            //apply PunchYawLeftSide
            if (UniformRandom.RandomInt(seed, 0, (int)dirShakeArgs.LateralTurnback) == 0)
            {
                runTimeComponent.PunchYawLeftSide = !runTimeComponent.PunchYawLeftSide;
            }
            //apply PunchDecayCdTime
            runTimeComponent.PunchDecayLeftInterval = (int)FireShakeProvider.GetDecayInterval(attackProxy.WeaponConfigAssy);
            //PunchYawSpeed
            runTimeComponent.PunchYawSpeed = FireShakeFormula.CalcPitchSpeed(punchYaw,
                                                                             orient.AccPunchYaw, runTimeComponent.PunchDecayLeftInterval);
            //PunchPitchSpeed(Not Speed)
            var fireRollCfg = attackProxy.WeaponConfigAssy.S_FireRollCfg;

            if (fireRollCfg != null)
            {
                var rotation  = orient.FireRoll;
                var rotateYaw = dirShakeArgs.UpBase * fireRollCfg.FireRollFactor;
                runTimeComponent.CameraRotationInterval = fireRollCfg.FireRollTime;
                if (Random.Range(0, 2) == 0)
                {
                    rotateYaw = -rotateYaw;
                }
                var maxFireRollAngle = fireRollCfg.MaxFireRollAngle;
                if (rotation + rotateYaw >= maxFireRollAngle)
                {
                    runTimeComponent.CameraRotationSpeed = (maxFireRollAngle - rotation) / runTimeComponent.CameraRotationInterval;
                }
                else if (rotation + rotateYaw <= -maxFireRollAngle)
                {
                    runTimeComponent.CameraRotationSpeed = (-maxFireRollAngle - rotation) / runTimeComponent.CameraRotationInterval;
                }
                else
                {
                    runTimeComponent.CameraRotationSpeed = rotateYaw / runTimeComponent.CameraRotationInterval;
                }
            }
        }
Esempio n. 4
0
        private void CalcBaseShake(WeaponBaseAgent heldAgent, int seed, ShakeInfo shakeInfo)
        {
            var weaponController = heldAgent.Owner.WeaponController();
            var runTimeComponent = heldAgent.RunTimeComponent;
            var orient           = weaponController.RelatedOrientation;

            heldAgent.SyncParts();
            var             commonFireConfig = heldAgent.CommonFireCfg;
            ShakeInfoStruct dirShakeArgs     = FireShakeProvider.GetFireUpDirShakeArgs(heldAgent, shakeInfo);
            /*计算水平,垂直震动增量*/
            float upDirShakeDelta, lateralDirShakeDelta;

            upDirShakeDelta = FireShakeFormula.CalcFireDirShakeDelta(dirShakeArgs.UpBase, dirShakeArgs.UpModifier,
                                                                     runTimeComponent.ContinuesShootCount);
            lateralDirShakeDelta = FireShakeFormula.CalcFireDirShakeDelta(dirShakeArgs.LateralBase,
                                                                          dirShakeArgs.LateralModifier, runTimeComponent.ContinuesShootCount);
            /*应用水平,垂直震动增量*/
            float punchYaw, punchPitch;

            punchYaw   = orient.AccPunchYaw;
            punchPitch = orient.AccPunchPitch;
            //垂直震动增量应用于punchPitch
            punchPitch = FireShakeFormula.CalcPunchPitch(punchPitch, upDirShakeDelta, dirShakeArgs.UpMax,
                                                         commonFireConfig.AttackInterval * 0.01f);
            runTimeComponent.TargetPunchPitchDelta = punchPitch - orient.AccPunchPitch;

            //水平震动增量应用于punchYaw
            punchYaw = FireShakeFormula.CaclPunchYaw(runTimeComponent.PunchYawLeftSide, punchYaw,
                                                     lateralDirShakeDelta, dirShakeArgs.LateralMax);
            /*应用于WeaponRuntimeComponent*/
            //apply PunchYawLeftSide
            if (UniformRandom.RandomInt(seed, 0, (int)dirShakeArgs.LateralTurnback) == 0)
            {
                runTimeComponent.PunchYawLeftSide = !runTimeComponent.PunchYawLeftSide;
            }
            //apply PunchDecayCdTime
            runTimeComponent.PunchDecayLeftInterval = (int)FireShakeProvider.GetDecayInterval(heldAgent);
            //PunchYawSpeed
            runTimeComponent.PunchYawSpeed = FireShakeFormula.CalcPitchSpeed(punchYaw,
                                                                             orient.AccPunchYaw, runTimeComponent.PunchDecayLeftInterval);
            //PunchPitchSpeed(Not Speed)
            var rotation  = orient.FireRoll;
            var rotateYaw = CalculateRotationDegree(heldAgent, dirShakeArgs);

            if (UnityEngine.Random.Range(0, 2) == 0)
            {
                rotateYaw = -rotateYaw;
            }
            if (rotation + rotateYaw >= 3)
            {
                runTimeComponent.CameraRotationSpeed = (3 - rotation) / runTimeComponent.PunchDecayLeftInterval;
            }
            else if (rotation + rotateYaw <= -3)
            {
                runTimeComponent.CameraRotationSpeed = (-3 - rotation) / runTimeComponent.PunchDecayLeftInterval;
            }
            else
            {
                runTimeComponent.CameraRotationSpeed = rotateYaw / runTimeComponent.PunchDecayLeftInterval;
            }
        }