Exemplo n.º 1
0
        public void Update(float speed)
        {
            switch (State)
            {
            case AccelerationTimerState.Off:
                break;

            case AccelerationTimerState.WaitingForStop:
                if (speed == 0)
                {
                    State = AccelerationTimerState.Ready;
                }
                break;

            case AccelerationTimerState.Ready:
                if (speed != 0)
                {
                    State = AccelerationTimerState.Counting;
                }
                break;

            case AccelerationTimerState.Counting:
                if (speed >= (float)100000 / 3600)     // 100 kph
                {
                    State           = AccelerationTimerState.Finished;
                    timerText.Color = Color.Red;
                    displayTime     = 0;
                }
                else
                {
                    watchTime += Game.LastFrameTime;
                }
                break;

            case AccelerationTimerState.Finished:
                displayTime += Game.LastFrameTime;
                if (displayTime > TIME_DISPLAYFINISHED)
                {
                    displayTime = 0;
                    this.Stop();
                }
                break;
            }
        }
Exemplo n.º 2
0
 public void Stop()
 {
     State = AccelerationTimerState.Off;
 }
Exemplo n.º 3
0
 public AccelerationTimerWidget()
 {
     State     = AccelerationTimerState.Off;
     timerText = new UIText("", new Point(UI.WIDTH / 2, UI.HEIGHT / 2), 0.5f, Color.White, 0, true);
 }
Exemplo n.º 4
0
 public void Start()
 {
     State           = AccelerationTimerState.WaitingForStop;
     watchTime       = 0;
     timerText.Color = Color.White; // reset color
 }