Ejemplo n.º 1
0
        /// <summary>
        /// Start new lap, checks if the newReplay is good and
        /// can be stored as best replay :)
        /// </summary>
        public void StartNewLap()
        {
            float thisLapTime =
                RacingGameManager.Player.GameTimeMilliseconds / 1000.0f;

            // Upload new highscore (as we currently are in game,
            // no bonus or anything will be added, this score is low!)
            Highscores.SubmitHighscore((int)level,
                (int)RacingGameManager.Player.GameTimeMilliseconds);

            RacingGameManager.Player.AddLapTime(thisLapTime);

            if (thisLapTime < bestReplay.LapTime)
            {
                // Add final checkpoint
                RacingGameManager.Landscape.NewReplay.CheckpointTimes.Add(
                    thisLapTime);

                // Save this replay to load it everytime in the future
                newReplay.Save(thisLapTime);

                // Set it as the current best replay
                bestReplay = newReplay;
            } // if

            // And start a new replay for this round
            newReplay = new Replay((int)level, true, track);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reload level
        /// </summary>
        /// <param name="setLevel">Level</param>
        internal void ReloadLevel(RacingGameManager.Level setLevel)
        {
            level = setLevel;

            // Load track based on the level selection, do this after
            // we got all the height data because the track might be adjusted.
            if (track == null)
                track = new Track("Track" + level.ToString(), this);
            else
                track.Reload("Track" + level.ToString(), this);

            // Load replay for this track to show best player
            bestReplay = new Replay((int)level, false, track);
            newReplay = new Replay((int)level, true, track);

            // Kill brake tracks
            brakeTracksVertices.Clear();
            brakeTracksVerticesArray = null;

            // Set car at start pos
            SetCarToStartPosition();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Start new lap, checks if the newReplay is good and
        /// can be stored as best replay :)
        /// </summary>
        public void StartNewLap()
        {
            float thisLapTime =
                RacingGameManager.Player.GameTimeMilliseconds / 1000.0f;

            // Upload new highscore (as we currently are in game,
            // no bonus or anything will be added, this score is low!)
            Highscores.SubmitHighscore((int)level,
                (int)RacingGameManager.Player.GameTimeMilliseconds);

            RacingGameManager.Player.AddLapTime(thisLapTime);

            if (thisLapTime < bestReplay.LapTime)
            {
                // Add final checkpoint
                RacingGameManager.Landscape.NewReplay.CheckpointTimes.Add(
                    thisLapTime);

                // Record lap time
                newReplay.LapTime = thisLapTime;

                // Save this replay to load it everytime in the future
                // Do this on a worker thread to prevent the game from skipping frames
                ThreadPool.QueueUserWorkItem(new WaitCallback(SaveReplay),
                                            (Replay)newReplay.Clone());

                // Set it as the current best replay
                bestReplay = newReplay;
            }

            // And start a new replay for this round
            newReplay = new Replay((int)level, true, track);
        }