Пример #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 AddAdditionalPlayers()
        {
            bool shouldAddAnother = MainMenu.SelectedNumberOfPlayers == 2;

            if (shouldAddAnother)
            {
                const float playerOffset = 200;
                PlayerBuggyInstance.X -= playerOffset;

                var player2Buggy = new PlayerBuggy();
                player2Buggy.X        += playerOffset;
                player2Buggy.Z         = PlayerBuggyInstance.Z;
                player2Buggy.RotationZ = PlayerBuggyInstance.RotationZ;
                player2Buggy.CreateXboxControllerInput(1);

                PlayerBuggyList.Add(player2Buggy);
            }
        }
Пример #3
0
        private void PlayerVsStormCollision()
        {
            bool shouldDie = PlayerBuggyList.Any(buggy => buggy.CollideAgainst(SandStormInstance));

#if DEBUG
            if (DebuggingVariables.MakePlayerInvincible)
            {
                shouldDie = false;
            }
#endif

            if (shouldDie)
            {
                PauseThisScreen();
                this.DeathComponentInstance.Visible = true;
                isPlayerDead = true;
            }
        }
Пример #4
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;
        }