/// <summary> /// Draw all of the world entities to the window /// </summary> public override void Draw() { if (IsInitialMapLoad) { InitialMapLoad(); } else if (_madeItToEnd && _loading == false) { WorldMap.BgMusic.Stop(); PrepareNextMap(); } else if (_madeItToEnd && _loading) { if (GameMaster.IsThemePlaying == false) { GameMaster.PlayTheme(); } WinInstance.Clear(GameMaster.ThemeColor); WinInstance.Draw(LoadingText); } else if (_madeItToEnd == false && _loading == false && IsInitialMapLoad == false) { if (GameMaster.IsThemePlaying) { GameMaster.StopTheme(); } if (WorldMap.BgMusic != null && WorldMap.BgMusic.Status != SoundStatus.Playing) { WorldMap.BgMusic.Play(); } _worldView.Center = WorldPlayer.Position; WinInstance.SetView(_worldView); _healthBar.SetPosition(new Vector2f((_worldView.Center.X - _worldView.Size.X / 2.0f) + 30, _worldView.Center.Y - 350)); _scoreDisp.SetPosition(new Vector2f((_worldView.Center.X + (_worldView.Size.X / 4.0f)), _worldView.Center.Y - 350)); WinInstance.Clear(WorldMap.BgColor); WinInstance.Draw(WorldMap); if (WorldMap.FloorObjects != null) { foreach (var floor in WorldMap.FloorObjects) { WinInstance.Draw(floor); } } if (EnemiesRendered != null && EnemiesRendered.Any()) { var allEneMove = false; foreach (var enemy in EnemiesRendered) { enemy.Play(); enemy.Update(); foreach (var shot in enemy.ShotsFired) { shot.Draw(); } allEneMove = enemy.CanMove; } if (allEneMove) { foreach (var enemy in EnemiesOnMap) { enemy.SetWaitToMax(); } } } else { if (EnemiesOnMap != null) { var center = _worldView.Center; var size = new Vector2f(_worldView.Size.X / 2, _worldView.Size.Y / 2); var leftX = center.X - size.X; var rightX = center.X + size.X; var topY = center.Y - size.Y; var bottomY = center.Y + size.Y; foreach (var enemy in EnemiesOnMap) { var enePos = enemy.Position; if ((enePos.Y < topY) || (enePos.Y + enemy.Height > bottomY) || (enePos.X > rightX) || (enePos.X < leftX)) { enemy.Stop(); continue; } enemy.Play(); foreach (var shot in enemy.ShotsFired) { shot.Draw(); } enemy.Update(); } } } if (_displayLives && IsInitialMapLoad == false) { DisplayLives(); _timeToDisp += GameMaster.Delta.AsSeconds(); if (_timeToDisp >= _maxTimeToDisp) { _displayLives = false; _dispControllerTime = false; _timerStarted = false; _countDownTimer.Stop(); _timeToDisp = 0.0f; } } if (_dispControllerTime && IsInitialMapLoad == false) { InitDisplayCountDownTimer(); if (_countDownText != null) { WinInstance.Draw(_countDownText); } } foreach (var item in WorldMap.ItemsOnMap) { WinInstance.Draw(item.Item); } if (_localPause == false) { WorldPlayer.Update(); } _healthBar.UpdateHealth(WorldPlayer.Health); _scoreDisp.UpdateScore(Score); _healthBar.Draw(); _scoreDisp.Draw(); foreach (var shot in WorldPlayer.ShotsFired) { shot.Draw(); } } foreach (var npc in NpCsOnMap) { npc.Update(); } }