public InitState(Game game) : base(game) { _currentState = InitStateState.FirstRun; _centerText = "Loading"; _animationText = ""; _animationTimeCounter = 0f; }
private async void Load() { var minWaitTime = Task.Run(() => Thread.Sleep(MinMillisecondsLoading)); Resources.AcaLogo = game.Content.Load <Texture2D>("acaLogo"); Resources.TaxiOrb = game.Content.Load <Model>("taxiOrb"); Resources.Background = game.Content.Load <Texture2D>("background"); Resources.Font22 = game.Content.Load <SpriteFont>("font22"); await minWaitTime.ConfigureAwait(true); _currentState = InitStateState.Done; }
public override void Update(GameTime gameTime) { switch (_currentState) { case InitStateState.FirstRun: var task = new Task(Load); _currentState = InitStateState.Loading; task.Start(); return; case InitStateState.Loading: _animationTimeCounter += gameTime.ElapsedGameTime.Milliseconds; if (_animationTimeCounter >= 500) { _animationText += "."; _animationTimeCounter = 0f; } if (_animationText.Length > 3) { _animationText = ""; } _pulseTime += (float)gameTime.ElapsedGameTime.TotalSeconds; break; case InitStateState.Done: NextState = new MainMenuState(game); Finished = true; break; } }