public void Update(GameTime gameTime) { if (_moon == null) { _moon = new Moon(this, _spriteSheet, _trex, new Vector2(TRexRunnerGame.WINDOW_WIDTH, MOON_POS_Y)); _moon.DrawOrder = MOON_DRAW_ORDER; _entityManager.AddEntity(_moon); } HandleCloudSpawning(); HandleStarSpawning(); foreach (SkyObject skyObject in _entityManager.GetEntitiesOfType <SkyObject>().Where(s => s.Position.X < -100)) { if (skyObject is Moon moon) { moon.Position = new Vector2(TRexRunnerGame.WINDOW_WIDTH, MOON_POS_Y); } else { _entityManager.RemoveEntity(skyObject); } } if (_previousScore != 0 && _previousScore < _scoreBoard.DisplayScore && _previousScore / NIGHT_TIME_SCORE != _scoreBoard.DisplayScore / NIGHT_TIME_SCORE) { TransitionToNightTime(); } if (IsNight && (_scoreBoard.DisplayScore - _nightTimeStartScore >= NIGHT_TIME_DURATION_SCORE)) { TransitionToDayTime(); } if (_scoreBoard.DisplayScore < NIGHT_TIME_SCORE && (IsNight || _isTransitioningToNight)) { TransitionToDayTime(); } UpdateTransition(gameTime); _previousScore = _scoreBoard.DisplayScore; }
public void Update(GameTime gameTime) { if (_moon == null) { _moon = new Moon(this, _spriteSheet, _trex, new Vector2(TRexGame.WINDOW_WIDTH, MOON_POS_Y)); _moon.DrawOrder = MOON_DRAW_ORDER; _entityManager.AddEntity(_moon); } HandleCloudSpawning(); HandleStarSpawning(); foreach (SkyObject skyObject in _entityManager.GetEntitiesOfType <SkyObject>().Where(s => s.Position.X < -200)) { if (skyObject is Moon moon) { moon.Position = new Vector2(TRexGame.WINDOW_WIDTH, MOON_POS_Y); } else { _entityManager.RemoveEntity(skyObject); } } }