public Time() { Timer = 0; Gametimestamp = 0; Week_day = 0; Day = 0; Step = 1000; Pause = new Button(globals.games_pause, new Vector2(170, 5), 25, 25); Speed = new Button(new List<Texture2D> { globals.game_normal, globals.game_fast, globals.game_faster }, new Vector2(200, 5), 25, 25); Speed.type = 1; current_state = time_flow.Normal; location = new Vector2(0, 0); }
public static void Update(GameTime gameTime) { Timer += gameTime.ElapsedGameTime.TotalMilliseconds; // Increment the timer by the elapsed game time. switch (current_state) { case time_flow.Normal: Step = 1000; break; case time_flow.x2: Step = 500; break; case time_flow.x3: Step = 50; break; } if (!(current_state == time_flow.Pause)) { if (Timer >= Step) { Gametimestamp += 1; // Increment the clock hour by 1 if (Gametimestamp%1440 ==0) { Week_day += 1; Day += 1; Week_day = Week_day % 7; } Timer = 0; } } //Update Button Controll logic MouseState state = Mouse.GetState(); if (current_state == time_flow.Pause) { if (Speed.Pressed(state)) { current_state = time_flow.Normal; Speed.type = 1; } } else if (current_state == time_flow.Normal) { if (Speed.Pressed(state)) { current_state = time_flow.x2; Speed.type = 2; } } else if (current_state == time_flow.x2) { if (Speed.Pressed(state)) { current_state = time_flow.x3; Speed.type = 0; } } else if (current_state == time_flow.x3) { if (Speed.Pressed(state)) { current_state = time_flow.Normal; Speed.type = 1; } } //pause button check if (Pause.Pressed(state)) { current_state = time_flow.Pause; Speed.type = 0; } }