public ShakeProcessor AddShake(string shakeInfoName)
            {
                if (!ShakeInfoDict.ContainsKey(shakeInfoName))
                {
                    Debug.LogError("CameraShake, sake info with this name does not exists: " + shakeInfoName);
                    return(null);
                }

                ShakeInfo info = ShakeInfoDict[shakeInfoName];

                info.IsPositionBased = false;
                GameObject shakeProcessorObj = IPool.I.GetInstance("Shake");

                if (shakeProcessorObj == null)
                {
                    // No more instances in the pool.
                    return(null);
                }
                ShakeProcessor shakeProcessor = shakeProcessorObj.GetComponent <ShakeProcessor>();

                shakeProcessor.Info = info;
                shakeProcessor.Init();
                shakeProcessor.gameObject.SetActive(true);

                if (!ShakeProcessors.ContainsKey(shakeInfoName))
                {
                    ShakeProcessors.Add(shakeInfoName, new List <ShakeProcessor>());
                }
                ShakeProcessors[shakeInfoName].Add(shakeProcessor);

                return(shakeProcessor);
            }
Beispiel #2
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);
        }
        public void Shake(ShakeInfo info)
        {
            iTween.ShakePosition(Camera.main.gameObject, iTween.Hash(
                                     "time", info.Time,
                                     "amount", info.Amount,

                                     "onstart", "OnITweenShakingStart",
                                     "oncomplete", "OnITweenShakingComplete"
                                     ));

            ActualShakeInfo = info;
        }
Beispiel #4
0
        public static ShakeInfoStruct GetFireUpDirShakeArgs(WeaponAttackProxy attackProxy, ShakeInfo shakeInfo)
        {
            var newInfo = (ShakeInfoStruct)shakeInfo;

            float factor = attackProxy.GetAttachedAttributeByType(WeaponAttributeType.UpBase);

            if (factor != 0f)
            {
                newInfo.UpBase *= factor;
            }
            //    logger.Info("Shoot Shake factor:"+factor);

            factor = attackProxy.GetAttachedAttributeByType(WeaponAttributeType.UpMax);
            if (factor != 0f)
            {
                newInfo.UpMax *= factor;
            }

            factor = attackProxy.GetAttachedAttributeByType(WeaponAttributeType.UpModifier);
            if (factor != 0f)
            {
                newInfo.UpModifier *= factor;
            }

            factor = attackProxy.GetAttachedAttributeByType(WeaponAttributeType.LateralBase);
            if (factor != 0f)
            {
                newInfo.LateralBase *= factor;
            }

            factor = attackProxy.GetAttachedAttributeByType(WeaponAttributeType.LateralMax);
            if (factor != 0f)
            {
                newInfo.LateralMax *= factor;
            }

            factor = attackProxy.GetAttachedAttributeByType(WeaponAttributeType.LateralModifier);
            if (factor != 0f)
            {
                newInfo.LateralModifier *= factor;
            }

            factor = attackProxy.GetAttachedAttributeByType(WeaponAttributeType.LateralTurnback);
            if (factor != 0f)
            {
                newInfo.LateralTurnback *= factor;
            }

            return(newInfo);
        }
Beispiel #5
0
 public void Setup(ShakeInfo info)
 {
     shake = info;
 }
Beispiel #6
0
 public void SetShake(ShakeInfo inThing)
 {
     shake = inThing;
 }                                                                 ///@property(readwrite,assign) ShakeInfo shake;
        /// <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;
                }
            }
        }
Beispiel #8
0
 public void ShakeCamera(ShakeInfo info)
 {
     ShakeCamera(info.Time, info.Interval, info.XDelta, info.YDelta, info.ForceShake);
 }
Beispiel #9
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;
            }
        }