Exemple #1
0
        private float CalculateRotationDegree(WeaponBaseAgent agent, ShakeInfoStruct dirShakeArgs)
        {
            switch (agent.WeaponConfigAssy.NewWeaponCfg.Type)
            {
            case 1:
                return(dirShakeArgs.UpBase * 1.5f);

            case 2:
                return(dirShakeArgs.UpBase * 2f);

            case 3:
                return(dirShakeArgs.UpBase * 1.3f);

            case 4:
                return(dirShakeArgs.UpBase * 1.5f);

            case 5:
                return(dirShakeArgs.UpBase * 2f);

            case 6:
                return(dirShakeArgs.UpBase);

            default:
                return(0);
            }
        }
        /// <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;
                }
            }
        }
Exemple #3
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;
            }
        }