Esempio n. 1
0
 public RaceTiming(Racer racer)
 {
     currentRacer = racer;
     isRacing = false;
     hasCompletedRace = false;
     isLastToBeEliminated = false;
     stopwatch = new Stopwatch();
     fastestLap = new TimeSpan(0);
     finalRaceTime = long.MaxValue;
 }
Esempio n. 2
0
        public override void finishRaceForTheRacer(Stopwatch finishTime, Racer racer, int _, int __)
        {
            racer.raceTiming.isRacing = false;
            racer.raceTiming.hasCompletedRace = true;
            racer.raceTiming.finalRaceTime = finishTime.ElapsedMilliseconds;
            if (racer.racingControls.chosenInput.GetType() == typeof(PadInputManager))
                GamePad.SetVibration(racer.racingControls.padIndex, 0.0f, 0.0f);
            if (racer.racingControls.chosenInput.GetType() != typeof(AiInputManager))
                racer.racingControls.setChosenInput(new AiInputManager(racer));

            TimeSpan ts = finishTime.Elapsed;
            racer.raceTiming.finalRaceTimeString = racer.raceTiming.convertTimeSpanToString(ts);
        }
Esempio n. 3
0
        public ShipPhysics(Racer parent)
        {
            parentRacer = parent;
            initializeWaypoints();
            setupStabalizerRaycastPositions();
            constructPhysicsBody();

            placeShipOnStartingGrid(parentRacer.shipNumber);

            if (parentRacer.racerType == RacerType.AI)
            {
                AiSpeed = (new Random(parentRacer.shipNumber * 3 + 29)).Next(200, 290);
            }
        }
Esempio n. 4
0
        public override void finishRaceForTheRacer(Stopwatch finishTime, Racer racer, int _, int __)
        {
            racer.raceTiming.isRacing = false;
            racer.raceTiming.hasCompletedRace = true;
            racer.raceTiming.finalRaceTime = finishTime.ElapsedMilliseconds;
            if (racer.racingControls.chosenInput.GetType() == typeof(PadInputManager))
                GamePad.SetVibration(racer.racingControls.padIndex, 0.0f, 0.0f);

            TimeSpan ts = finishTime.Elapsed;
            racer.raceTiming.finalRaceTimeString = racer.raceTiming.convertTimeSpanToString(ts);

            // TODO: Display, you lasted ....
            // TODO: explode the ship or something and remove from physics

            // WARNING: this may not *cleanly* remove the ship from the race
            racer.shipDrawing.isVisible = false;
            racer.shipPhysics.removeFromPhysicsEngine();
        }
Esempio n. 5
0
        public override void finishRaceForTheRacer(Stopwatch finishTime, Racer racer, int _, int __)
        {
            racer.raceTiming.isRacing         = false;
            racer.raceTiming.hasCompletedRace = true;
            racer.raceTiming.finalRaceTime    = finishTime.ElapsedMilliseconds;
            if (racer.racingControls.chosenInput.GetType() == typeof(PadInputManager))
            {
                GamePad.SetVibration(racer.racingControls.padIndex, 0.0f, 0.0f);
            }

            TimeSpan ts = finishTime.Elapsed;

            racer.raceTiming.finalRaceTimeString = racer.raceTiming.convertTimeSpanToString(ts);

            // TODO: Display, you lasted ....
            // TODO: explode the ship or something and remove from physics

            // WARNING: this may not *cleanly* remove the ship from the race
            racer.shipDrawing.isVisible = false;
            racer.shipPhysics.removeFromPhysicsEngine();
        }
Esempio n. 6
0
 public abstract void finishRaceForTheRacer(Stopwatch finishTime, Racer racer, int points, int level);
Esempio n. 7
0
        //(Matrix viewMatrix, Matrix projectionMatrix)
        /// <summary>
        /// Draws a heads up display on the current camera in its viewport, as long as the ship is not PlayerType.None
        /// </summary>
        public static void DrawHUD(CameraWrapper camera, Racer racer, GameTime gameTime)
        {
            //Getting information from the GraphicsDevice might be very slow on Xbox
            int viewportHeight = camera.Viewport.Height;
            int viewportWidth = camera.Viewport.Width;

            if (racer.racerType == RacerType.None)
                return;//No HUD when just viewing ship model.
            //Draw speed text //must be after mesh.draw

            int vOffset = camera.Viewport.Height - 60;

            //MainGame.graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend;//Set display states

            int bleedHeight = (int)(viewportHeight * 0.1);
            int bleedWidth = (int)(viewportWidth * 0.1);

            if (racer.raceTiming.hasCompletedRace && GameLoop.raceComplete != true)
            {
                ////////////////////////
                ///// FINAL RESULTS ////
                ////////////////////////
                if (Race.currentRaceType.getRaceType().Equals(RaceType.LappedRace))
                {
                    //BeatShift.spriteBatch.Begin();//(SpriteSortMode.Immediate, BlendState.AlphaBlend);
                    //DrawMessage("Finished!", 325, vOffset / 2);
                    DrawMessageColour(BeatShift.newfont, "Finished!", viewportWidth / 4, viewportHeight / 2 + 40, 0.6f, Color.PapayaWhip);
                    //DrawMessage("Final Time: " + racer.raceTiming.getFinalTotalTime(), 300, vOffset / 2 + 40);
                }
                if (Race.currentRaceType.getRaceType().Equals(RaceType.EliminiationRace))
                {
                    BeatShift.spriteBatch.Draw(GameTextures.Eliminated, new Rectangle(viewportWidth / 2 - GameTextures.Eliminated.Width / 2, 3 * viewportHeight / 3, GameTextures.Eliminated.Width, GameTextures.Eliminated.Height), Color.PapayaWhip);
                    //DrawMessage("ELIMINATED!", 325, vOffset / 2);
                }
                if (Race.currentRaceType.getRaceType().Equals(RaceType.TimeTrialRace))
                {
                    //BeatShift.spriteBatch.Begin();
                    DrawMessageColour(BeatShift.newfont, "Best Lap: " + racer.raceTiming.getBestLapTime(), viewportWidth / 4, viewportHeight / 2, 0.5f, Color.PapayaWhip);
                    //DrawMessage("Best lap time: " + racer.raceTiming.getBestLapTime(), 325, vOffset / 2);
                }

            }
            else
            {
                //Draw messages to when points are given
                ////////////////////
                //// Points Msg ////
                ////////////////////
                racer.racerPoints.pointsPopupManager.Draw(new Vector2(80f, viewportHeight - 140));
                //DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(), viewportWidth - 125, 195, 0.3f, Color.Goldenrod);

                //////////////////
                //// Messages ////
                //////////////////
                racer.messagePopupManager.Draw(new Vector2(180f, viewportHeight - 140));
                //DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(),viewportWidth - 125, 195, 0.4f, Color.Goldenrod);

                /////////////////////
                ///// HUD BAR ///////
                /////////////////////
                int h = viewportWidth / (GameTextures.HudBar.Width / GameTextures.HudBar.Height);

                if (viewportWidth > 700)
                {
                    BeatShift.spriteBatch.Draw(GameTextures.HudBar, new Rectangle(0, viewportHeight - GameTextures.HudBar.Height, GameTextures.HudBar.Width, GameTextures.HudBar.Height), Color.White);
                }
                else
                {
                    BeatShift.spriteBatch.Draw(GameTextures.HudBarSmall, new Rectangle(0, viewportHeight - GameTextures.HudBarSmall.Height, GameTextures.HudBarSmall.Width, GameTextures.HudBarSmall.Height), Color.White);
                }
                ////////////////////////////
                ///// ORANGE BOOST BAR /////
                ////////////////////////////

                racer.raceTiming.previousBoost = MathHelper.Lerp(racer.raceTiming.previousBoost, (float)racer.racingControls.getBoostValue() / 100, 0.1f);
                racer.raceTiming.previousLapProgress = MathHelper.Lerp(racer.raceTiming.previousLapProgress, (float)racer.shipPhysics.getLapPercentage() / 100, 0.05f);

                var chosenLine = (viewportWidth > 700) ? GameTextures.BoostBarLine : GameTextures.BoostBarLineSmall;
                int srcWidth = (int)((chosenLine.Width) * racer.raceTiming.previousBoost);

                if (viewportWidth > 700)
                {
                    Rectangle orange_src2 = new Rectangle(chosenLine.Width - srcWidth, 0, chosenLine.Width, chosenLine.Height);
                    Rectangle orange_dest = new Rectangle(36, viewportHeight - chosenLine.Height, chosenLine.Width, chosenLine.Height);
                    BeatShift.spriteBatch.Draw(chosenLine, orange_dest, orange_src2, Color.White);
                }
                else
                {
                    Rectangle orange_src2 = new Rectangle(chosenLine.Width - srcWidth, 0, chosenLine.Width, chosenLine.Height);
                    Rectangle orange_dest = new Rectangle(21, viewportHeight - chosenLine.Height, chosenLine.Width, chosenLine.Height);
                    BeatShift.spriteBatch.Draw(chosenLine, orange_dest, orange_src2, Color.White);
                }

                /////////////////////////
                ///////// LEVEL /////////
                /////////////////////////

                if (viewportWidth > 700)
                {
                    DrawMessageColour(BeatShift.volterfont, "LEVEL", viewportWidth - 240, vOffset - 53, 0.5f, Color.PapayaWhip);
                    DrawMessageColour(BeatShift.volterfont, (racer.beatQueue.getLayer() + 1).ToString(), viewportWidth - 230, vOffset - 35, 1f, Color.PapayaWhip);
                }
                else
                {
                    DrawMessageColour(BeatShift.volterfont, "LEVEL", viewportWidth - 143, vOffset - 12, 0.4f, Color.PapayaWhip);
                    DrawMessageColour(BeatShift.volterfont, (racer.beatQueue.getLayer() + 1).ToString(), viewportWidth - 136, vOffset - 3, 0.8f, Color.PapayaWhip);
                }

                //////////////////////////
                /////// COMBO COUNT //////
                //////////////////////////

                //if (viewportWidth > 700)
                //{
                //    DrawMessageColour(BeatShift.volterfont, racer.beatQueue.getCombo().ToString()+"x", viewportWidth - 240, vOffset - 73, 3f, Color.Black);
                //}
                //else
                //{
                //    DrawMessageColour(BeatShift.volterfont, racer.beatQueue.getCombo().ToString() + "x", viewportWidth - 143, vOffset - 42, 2.4f, Color.Black);
                //}

                //DrawMessageColour(BeatShift.volterfont, GameDebugTools.ReflectionTracker.getTrackedAsString(), 0, 0, 1.2f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "nextWaypoint: " + racer.shipPhysics.nextWaypoint.getIndex(), 0, 50, 1.5f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "currentProgressWaypoint: " + racer.shipPhysics.currentProgressWaypoint.getIndex(), 0, 80, 1.5f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "nearestMapPoint: " + racer.shipPhysics.nearestMapPoint.getIndex(), 0, 110, 1.5f, Color.Black);

                ////////////////////////
                /////// SPEED //////////
                ////////////////////////
                try
                {
                    racer.raceTiming.previousSpeed = MathHelper.Lerp(racer.raceTiming.previousSpeed, (Math.Abs((int)racer.shipPhysics.getForwardSpeed())), 0.05f);
                }
                catch (OverflowException e)
                {
                    racer.raceTiming.previousSpeed = 0;
                }
                racer.raceTiming.speedToDisplay = String.Format("{0:0000}", racer.raceTiming.previousSpeed);
                if (viewportWidth > 700)
                {
                    DrawMessageColour(BeatShift.volterfont, "MPH", viewportWidth - 126, vOffset - 42, 0.5f, Color.Black);
                    DrawMessageColour(BeatShift.newfont, racer.raceTiming.speedToDisplay, viewportWidth - 185, vOffset - 48, 0.4f, Color.Black);
                }
                else
                {
                    DrawMessageColour(BeatShift.volterfont, "MPH", viewportWidth - 75, vOffset - 14, 0.5f, Color.Black);
                    DrawMessageColour(BeatShift.newfont, racer.raceTiming.speedToDisplay, viewportWidth - 110, vOffset - 8, 0.4f, Color.Black);
                }

                //////////////////////////////
                /////// TOP RIGHT BOARD //////
                //////////////////////////////

                double scaleFactorHeight = (double)viewportHeight / 720;
                double scaleFactorWidth = scaleFactorHeight;// (double)viewportWidth / 1280;

                int newBoardWidth = (int)(GameTextures.TopRightBoard.Width * scaleFactorWidth);
                int newBoardHeight = (int)(GameTextures.TopRightBoard.Height * scaleFactorHeight);

                if (Race.currentRaceType.getRaceType().Equals(RaceType.EliminiationRace))
                {
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.EliminationBar.Width, 0, GameTextures.EliminationBar.Width, GameTextures.EliminationBar.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.EliminationBar, d, Color.White);

                        if ( racer.raceTiming.currentRanking == Race.currentRacers.Count)
                            DrawMessageColour(BeatShift.newfont, "DANGER!", viewportWidth - 190, 55, 0.75f, Color.White);
                        else
                            DrawMessageColour(BeatShift.newfont, "SAFE", viewportWidth - 180, 55, 0.75f, Color.White);

                        //if (racer.raceTiming.currentRanking == 1)
                        //{
                        //    DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 160, 55, 0.75f, Color.PapayaWhip);
                        //    DrawMessageColour(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 140, 55, 0.75f, Color.PapayaWhip);
                        //}
                        //else
                        //{
                        //    DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 160, 55, 0.75f, Color.PapayaWhip);
                        //    DrawMessageColour(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 135, 55, 0.75f, Color.PapayaWhip);
                        //}
                    }
                }
                else if (Race.currentRaceType.getRaceType().Equals(RaceType.PointsRace))
                {
                    if (viewportWidth > 700)
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.PointsHUD.Width, 0, GameTextures.PointsHUD.Width, GameTextures.PointsHUD.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.PointsHUD, d, Color.White);
                    }
                    else
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.PointsHUD.Width, 0, GameTextures.PointsHUD.Width, GameTextures.PointsHUD.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.PointsHUD, d, Color.White);
                    }
                }
                else
                {
                    if (viewportWidth > 700)
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.TopRightBoard.Width, 0, GameTextures.TopRightBoard.Width, GameTextures.TopRightBoard.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.TopRightBoard, d, Color.White);
                    }
                    else
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.TopRightBoardSmall.Width, 0, GameTextures.TopRightBoardSmall.Width, GameTextures.TopRightBoardSmall.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.TopRightBoardSmall, d, Color.White);
                    }
                }

                //////////////////////////////
                //////// TOTAL POINTS ////////
                //////////////////////////////

                if (Race.currentRaceType.displayTotalPoints)
                {
                    DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(), viewportWidth - GameTextures.PointsHUD.Width/2 -65, 65, 1f, Color.PapayaWhip);
                }

                //////////////////////////////
                ////////// TOTAL LAPS ////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentLapOutofTotalLaps)
                {
                    if (viewportWidth > 700)
                    {
                        if (racer.raceTiming.isRacing == true)
                            DrawMessageColour(BeatShift.newfont, (racer.raceTiming.currentLap + 1) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 125, 33, 0.5f, Color.PapayaWhip);
                        else
                            DrawMessageColour(BeatShift.newfont, (racer.raceTiming.currentLap) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 125, 33, 0.5f, Color.PapayaWhip);
                        DrawMessageColour(BeatShift.volterfont, "LAPS", viewportWidth - 74, 39, 1f, Color.DimGray);
                    }
                    else
                    {
                        if (racer.raceTiming.isRacing == true)
                            DrawMessageColour(BeatShift.volterfont, (racer.raceTiming.currentLap + 1) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 82, 25, 0.5f, Color.PapayaWhip);
                        else
                            DrawMessageColour(BeatShift.volterfont, (racer.raceTiming.currentLap) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 82, 25, 0.5f, Color.PapayaWhip);
                        DrawMessageColour(BeatShift.volterfont, "LAPS", viewportWidth - 54, 25, 0.5f, Color.PapayaWhip);
                    }
                }

                //////////////////////////////
                ///////// CURRENT LAP ////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentLapTime)
                {
                    if (viewportWidth > 700)
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getCurrentLapTime(), viewportWidth - 125, 70, 0.4f, Color.PapayaWhip);
                    }
                    else
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getCurrentLapTime(), viewportWidth - 125, 36, 0.4f, Color.PapayaWhip);
                    }
                }
                /////////////////////////////
                ////// WRONG WAY SIGN ///////
                /////////////////////////////

                if (racer.shipPhysics.wrongWay == true)
                {
                    int newWarningWidth = (int)(GameTextures.WrongWaySign.Width * scaleFactorWidth);
                    int newWarningHeight = (int)(GameTextures.WrongWaySign.Height * scaleFactorHeight);
                    BeatShift.spriteBatch.Draw(GameTextures.WrongWaySign, new Rectangle(viewportWidth / 2 - newWarningWidth / 2, viewportHeight / 2 - newWarningHeight / 2, newWarningWidth, newWarningHeight), Color.White);
                }

                /////////////////////////////
                ////// RESETTING SIGN ///////
                /////////////////////////////

                if (racer.isRespawning && racer.shipPhysics.millisecsLeftTillReset < 2000)
                {
                    int newWarningWidth = (int)(GameTextures.ResettingSign.Width * scaleFactorWidth);
                    int newWarningHeight = (int)(GameTextures.ResettingSign.Height * scaleFactorHeight);
                    BeatShift.spriteBatch.Draw(GameTextures.ResettingSign, new Rectangle(viewportWidth / 2 - newWarningWidth / 2, viewportHeight / 2 - newWarningHeight / 2, newWarningWidth, newWarningHeight), Color.White);
                }

                /////////////////////////////
                ////// COUNTDOWN SIGN ///////
                /////////////////////////////

                if (Race.currentRaceType.countDownRunning)
                    BeatShift.spriteBatch.Draw(Race.currentRaceType.countdownState, new Vector2(viewportWidth / 2 - Race.currentRaceType.countdownState.Width / 2, viewportHeight / 2 - Race.currentRaceType.countdownState.Height / 2), Color.White);

                // Other info
                //DrawMessage("Progress: " + racer.getLapPercentage() + "%", 10, vOffset + 26);
                //DrawMessage("Accuracy: " + racer.racingControls.getLastPress(), 10, vOffset - 30);
                //DrawMessage("Dist from trac: " + racer.shipPhysics.shipRayToTrackTime, 10, vOffset - 30);
                //DrawNewMessage(" !\"#$%'()*+,-./0123456789:;<=>?@ABCDEFGHIJ", 0, 30);
                //DrawNewMessage("KLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrrstuvwxyz{|}~", 0, 90);

                //////////////////////////////
                ////////// BEST LAP //////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentBestLap)
                {
                    if (viewportWidth > 700)
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getBestLapTime(), viewportWidth - 125, 95, 0.4f, Color.Goldenrod);
                    }

                    //////////////////////////
                    ////////// RANK //////////
                    //////////////////////////

                    if (Race.currentRaceType.displayCurrentRank && racer.raceTiming.currentRanking == 0)
                    {
                        if (viewportWidth > 700)
                        {
                            DrawMessageColour(BeatShift.newfont, "-", viewportWidth - 190, 22, 0.75f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, "-", viewportWidth - 187, 22, 0.75f, Color.PapayaWhip);
                        }
                    }
                    else if (Race.currentRaceType.displayCurrentRank)
                    {
                        if (viewportWidth > 700)
                        {
                            DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 190, 22, 0.75f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 187, 22, 0.75f, Color.PapayaWhip);
                        }
                        //DrawMessage(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 178 + extraSuffixOffset(racer.raceTiming.currentRanking), 26, 0.25f);
                    }
                }

            }
        }
Esempio n. 8
0
 public BeatQueue(Racer racer)
 {
     parentRacer = racer;
     beats       = new Queue <Beat>();
     maxLayer    = BeatShift.bgm.Layers();
 }
Esempio n. 9
0
        /// <summary>
        /// Draws a heads up display on the current camera in its viewport, as long as the ship is not PlayerType.None
        /// </summary>
        public static void DrawHUD(CameraWrapper camera, Racer racer, GameTime gameTime)//(Matrix viewMatrix, Matrix projectionMatrix)
        {
            //Getting information from the GraphicsDevice might be very slow on Xbox
            int viewportHeight = camera.Viewport.Height;
            int viewportWidth  = camera.Viewport.Width;

            if (racer.racerType == RacerType.None)
            {
                return;//No HUD when just viewing ship model.
            }
            //Draw speed text //must be after mesh.draw

            int vOffset = camera.Viewport.Height - 60;

            //MainGame.graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend;//Set display states

            int bleedHeight = (int)(viewportHeight * 0.1);
            int bleedWidth  = (int)(viewportWidth * 0.1);


            if (racer.raceTiming.hasCompletedRace && GameLoop.raceComplete != true)
            {
                ////////////////////////
                ///// FINAL RESULTS ////
                ////////////////////////
                if (Race.currentRaceType.getRaceType().Equals(RaceType.LappedRace))
                {
                    //BeatShift.spriteBatch.Begin();//(SpriteSortMode.Immediate, BlendState.AlphaBlend);
                    //DrawMessage("Finished!", 325, vOffset / 2);
                    DrawMessageColour(BeatShift.newfont, "Finished!", viewportWidth / 4, viewportHeight / 2 + 40, 0.6f, Color.PapayaWhip);
                    //DrawMessage("Final Time: " + racer.raceTiming.getFinalTotalTime(), 300, vOffset / 2 + 40);
                }
                if (Race.currentRaceType.getRaceType().Equals(RaceType.EliminiationRace))
                {
                    BeatShift.spriteBatch.Draw(GameTextures.Eliminated, new Rectangle(viewportWidth / 2 - GameTextures.Eliminated.Width / 2, 3 * viewportHeight / 3, GameTextures.Eliminated.Width, GameTextures.Eliminated.Height), Color.PapayaWhip);
                    //DrawMessage("ELIMINATED!", 325, vOffset / 2);
                }
                if (Race.currentRaceType.getRaceType().Equals(RaceType.TimeTrialRace))
                {
                    //BeatShift.spriteBatch.Begin();
                    DrawMessageColour(BeatShift.newfont, "Best Lap: " + racer.raceTiming.getBestLapTime(), viewportWidth / 4, viewportHeight / 2, 0.5f, Color.PapayaWhip);
                    //DrawMessage("Best lap time: " + racer.raceTiming.getBestLapTime(), 325, vOffset / 2);
                }
            }
            else
            {
                //Draw messages to when points are given
                ////////////////////
                //// Points Msg ////
                ////////////////////
                racer.racerPoints.pointsPopupManager.Draw(new Vector2(80f, viewportHeight - 140));
                //DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(), viewportWidth - 125, 195, 0.3f, Color.Goldenrod);

                //////////////////
                //// Messages ////
                //////////////////
                racer.messagePopupManager.Draw(new Vector2(180f, viewportHeight - 140));
                //DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(),viewportWidth - 125, 195, 0.4f, Color.Goldenrod);

                /////////////////////
                ///// HUD BAR ///////
                /////////////////////
                int h = viewportWidth / (GameTextures.HudBar.Width / GameTextures.HudBar.Height);

                if (viewportWidth > 700)
                {
                    BeatShift.spriteBatch.Draw(GameTextures.HudBar, new Rectangle(0, viewportHeight - GameTextures.HudBar.Height, GameTextures.HudBar.Width, GameTextures.HudBar.Height), Color.White);
                }
                else
                {
                    BeatShift.spriteBatch.Draw(GameTextures.HudBarSmall, new Rectangle(0, viewportHeight - GameTextures.HudBarSmall.Height, GameTextures.HudBarSmall.Width, GameTextures.HudBarSmall.Height), Color.White);
                }
                ////////////////////////////
                ///// ORANGE BOOST BAR /////
                ////////////////////////////

                racer.raceTiming.previousBoost       = MathHelper.Lerp(racer.raceTiming.previousBoost, (float)racer.racingControls.getBoostValue() / 100, 0.1f);
                racer.raceTiming.previousLapProgress = MathHelper.Lerp(racer.raceTiming.previousLapProgress, (float)racer.shipPhysics.getLapPercentage() / 100, 0.05f);

                var chosenLine = (viewportWidth > 700) ? GameTextures.BoostBarLine : GameTextures.BoostBarLineSmall;
                int srcWidth   = (int)((chosenLine.Width) * racer.raceTiming.previousBoost);

                if (viewportWidth > 700)
                {
                    Rectangle orange_src2 = new Rectangle(chosenLine.Width - srcWidth, 0, chosenLine.Width, chosenLine.Height);
                    Rectangle orange_dest = new Rectangle(36, viewportHeight - chosenLine.Height, chosenLine.Width, chosenLine.Height);
                    BeatShift.spriteBatch.Draw(chosenLine, orange_dest, orange_src2, Color.White);
                }
                else
                {
                    Rectangle orange_src2 = new Rectangle(chosenLine.Width - srcWidth, 0, chosenLine.Width, chosenLine.Height);
                    Rectangle orange_dest = new Rectangle(21, viewportHeight - chosenLine.Height, chosenLine.Width, chosenLine.Height);
                    BeatShift.spriteBatch.Draw(chosenLine, orange_dest, orange_src2, Color.White);
                }

                /////////////////////////
                ///////// LEVEL /////////
                /////////////////////////

                if (viewportWidth > 700)
                {
                    DrawMessageColour(BeatShift.volterfont, "LEVEL", viewportWidth - 240, vOffset - 53, 0.5f, Color.PapayaWhip);
                    DrawMessageColour(BeatShift.volterfont, (racer.beatQueue.getLayer() + 1).ToString(), viewportWidth - 230, vOffset - 35, 1f, Color.PapayaWhip);
                }
                else
                {
                    DrawMessageColour(BeatShift.volterfont, "LEVEL", viewportWidth - 143, vOffset - 12, 0.4f, Color.PapayaWhip);
                    DrawMessageColour(BeatShift.volterfont, (racer.beatQueue.getLayer() + 1).ToString(), viewportWidth - 136, vOffset - 3, 0.8f, Color.PapayaWhip);
                }

                //////////////////////////
                /////// COMBO COUNT //////
                //////////////////////////

                //if (viewportWidth > 700)
                //{
                //    DrawMessageColour(BeatShift.volterfont, racer.beatQueue.getCombo().ToString()+"x", viewportWidth - 240, vOffset - 73, 3f, Color.Black);
                //}
                //else
                //{
                //    DrawMessageColour(BeatShift.volterfont, racer.beatQueue.getCombo().ToString() + "x", viewportWidth - 143, vOffset - 42, 2.4f, Color.Black);
                //}


                //DrawMessageColour(BeatShift.volterfont, GameDebugTools.ReflectionTracker.getTrackedAsString(), 0, 0, 1.2f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "nextWaypoint: " + racer.shipPhysics.nextWaypoint.getIndex(), 0, 50, 1.5f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "currentProgressWaypoint: " + racer.shipPhysics.currentProgressWaypoint.getIndex(), 0, 80, 1.5f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "nearestMapPoint: " + racer.shipPhysics.nearestMapPoint.getIndex(), 0, 110, 1.5f, Color.Black);

                ////////////////////////
                /////// SPEED //////////
                ////////////////////////
                try
                {
                    racer.raceTiming.previousSpeed = MathHelper.Lerp(racer.raceTiming.previousSpeed, (Math.Abs((int)racer.shipPhysics.getForwardSpeed())), 0.05f);
                }
                catch (OverflowException e)
                {
                    racer.raceTiming.previousSpeed = 0;
                }
                racer.raceTiming.speedToDisplay = String.Format("{0:0000}", racer.raceTiming.previousSpeed);
                if (viewportWidth > 700)
                {
                    DrawMessageColour(BeatShift.volterfont, "MPH", viewportWidth - 126, vOffset - 42, 0.5f, Color.Black);
                    DrawMessageColour(BeatShift.newfont, racer.raceTiming.speedToDisplay, viewportWidth - 185, vOffset - 48, 0.4f, Color.Black);
                }
                else
                {
                    DrawMessageColour(BeatShift.volterfont, "MPH", viewportWidth - 75, vOffset - 14, 0.5f, Color.Black);
                    DrawMessageColour(BeatShift.newfont, racer.raceTiming.speedToDisplay, viewportWidth - 110, vOffset - 8, 0.4f, Color.Black);
                }

                //////////////////////////////
                /////// TOP RIGHT BOARD //////
                //////////////////////////////

                double scaleFactorHeight = (double)viewportHeight / 720;
                double scaleFactorWidth  = scaleFactorHeight;// (double)viewportWidth / 1280;

                int newBoardWidth  = (int)(GameTextures.TopRightBoard.Width * scaleFactorWidth);
                int newBoardHeight = (int)(GameTextures.TopRightBoard.Height * scaleFactorHeight);

                if (Race.currentRaceType.getRaceType().Equals(RaceType.EliminiationRace))
                {
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.EliminationBar.Width, 0, GameTextures.EliminationBar.Width, GameTextures.EliminationBar.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.EliminationBar, d, Color.White);

                        if (racer.raceTiming.currentRanking == Race.currentRacers.Count)
                        {
                            DrawMessageColour(BeatShift.newfont, "DANGER!", viewportWidth - 190, 55, 0.75f, Color.White);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, "SAFE", viewportWidth - 180, 55, 0.75f, Color.White);
                        }

                        //if (racer.raceTiming.currentRanking == 1)
                        //{
                        //    DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 160, 55, 0.75f, Color.PapayaWhip);
                        //    DrawMessageColour(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 140, 55, 0.75f, Color.PapayaWhip);
                        //}
                        //else
                        //{
                        //    DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 160, 55, 0.75f, Color.PapayaWhip);
                        //    DrawMessageColour(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 135, 55, 0.75f, Color.PapayaWhip);
                        //}
                    }
                }
                else if (Race.currentRaceType.getRaceType().Equals(RaceType.PointsRace))
                {
                    if (viewportWidth > 700)
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.PointsHUD.Width, 0, GameTextures.PointsHUD.Width, GameTextures.PointsHUD.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.PointsHUD, d, Color.White);
                    }
                    else
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.PointsHUD.Width, 0, GameTextures.PointsHUD.Width, GameTextures.PointsHUD.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.PointsHUD, d, Color.White);
                    }
                }
                else
                {
                    if (viewportWidth > 700)
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.TopRightBoard.Width, 0, GameTextures.TopRightBoard.Width, GameTextures.TopRightBoard.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.TopRightBoard, d, Color.White);
                    }
                    else
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.TopRightBoardSmall.Width, 0, GameTextures.TopRightBoardSmall.Width, GameTextures.TopRightBoardSmall.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.TopRightBoardSmall, d, Color.White);
                    }
                }


                //////////////////////////////
                //////// TOTAL POINTS ////////
                //////////////////////////////

                if (Race.currentRaceType.displayTotalPoints)
                {
                    DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(), viewportWidth - GameTextures.PointsHUD.Width / 2 - 65, 65, 1f, Color.PapayaWhip);
                }

                //////////////////////////////
                ////////// TOTAL LAPS ////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentLapOutofTotalLaps)
                {
                    if (viewportWidth > 700)
                    {
                        if (racer.raceTiming.isRacing == true)
                        {
                            DrawMessageColour(BeatShift.newfont, (racer.raceTiming.currentLap + 1) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 125, 33, 0.5f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, (racer.raceTiming.currentLap) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 125, 33, 0.5f, Color.PapayaWhip);
                        }
                        DrawMessageColour(BeatShift.volterfont, "LAPS", viewportWidth - 74, 39, 1f, Color.DimGray);
                    }
                    else
                    {
                        if (racer.raceTiming.isRacing == true)
                        {
                            DrawMessageColour(BeatShift.volterfont, (racer.raceTiming.currentLap + 1) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 82, 25, 0.5f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.volterfont, (racer.raceTiming.currentLap) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 82, 25, 0.5f, Color.PapayaWhip);
                        }
                        DrawMessageColour(BeatShift.volterfont, "LAPS", viewportWidth - 54, 25, 0.5f, Color.PapayaWhip);
                    }
                }

                //////////////////////////////
                ///////// CURRENT LAP ////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentLapTime)
                {
                    if (viewportWidth > 700)
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getCurrentLapTime(), viewportWidth - 125, 70, 0.4f, Color.PapayaWhip);
                    }
                    else
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getCurrentLapTime(), viewportWidth - 125, 36, 0.4f, Color.PapayaWhip);
                    }
                }
                /////////////////////////////
                ////// WRONG WAY SIGN ///////
                /////////////////////////////

                if (racer.shipPhysics.wrongWay == true)
                {
                    int newWarningWidth  = (int)(GameTextures.WrongWaySign.Width * scaleFactorWidth);
                    int newWarningHeight = (int)(GameTextures.WrongWaySign.Height * scaleFactorHeight);
                    BeatShift.spriteBatch.Draw(GameTextures.WrongWaySign, new Rectangle(viewportWidth / 2 - newWarningWidth / 2, viewportHeight / 2 - newWarningHeight / 2, newWarningWidth, newWarningHeight), Color.White);
                }

                /////////////////////////////
                ////// RESETTING SIGN ///////
                /////////////////////////////

                if (racer.isRespawning && racer.shipPhysics.millisecsLeftTillReset < 2000)
                {
                    int newWarningWidth  = (int)(GameTextures.ResettingSign.Width * scaleFactorWidth);
                    int newWarningHeight = (int)(GameTextures.ResettingSign.Height * scaleFactorHeight);
                    BeatShift.spriteBatch.Draw(GameTextures.ResettingSign, new Rectangle(viewportWidth / 2 - newWarningWidth / 2, viewportHeight / 2 - newWarningHeight / 2, newWarningWidth, newWarningHeight), Color.White);
                }

                /////////////////////////////
                ////// COUNTDOWN SIGN ///////
                /////////////////////////////

                if (Race.currentRaceType.countDownRunning)
                {
                    BeatShift.spriteBatch.Draw(Race.currentRaceType.countdownState, new Vector2(viewportWidth / 2 - Race.currentRaceType.countdownState.Width / 2, viewportHeight / 2 - Race.currentRaceType.countdownState.Height / 2), Color.White);
                }

                // Other info
                //DrawMessage("Progress: " + racer.getLapPercentage() + "%", 10, vOffset + 26);
                //DrawMessage("Accuracy: " + racer.racingControls.getLastPress(), 10, vOffset - 30);
                //DrawMessage("Dist from trac: " + racer.shipPhysics.shipRayToTrackTime, 10, vOffset - 30);
                //DrawNewMessage(" !\"#$%'()*+,-./0123456789:;<=>?@ABCDEFGHIJ", 0, 30);
                //DrawNewMessage("KLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrrstuvwxyz{|}~", 0, 90);


                //////////////////////////////
                ////////// BEST LAP //////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentBestLap)
                {
                    if (viewportWidth > 700)
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getBestLapTime(), viewportWidth - 125, 95, 0.4f, Color.Goldenrod);
                    }

                    //////////////////////////
                    ////////// RANK //////////
                    //////////////////////////

                    if (Race.currentRaceType.displayCurrentRank && racer.raceTiming.currentRanking == 0)
                    {
                        if (viewportWidth > 700)
                        {
                            DrawMessageColour(BeatShift.newfont, "-", viewportWidth - 190, 22, 0.75f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, "-", viewportWidth - 187, 22, 0.75f, Color.PapayaWhip);
                        }
                    }
                    else if (Race.currentRaceType.displayCurrentRank)
                    {
                        if (viewportWidth > 700)
                        {
                            DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 190, 22, 0.75f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 187, 22, 0.75f, Color.PapayaWhip);
                        }
                        //DrawMessage(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 178 + extraSuffixOffset(racer.raceTiming.currentRanking), 26, 0.25f);
                    }
                }
            }
        }
Esempio n. 10
0
 public BeatQueue(Racer racer)
 {
     parentRacer = racer;
     beats = new Queue<Beat>();
     maxLayer = BeatShift.bgm.Layers();
 }
Esempio n. 11
0
 public ShipDrawing(Func <Matrix> getDrawOrientationMatrix, Func <Vector3> getPosition, Racer parent)
 {
     parentRacer = parent;
     //parent.raceTiming.previousSpeed();
     setPositionFunctions(getDrawOrientationMatrix, getPosition);
     //System.Diagnostics.Debug.WriteLine(engineGlow.Emitter.ParticlesPerSecond);
     LoadContent();
 }
Esempio n. 12
0
 public abstract void finishRaceForTheRacer(Stopwatch finishTime, Racer racer, int points, int level);
Esempio n. 13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="cGame">Handle to the Game object being used. Pass in null for this 
 /// parameter if not using a Game object.</param>
 public EngineParticleSystem(Game cGame, Racer ParentRacer) : base(cGame) { parentRacer = ParentRacer; }
Esempio n. 14
0
 public static void setupAIRacers(int numberOfAiRacers)
 {
     //Add AI racers
     initializeAiNames();
     if (!currentRaceType.getRaceType().Equals(RaceType.TimeTrialRace))
     {
         for (int i = 0; i < numberOfAiRacers; i++)
         {
             Racer r = new Racer(new RacerId(pickAiName(i)), currentRacers.Count+1, RacerType.AI);
             currentRacers.Add(r);
         }
     }
     //setupViewports();
 }