public static void DrawScreen(Graphics graphics, GameSession gameSession, SortedDictionary <int, GranularObjectInformation> turnMapInformation, int turnStep, ScreenParameters screenParameters) { foreach (GranularObjectInformation turnInformation in turnMapInformation.Values) { var currentObject = turnInformation.CelestialObject; var location = GetCurrentLocation(turnMapInformation, currentObject, turnStep, screenParameters.DrawInterval); var celestialObjectType = (CelestialObjectTypes)currentObject.Classification; switch (celestialObjectType) { case CelestialObjectTypes.Asteroid: // Regular asteroid DrawTacticalMap.DrawAsteroid(currentObject, location, graphics, screenParameters); break; case CelestialObjectTypes.SpaceshipPlayer: case CelestialObjectTypes.SpaceshipNpcEnemy: case CelestialObjectTypes.SpaceshipNpcFriend: case CelestialObjectTypes.SpaceshipNpcNeutral: //if (mapSettings.IsDrawSpaceshipInformation) // DrawTacticalMap.DrawSpaceshipInformation(currentObject, location, graphics, _screenParameters); DrawTacticalMap.DrawSpaceship(currentObject, location, graphics, screenParameters); break; case CelestialObjectTypes.Missile: DrawTacticalMap.DrawMissile(currentObject, location, graphics, screenParameters); break; } if (screenParameters.Settings.IsDrawCelestialObjectDirections) { try { DrawTacticalMap.DrawCelestialObjectDirection(currentObject, location, graphics, screenParameters); } catch (Exception e) { Logger.Error(e.Message); } } if (screenParameters.Settings.IsDrawCelestialObjectCoordinates) { if (currentObject.Classification > 0) { DrawTacticalMap.DrawCelestialObjectCoordinates(currentObject, graphics, screenParameters); } } } }
private void DrawScreen() { var drawTurn = turn; var currentTurnCelestialMapData = DrawTurns[turn] as DrawMapData; if (currentTurnCelestialMapData == null) { return; } var stopwatch1 = Stopwatch.StartNew(); Image image = new Bitmap(Width, Height); var graphics = Graphics.FromImage(image); graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = InterpolationMode.Bicubic; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; if (_gameSession.SpaceMap.IsEnabled) { turnCurrentStep++; if (turnCurrentStep > turnAllSteps) { turnCurrentStep = turnAllSteps; } } DrawCenterScreenCross(graphics); DrawMouseMoveCross(graphics); DrawPointInSpaceCross(graphics); DrawTrajectory(_gameSession, graphics, _screenParameters); foreach (DrawMapDataObject dataObject in currentTurnCelestialMapData.GetData().Values) { if (drawTurn != turn) { return; } var currentObject = dataObject.GetCelestialObject(turn, turnCurrentStep); /* classification * 1 - Asteroid * 200 - Spacecraft * 3 - Drone * 4 - Missile */ switch ((CelestialObjectTypes)currentObject.Classification) { case CelestialObjectTypes.Asteroid: // Regular asteroid DrawTacticalMap.DrawAsteroid(currentObject, currentObject.GetLocation(), graphics, _screenParameters); break; case CelestialObjectTypes.SpaceshipPlayer: if (mapSettings.IsDrawSpaceshipInformation) { DrawTacticalMap.DrawSpaceshipInformation(currentObject, graphics, _screenParameters); } DrawTacticalMap.DrawSpaceship(currentObject, new PointF(currentObject.PositionX, currentObject.PositionY), graphics, _screenParameters); break; case CelestialObjectTypes.Missile: DrawTacticalMap.DrawMissile(currentObject, PointF.Empty, graphics, _screenParameters); break; } if (mapSettings.IsDrawCelestialObjectDirections) { try { DrawTacticalMap.DrawCelestialObjectDirection(currentObject, currentObject.GetLocation(), graphics, _screenParameters); } catch (Exception e) { Logger.Error(e.Message); } } if (mapSettings.IsDrawCelestialObjectCoordinates) { if (currentObject.Classification > 0) { DrawTacticalMap.DrawCelestialObjectCoordinates(currentObject, graphics, _screenParameters); } } } stopwatch1.Stop(); var workTime = stopwatch1.Elapsed.TotalMilliseconds; var logInformation = $"[WeyPoints] Turn = {_gameSession.Turn}.{turnCurrentStep} workTime = {workTime} ms"; Logger.Debug(logInformation); using (var font = new Font("Times New Roman", 10, FontStyle.Bold, GraphicsUnit.Pixel)) { graphics.DrawString(logInformation, font, new SolidBrush(Color.WhiteSmoke), new PointF(0, 0)); } BackgroundImage = image; }