Пример #1
0
        void ScrollingActivity()
        {
            float desiredTruckY = CameraControllerInstance.Y - Camera.Main.OrthogonalHeight / 4;

            const float extraUnitPerYVelocity = 1.0f;
            float       heightFromVelocity    = 0;

            var yVelocity = PlayerBuggyList.Max(buggy => buggy.YVelocity);

            if (yVelocity > 0)
            {
                heightFromVelocity = extraUnitPerYVelocity * yVelocity;
            }

            var y = PlayerBuggyList.Sum(buggy => buggy.Y) / PlayerBuggyList.Count;

            float heightAbove = y + heightFromVelocity - desiredTruckY;

            float velocity = heightAbove; // Math.Max(0, heightAbove);

            var ratioOfMaxBuggyVelocity = velocity / PlayerBuggyInstance.MaxSpeed;

            ObstacleSpawnerInstance.MovementRatio = ratioOfMaxBuggyVelocity;

            CameraControllerInstance.Y += velocity * TimeManager.SecondDifference;
        }
Пример #2
0
        private void CameraShakingActivity()
        {
            // so that the camera isn't always shaking:
            var distanceFromSandstorm = PlayerBuggyList.Max(buggy => buggy.Y - SandStormInstance.Y);

            //const float distanceForNoShake = 790;
            //const float distanceForMaxShake = 200;

            var distanceFromMaxShake = distanceFromSandstorm - CameraControllerInstance.FullShakeDistance;
            var range = CameraControllerInstance.NoShakeDistance - CameraControllerInstance.FullShakeDistance;

            var shakeRatio = 1 - distanceFromMaxShake / range;

            shakeRatio = Math.Min(1, shakeRatio);
            shakeRatio = Math.Max(0, shakeRatio);

#if DEBUG
            if (DebuggingVariables.DisableCameraShake)
            {
                shakeRatio = 0;
            }
#endif
            CameraControllerInstance.ProximityRatio = shakeRatio;
        }