Beispiel #1
0
 public override void Start(RacingController controller)
 {
     controller.InfoDisplay.text       = "";
     TimeCountdownStarted              = Time.time;
     CurrentCountdown                  = CountdownFrom;
     controller.CarUserControl.enabled = false;
 }
Beispiel #2
0
 public override void Update(RacingController controller)
 {
     UpdateTimerPauseState(controller);
     UpdateTime(controller);
     UpdateWarnings(controller);
     UpdateSpeed(controller);
 }
Beispiel #3
0
 public override void Start(RacingController controller)
 {
     controller.StateRacing.ClearHUD(controller);
     controller.DeathScreen.ShowAll();
     controller.CarUserControl.enabled = false;
     controller.ZombieEatingAudio.Play();
 }
Beispiel #4
0
        private void UpdateTimerPauseState(RacingController controller)
        {
            if (controller.PauseMenuManager.GamePaused)
            {
                if (WarningTime != null && !WarningTime.IsPaused)
                {
                    WarningTime.Pause();
                }

                if (CurrentRound != null && !CurrentRound.Timer.IsPaused)
                {
                    CurrentRound.Timer.Pause();
                }
            }
            else
            {
                if (WarningTime != null && WarningTime.IsPaused)
                {
                    WarningTime.Unpause();
                }

                if (CurrentRound != null && CurrentRound.Timer.IsPaused)
                {
                    CurrentRound.Timer.Unpause();
                }
            }
        }
Beispiel #5
0
 public void ClearHUD(RacingController controller)
 {
     controller.InfoDisplay.text           = "";
     controller.TimeDisplay.text           = "";
     controller.WarningMessageDisplay.text = "";
     controller.SpeedDisplay.text          = "";
     controller.NormalInfoDisplay.text     = "";
 }
Beispiel #6
0
        public override void Start(RacingController controller)
        {
            Rounds       = new List <RoundInformation>();
            CurrentRound = new RoundInformation();
            controller.CarUserControl.enabled = true;

            ClearHUD(controller);
        }
Beispiel #7
0
        private void UpdateWarnings(RacingController controller)
        {
            if (controller.RoadController.OffTrack)
            {
                StartWarningIfNotRunning(controller);
                controller.WarningMessageDisplay.text = "Off Track<br>The Zombies will eat you!";
            }
            else if (controller.RoadController.WrongDirection)
            {
                StartWarningIfNotRunning(controller);
                controller.WarningMessageDisplay.text = "Wrong direction<br>The Zombies will devour you!";
            }
            else if (controller.CarController.CurrentSpeed < controller.MinSpeed)
            {
                // prevent stop
            }
            else if (controller.Hits > controller.WarningHits)
            {
                // prevent stop
            }
            else
            {
                controller.WarningMessageDisplay.text = "";
                StopWarning(controller);
            }

            if (controller.Hits > controller.WarningHits)
            {
                StartWarningIfNotRunning(controller);
            }

            if (controller.CarController.CurrentSpeed < controller.MinSpeed)
            {
                controller.SpeedDisplayBlink.StartBlink();
                StartWarningIfNotRunning(controller);
            }
            else
            {
                controller.SpeedDisplayBlink.StopBlink();
            }

            if (WarningTime != null && WarningTime.IsRunning)
            {
                var a      = controller.WarningZombie;
                var volume = controller.WarningIntensity.Evaluate(WarningTime.ElapsedMilliseconds / 1000.0f / controller.SecondsTillDeath);
                a.SetVolume(volume);

                if (volume >= 1.0f)   // time elapsed = dead
                {
                    ClearHUD(controller);
                    a.Fadeout();
                    controller.CarController.Stop();
                    controller.SwitchToDead();
                    WarningTime.Stop();
                }
            }
        }
Beispiel #8
0
        private void StopWarning(RacingController controller)
        {
            if (WarningTime == null)
            {
                return;
            }

            WarningTime.Stop();
            var a = controller.WarningZombie;

            a.Fadeout();
        }
Beispiel #9
0
        public override void Update(RacingController controller)
        {
            CurrentCountdown = CountdownFrom - Mathf.FloorToInt(Time.time - TimeCountdownStarted);

            controller.InfoDisplay.text = "" + CurrentCountdown + "";

            if (CurrentCountdown <= 0)
            {
                controller.InfoDisplay.text = "";
                controller.SwitchToRacing();
            }
        }
Beispiel #10
0
        public override void OnStartFinishTrigger(RacingController controller)
        {
            CurrentRound.Stop();
            Rounds.Add(CurrentRound);
            var roundTime = -1;

            if (CurrentRound != null)
            {
                roundTime = CurrentRound.Duration().Milliseconds;
            }

            CurrentRound = new RoundInformation();

            if (Rounds.Count >= controller.LapsToWin)
            {
                controller.WarningZombie.Stop();
                controller.CarController.Stop();
                controller.SwitchToWon();
            }
            else
            {
                if (Rounds.Count == controller.LapsToWin - 1)
                {
                    controller.NormalInfoDisplay.text = "Final Round";
                    controller.FinalRoundAudio.Play();
                }
                else
                {
                    controller.NormalInfoDisplay.text = "Next Lap";

                    // is this a new best time?
                    if (roundTime > 0)
                    {
                        for (var i = 0; i < Rounds.Count; i++)
                        {
                            if (Rounds[i].Duration().Milliseconds < roundTime)
                            {
                                controller.NewBestTime.Play();
                                break;
                            }
                        }
                    }
                }

                controller.StartCoroutine(controller.ClearInfoDisplay());
            }
        }
Beispiel #11
0
        private void UpdateTime(RacingController controller)
        {
            controller.LapDisplay.text = (Rounds.Count + 1) + " / " + controller.LapsToWin;

            var currentTime = FloatToRaceTime(CurrentRound.Duration());

            var lastTimes = "";

            for (var i = Rounds.Count - 1; i >= Math.Max(Rounds.Count - 3, 0); i--)
            {
                var r = Rounds[i];
                lastTimes += FloatToRaceTime(r.Duration()) + "\n";
            }

            var timeDisplay = currentTime + "\n<size=50%>";

            timeDisplay += lastTimes;
            timeDisplay += "</size>";

            controller.TimeDisplay.text = timeDisplay;
        }
Beispiel #12
0
        private void StartWarningIfNotRunning(RacingController controller)
        {
            var wasRunning = true;

            if (WarningTime == null)
            {
                WarningTime = new PausableStopwatch();
                wasRunning  = false;
            }
            else if (!WarningTime.IsRunning)
            {
                WarningTime.Start();
                wasRunning = false;
            }

            if (!wasRunning)
            {
                // play sound
                var a = controller.WarningZombie;
                a.Play(controller.WarningIntensity.Evaluate(0));
            }
        }
Beispiel #13
0
 public abstract void Update(RacingController controller);
Beispiel #14
0
 public override void Start(RacingController controller)
 {
     controller.StateRacing.ClearHUD(controller);
     controller.SuccessScreen.ShowAll();
     controller.CarUserControl.enabled = false;
 }
Beispiel #15
0
 public virtual void ClearHUD(RacingController controller)
 {
 }
Beispiel #16
0
 public virtual void OnStartFinishTrigger(RacingController controller)
 {
 }
Beispiel #17
0
 public override void ClearHUD(RacingController controller)
 {
     controller.DeathScreen.HideAll();
     controller.SuccessScreen.HideAll();
 }
Beispiel #18
0
 private void UpdateSpeed(RacingController controller)
 {
     controller.SpeedDisplay.text = controller.CarController.CurrentSpeed.ToString("000") + " km/h";
 }
Beispiel #19
0
 public override void Update(RacingController controller)
 {
 }
Beispiel #20
0
 public abstract void Start(RacingController controller);