/// <summary> /// Draw the inital map load decal /// </summary> public void InitialMapLoad() { if (GameMaster.IsThemePlaying == false) { GameMaster.PlayTheme(); } var currentCenter = _worldView.Center; if (Math.Abs(WorldMap.EndOfMap.X - currentCenter.X) <= _worldView.Size.X / 2.0f) { IsInitialMapLoad = false; GameMaster.StopTheme(); return; } if (WinInstance == null) { return; } InitLoadText.Position = new Vector2f(currentCenter.X, WinInstance.Size.Y / 2f); _worldView.Move(new Vector2f(150 * GameMaster.Delta.AsSeconds(), 0.0f)); WinInstance.SetView(_worldView); WinInstance.Clear(WorldMap.BgColor); WinInstance.Draw(WorldMap); if (WorldMap.FloorObjects != null) { foreach (var floor in WorldMap.FloorObjects) { WinInstance.Draw(floor); } } WinInstance.Draw(InitLoadText); }
/// <summary> /// Draw menu items and pointer to the window /// </summary> public override void Draw() { WinInstance.Clear(GameMaster.ThemeColor); WinInstance.SetView(WinInstance.DefaultView); base.Draw(); Pointer.Draw(); }
/// <summary> /// Prepare the next mapl for loading to the world /// </summary> private void PrepareNextMap() { CurrentMap++; WorldPlayer.RemoveControls(); _loading = true; if (LoadingText == null) { var font = AssetManager.LoadFont("OrangeJuice"); LoadingText = new Text() { Position = WinInstance.DefaultView.Center, DisplayedString = AssetManager.GetMessage("Loading"), CharacterSize = 60, Color = Color.Black, Font = font }; } WinInstance.SetView(WinInstance.DefaultView); var ts = new ThreadStart(LoadNewMap); _loadingThread = new Thread(ts) { Priority = ThreadPriority.Highest, IsBackground = true }; _loadingThread.Start(); }
/// <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(); } }