public override void OnRender(Canvas canvas) { if (!PauseRendering) { Rectangle PlayfieldRect = canvas.TargetControl.ClientRectangle; _playfield.ClientArea = PlayfieldRect; int bottom_left = (PlayfieldRect.Y + PlayfieldRect.Height); Rectangle SpriteRect = Rectangle.Empty; if (Map != null) { SpriteRect = Map.ToRectangle(); // Prevent black from appearing on sides of map. if (!SpriteRect.Contains(PlayfieldRect)) { int right = (int)(Map.Position.X + (Map.TextureWidth * _playfield.Scale)); int bottom = (int)(Map.Position.Y + (Map.TextureHeight * _playfield.Scale)); if (right < PlayfieldRect.Width) { Pan(PlayfieldRect.Width - right, 0); } if (bottom < PlayfieldRect.Height) { Pan(0, PlayfieldRect.Height - bottom); } if (Map.Position.Y > PlayfieldRect.Y) { Pan(0, -(Map.Position.Y)); } if (Map.Position.X > PlayfieldRect.X) { Pan(-(Map.Position.X), 0); } } } switch (MapScrollState) { case MapPlayfieldScrollState.UP: Pan(0, -10); break; case MapPlayfieldScrollState.DOWN: Pan(0, 10); break; case MapPlayfieldScrollState.LEFT: Pan(-10, 0); break; case MapPlayfieldScrollState.RIGHT: Pan(10, 0); break; } _playfield.OnRender(canvas); if (WBRoom != null) { // Draw Whiteboard information from other selected rooms List<string> otherWBNames = WBRoom.GetOtherWBRoomNames(); if (otherWBNames != null) { foreach (string otherWBName in otherWBNames) { DrawWhiteboardRoomObjects(WBRoom.GetOtherWBRoom(otherWBName), canvas); } } // Draw Whiteboard information from current room DrawWhiteboardRoomObjects(WBRoom, canvas); // Draw any commands in progress if ((WBRoom.DrawMode == DrawModes.Line) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { if ((WBRoom.DrawText != null) && (WBRoom.DrawText.Length > 0)) { int lineTextSize = LineTextSize; DrawShortenedLine(canvas, WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y, 1f); if (lineTextSize > MaxFontSize) { lineTextSize = MaxFontSize; } if (lineTextSize < 1) { lineTextSize = 1; } if (wbFonts[lineTextSize] == null) { wbFonts[lineTextSize] = canvas.CreateFont(new System.Drawing.Font("Arial", lineTextSize, FontStyle.Bold, GraphicsUnit.Pixel)); } DrawCenteredText(wbFonts[lineTextSize], WBRoom.DrawText, LineEndLocation.X, LineEndLocation.Y, WBRoom.DrawColor); } else { canvas.DrawLine(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y); } } else if ((WBRoom.DrawMode == DrawModes.Circle) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { canvas.DrawCircle(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y); } else if ((WBRoom.DrawMode == DrawModes.Arrow) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { canvas.DrawArrow(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y); } else if ((WBRoom.DrawMode == DrawModes.Text) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { if ((WBRoom.DrawText != null) && (WBRoom.DrawText.Length > 0)) { int drawPointSize = WBRoom.DrawPointSize + 7; if (drawPointSize > MaxFontSize) { drawPointSize = MaxFontSize; } if (wbFonts[drawPointSize] == null) { wbFonts[drawPointSize] = canvas.CreateFont(new System.Drawing.Font("Arial", drawPointSize, FontStyle.Bold, GraphicsUnit.Pixel)); } DrawCenteredText(wbFonts[drawPointSize], WBRoom.DrawText, LineEndLocation.X, LineEndLocation.Y, WBRoom.DrawColor); } } else if ((WBRoom.DrawMode == DrawModes.Selection) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { RectangleF selectionRect; int selectionX = Math.Min(LineStartLocation.X, LineEndLocation.X); int selectionY = Math.Min(LineStartLocation.Y, LineEndLocation.Y); selectionRect = new RectangleF((float)selectionX, (float)selectionY, (float)Math.Abs(LineStartLocation.X - LineEndLocation.X), (float)Math.Abs(LineStartLocation.Y - LineEndLocation.Y)); canvas.DrawRect(selectionRect, Color.Orange); } } // Draw Mini map _bottom_status_bar.Height = 35; _bottom_status_bar.Width = PlayfieldRect.Width; _bottom_status_bar.X = PlayfieldRect.X; _bottom_status_bar.Y = bottom_left - _bottom_status_bar.Height; canvas.DrawFillRect(_bottom_status_bar, _mini_map_background); if (true) //check DDD_Global or playfield { if (_rangeFinderFont == null && this.Fonts.ContainsKey("RangeRing")) { _rangeFinderFont = this.Fonts["RangeRing"]; } string rangeText = DDD_Global.Instance.GetRangeFinderDisplayString(); if (_rangeFinderFont != null && rangeText.Trim() != string.Empty) { _mouseoverRangeFinderDisplay = _rangeFinderFont.MeasureString(null, rangeText, DrawTextFormat.Center, Color.White); _mouseoverRangeFinderDisplay.X = Convert.ToInt32(DDD_Global.Instance.RangeFinderXDisplay);// 500; _mouseoverRangeFinderDisplay.Y = Convert.ToInt32(DDD_Global.Instance.RangeFinderYDisplay);// 400; _mouseoverRangeFinderDisplay.Width += 10; canvas.DrawFillRect(_mouseoverRangeFinderDisplay, _mini_map_background);//_rangeFinderMaterial); _rangeFinderFont.DrawText(null, rangeText, _mouseoverRangeFinderDisplay, DrawTextFormat.Center, Color.White); //DRAW LINE FROM OBJECT TO CURSOR float objX = 0f; float objY = 0f; DDDObjects obj = _playfield.GetSelectedObject(); if (obj != null) { objX = obj.ScreenCoordinates.X; objY = obj.ScreenCoordinates.Y; canvas.DrawLine(Color.Black, 3, _mouseoverRangeFinderDisplay.X - 10, _mouseoverRangeFinderDisplay.Y - 15, objX, objY); } } } if (!MiniMapOverride) { if ((!Map_IsContained_Horizontal(PlayfieldRect)) && (!Map_IsContained_Vertical(PlayfieldRect))) { ShowMiniMap = false; } else { ShowMiniMap = true; } if (WBRoom != null) { ShowMiniMap = true; } if (ShowMiniMap) { _mini_map.X = (PlayfieldRect.X + PlayfieldRect.Width) - _mini_map.Width; _mini_map.Y = 0; _mini_map.Height = (int)((Map.TextureHeight / Map.TextureWidth) * (float)_mini_map.Width); _mini_map_thumb.X = (int)(-(Map.Position.X / (Map.TextureWidth * _playfield.Scale)) * (float)_mini_map.Width) + _mini_map.X; _mini_map_thumb.Y = (int)(-(Map.Position.Y / (Map.TextureHeight * _playfield.Scale)) * (float)_mini_map.Height) + _mini_map.Y; _mini_map_thumb.Width = (int)(_mini_map.Width * ((float)PlayfieldRect.Width / (Map.TextureWidth * _playfield.Scale))); _mini_map_thumb.Height = (int)(_mini_map.Height * ((float)PlayfieldRect.Height / (Map.TextureHeight * _playfield.Scale))); canvas.DrawFillRect(_mini_map, _mini_map_background); // Draw rect for other users in a whiteboard room if (wbRoom != null) { int originX = 0; int originY = 0; int screenSizeWidth = 0; int screenSizeHeight = 0; double screenZoom = 0.0; foreach (string wbUser in wbRoom.MembershipList) { if (string.Compare(wbUser, DDD_Global.Instance.PlayerID) == 0) { continue; } if (wbRoom.GetScreenViewInfo(wbUser, ref originX, ref originY, ref screenSizeWidth, ref screenSizeHeight, ref screenZoom)) { Rectangle userMiniMapRect = Rectangle.Empty; Vector2 _metersPerPixelValues = new Vector2(); Vector2 userPosition = new Vector2(); _metersPerPixelValues.X = UTM_Mapping.HorizonalMetersPerPixel; _metersPerPixelValues.Y = UTM_Mapping.VerticalMetersPerPixel; userPosition.X = (float) originX / _metersPerPixelValues.X; userPosition.Y = (float)originY / _metersPerPixelValues.Y; userMiniMapRect.X = (int)((userPosition.X / (Map.TextureWidth)) * (float)_mini_map.Width) + _mini_map.X; userMiniMapRect.Y = (int)((userPosition.Y / (Map.TextureHeight)) * (float)_mini_map.Height) + _mini_map.Y; userMiniMapRect.Width = (int)((float)screenSizeWidth / _metersPerPixelValues.X / Map.TextureWidth * (float)_mini_map.Width); userMiniMapRect.Height = (int)((float)screenSizeHeight / _metersPerPixelValues.Y / Map.TextureHeight * (float)_mini_map.Height); // Draw rect for this a whiteboard user if (DMColorMap.ContainsKey(wbUser)) { canvas.DrawRect(userMiniMapRect, Color.FromArgb(DMColorMap[wbUser])); } else { canvas.DrawRect(userMiniMapRect, Color.DarkBlue); } } } } // Draw rect for this user if ((wbRoom != null) && DMColorMap.ContainsKey(DDD_Global.Instance.PlayerID)) { canvas.DrawRect(_mini_map_thumb, Color.FromArgb(DMColorMap[DDD_Global.Instance.PlayerID])); } else { canvas.DrawRect(_mini_map_thumb, Color.Red); } lock (this) { DDDObjects selected = GetSelectedObject(); foreach (string obj_name in _playfield.PlayfieldObjects) { DDDObjects obj = (DDDObjects)_playfield.GetMappableObject(obj_name); if (obj != null) { _mini_map_track.X = (int)(((_mini_map.Width / Map.TextureWidth) * obj.Position.X) + _mini_map.X) - (int)(.5 * _mini_map_track.Width); _mini_map_track.Y = (int)(((_mini_map.Height / Map.TextureHeight) * obj.Position.Y) + _mini_map.Y) - (int)(.5 * _mini_map_track.Height); if (selected != null) { if ((selected.ID == obj.ID) && !ShowUnitColorOnMiniMap) { canvas.DrawTri(_mini_map_track, Color.Yellow, DIRECTION.UP); continue; } } if (!ShowUnitColorOnMiniMap) { canvas.DrawTri(_mini_map_track, Color.DodgerBlue, DIRECTION.UP); } else { canvas.DrawTri(_mini_map_track, obj.TextBoxColor, DIRECTION.UP); } } } foreach (string obj_name in _playfield.PlayfieldObjects) { DDDObjects obj = (DDDObjects)_playfield.GetMappableObject(obj_name); if (obj != null) { _mini_map_track.X = (int)(((_mini_map.Width / Map.TextureWidth) * obj.Position.X) + _mini_map.X) - (int)(.5 * _mini_map_track.Width); _mini_map_track.Y = (int)(((_mini_map.Height / Map.TextureHeight) * obj.Position.Y) + _mini_map.Y) - (int)(.5 * _mini_map_track.Height); if (obj.IsBeingAttacked) { if (GameFramework.ElapsedSeconds(AnimationTimer, AnimationCycle)) { AnimationTimer = GameFramework.QueryPerformanceTimer(); } if (GameFramework.ElapsedSeconds(AnimationTimer, BlinkCycle)) { canvas.DrawTri(_mini_map_track, Color.White, DIRECTION.UP); continue; } } } } } } } if (ShowPosition) { DDDObjects obj = _playfield.GetSelectedObject(); if (obj != null) { if (obj.IsPathCalculatorRunning()) { canvas.DrawFillRect(_bottom_status_bar, _mini_map_background); SizeF size = obj.DrawIcon(canvas, PlayfieldRect.X, _bottom_status_bar.Y, 30, 30); int font_height = (Fonts["Arial8B"].MeasureString(null, obj.FullVelocityStr, DrawTextFormat.None, Color.White)).Height; Fonts["Arial8B"].DrawText(null, obj.FullVelocityStr, PlayfieldRect.X + (int)size.Width + 2, _bottom_status_bar.Y, Color.White); Fonts["Arial8B"].DrawText(null, obj.FullTTDStr, PlayfieldRect.X + (int)size.Width + 2, (_bottom_status_bar.Y + font_height), Color.White); Fonts["Arial8B"].DrawText(null, obj.FullDestinationStr, PlayfieldRect.X + (int)size.Width + 2, (_bottom_status_bar.Y + (2 * font_height)), Color.White); } else { SizeF size = obj.DrawIcon(canvas, PlayfieldRect.X, _bottom_status_bar.Y, 30, 30); int font_height = (Fonts["Arial10B"].MeasureString(null, obj.ObjectID, DrawTextFormat.None, Color.White)).Height; Fonts["Arial10B"].DrawText(null, obj.ObjectID, PlayfieldRect.X + (int)size.Width, (_bottom_status_bar.Bottom - font_height), Color.White); } } } int width; String str = String.Empty; if (!IsPaused) { if (DDD_Global.Instance.IsForkReplay) { str = String.Format("Fork Replay {0}", Time); } else { str = Time; } } else { str = "Paused"; } width = (Fonts["Arial10B"].MeasureString(null, str, DrawTextFormat.None, Color.Yellow)).Width + 5; Fonts["Arial10B"].DrawText(null, str, _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow); //if (!IsPaused) //{ // if (DDD_Global.Instance.IsForkReplay) // { // width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5; // Fonts["Arial10B"].DrawText(null, String.Format("Fork Replay {0}",Time), _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow); // } // else // { // width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5; // Fonts["Arial10B"].DrawText(null, Time, _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow); // } //} //else //{ // width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5; // Fonts["Arial10B"].DrawText(null, "Paused", _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow); //} } }
public void DrawWhiteboardRoomObjects(WhiteboardRoom wbRoom, Canvas canvas) { if (wbRoom == null) { return; } // Draw all whiteboard commands Array drawingCommands = wbRoom.GetCurrentDrawingCommands(); foreach (object obj in drawingCommands) { if (obj is LineObject) { LineObject line = (LineObject)obj; LocationValue start = new LocationValue(); LocationValue end = new LocationValue(); int drawPointSize = (int)(line.Width * _playfield.Scale); if ((drawPointSize == 0) && (line.Width > 0)) { drawPointSize = 1; } if ((line.Mode == DrawModes.Line) || (line.Mode == DrawModes.Circle) || (line.Mode == DrawModes.Arrow)) { start.X = line.Start.X * _playfield.Scale + Map.Position.X; start.Y = line.Start.Y * _playfield.Scale + Map.Position.Y; end.X = line.End.X * _playfield.Scale + Map.Position.X; end.Y = line.End.Y * _playfield.Scale + Map.Position.Y; if (line.Mode == DrawModes.Line) { if ((line.Text != null) && (line.Text.Length > 0)) { int lineTextSize = (int) ((LineTextSize / line.OriginalScale) * _playfield.Scale); DrawShortenedLine(canvas, line.Color, drawPointSize, (float)start.X, (float)start.Y, (float)end.X, (float)end.Y, (float) (_playfield.Scale / line.OriginalScale)); if (lineTextSize > MaxFontSize) { lineTextSize = MaxFontSize; } if (lineTextSize < 1) { lineTextSize = 1; } if (wbFonts[lineTextSize] == null) { wbFonts[lineTextSize] = canvas.CreateFont(new System.Drawing.Font("Arial", lineTextSize, FontStyle.Bold, GraphicsUnit.Pixel)); } DrawCenteredText(wbFonts[lineTextSize], line.Text, (int)end.X, (int)end.Y, line.Color); } else { canvas.DrawLine(line.Color, drawPointSize, (float)start.X, (float)start.Y, (float)end.X, (float)end.Y); } } else if (line.Mode == DrawModes.Circle) { canvas.DrawCircle(line.Color, drawPointSize, (float)start.X, (float)start.Y, (float)end.X, (float)end.Y); } else if (line.Mode == DrawModes.Arrow) { canvas.DrawArrow(line.Color, drawPointSize, (float)start.X, (float)start.Y, (float)end.X, (float)end.Y); } } else if ((line.Mode == DrawModes.Text) && (line.Text != null) && (line.Text.Length > 0)) { start.X = line.Start.X * _playfield.Scale + Map.Position.X; start.Y = line.Start.Y * _playfield.Scale + Map.Position.Y; if (drawPointSize > MaxFontSize) { drawPointSize = MaxFontSize; } if (wbFonts[drawPointSize] == null) { wbFonts[drawPointSize] = canvas.CreateFont(new System.Drawing.Font("Arial", drawPointSize, FontStyle.Bold, GraphicsUnit.Pixel)); } DrawCenteredText(wbFonts[drawPointSize], line.Text, (int)start.X, (int)start.Y, line.Color); // Update the bounding box if needed if ((line.BoundingPolygon == null) || (wbRoom == WBRoom)) { RectangleF textRect; Polygon textPoly; float width; float height; PointF boundStart = new PointF(); textRect = wbFonts[drawPointSize].MeasureString(null, line.Text, DrawTextFormat.None, line.Color); width = textRect.Right / _playfield.Scale; if ((width * line.OriginalScale) < 5) { width = 5 / (float) line.OriginalScale; } height = textRect.Bottom / _playfield.Scale; if ((height * line.OriginalScale) < 5) { height = 5 / (float) line.OriginalScale; } boundStart.X = (float)line.Start.X - (width / 2); boundStart.Y = (float)line.Start.Y - (height / 2); textPoly = new Polygon(); textPoly.Points.Add(new Vector(boundStart.X, boundStart.Y)); textPoly.Points.Add(new Vector(boundStart.X + width, boundStart.Y)); textPoly.Points.Add(new Vector(boundStart.X + width, boundStart.Y + height)); textPoly.Points.Add(new Vector(boundStart.X, boundStart.Y + height)); textPoly.Offset(0, 0); textPoly.BuildEdges(); line.BoundingPolygon = textPoly; } } // Draw Bounding rectable if object is selected if ((line.ObjectSelected) && (line.BoundingPolygon != null) && (line.BoundingPolygon.Points.Count >= 2)) { LocationValue boundStart = new LocationValue(); LocationValue boundEnd = new LocationValue(); Vector prevPoint = line.BoundingPolygon.Points[line.BoundingPolygon.Points.Count - 1]; foreach (Vector curPoint in line.BoundingPolygon.Points) { boundStart.X = prevPoint.X * _playfield.Scale + Map.Position.X; boundStart.Y = prevPoint.Y * _playfield.Scale + Map.Position.Y; boundEnd.X = curPoint.X * _playfield.Scale + Map.Position.X; boundEnd.Y = curPoint.Y * _playfield.Scale + Map.Position.Y; canvas.DrawLine(Color.Black.ToArgb(), 1, (float)boundStart.X, (float)boundStart.Y, (float)boundEnd.X, (float)boundEnd.Y); prevPoint = curPoint; } } } } }
public void DrawShortenedLine(Canvas canvas, int color, int pointSize, float x1, float y1, float x2, float y2, float scale) { float lineLength = (float) Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)); int shortenLineBy = (int) (ShortenLineBy * scale); if (lineLength < shortenLineBy) { canvas.DrawLine(color, pointSize, x1, y1, x2, y2); } else { float angle = (float) Math.Atan2(y2 - y1, x2 - x1); float newEndX = x1 + (lineLength - shortenLineBy) * (float)Math.Cos(angle); float newEndY = y1 + (lineLength - shortenLineBy) * (float)Math.Sin(angle); canvas.DrawLine(color, pointSize, x1, y1, newEndX, newEndY); } }
public void DrawHeading(Canvas canvas) { if (IsPathCalculatorRunning()) { Vector2 destination = ToScreenCoordinates(_destination.X, _destination.Y); float center_x = _overlay_rect.X + (_overlay_rect.Width / 2); float center_y = _overlay_rect.Y + (_overlay_rect.Height / 2); canvas.DrawLine(HeadingColor, 1, center_x, center_y, destination.X, destination.Y); _destination_area.X = destination.X - 3; _destination_area.Y = destination.Y - 3; _destination_area.Height = 6; _destination_area.Width = 6; canvas.DrawFillRect(this._destination_area, _heading_color_material); } }
public override void OnRender(Canvas canvas) { if (Map != null) { Map.Draw(canvas); } DrawActiveZones(canvas); DDDObjects.Scale = Scale; if (!ScaleUnitWithMap) { DDDObjects.MinScale = 1; } else { DDDObjects.MinScale = .5f; } DDDObjects.MapPosition(Map.Position.X, Map.Position.Y); lock (this) { DDDObjects selected_target = GetSelectedTarget(); DDDObjects selected_asset = GetSelectedObject(); //draw range rings foreach (string obj_name in OrderedPlayfieldObjects) { DDDObjects obj = (DDDObjects)GetMappableObject(obj_name); if (obj != null) { obj.DrawRangeRings(canvas); } } foreach (string obj_name in OrderedPlayfieldObjects) { DDDObjects obj = (DDDObjects)GetMappableObject(obj_name); if (obj != null) { if (obj == selected_asset) { //display mouseover info float xpos = UTM_Mapping.HorizontalPixelsToMeters((obj.ScreenCoordinates.X - Map.Position.X) / Scale); float ypos = UTM_Mapping.VerticalPixelsToMeters((obj.ScreenCoordinates.Y - Map.Position.Y ) / Scale); //float xpos = UTM_Mapping.HorizontalPixelsToMeters((obj.ScreenCoordinates.X + (obj.SpriteArea.Width / 2)) - Map.Position.X); //float ypos = UTM_Mapping.VerticalPixelsToMeters((obj.ScreenCoordinates.Y + (obj.SpriteArea.Height / 2) - (Scale * 50)) - Map.Position.Y); //Console.WriteLine("x: {0}; y: {1}", xpos, ypos); // Console.WriteLine("x: {0}; y: {1}", xpos, ypos + (obj.SpriteArea.Height / 2) / Scale); DDD_Global.Instance.SetRangeFinderDistance(xpos, ypos); //get distance string string distanceFromSelected = DDD_Global.Instance.RangeFinderDistanceString; int distance = -1; int intensity = -1; if (distanceFromSelected.Trim() != "") { distance = (int)Math.Round(Convert.ToDouble(distanceFromSelected)); intensity = obj.GetCapabilityRangeRingIntensity(obj.CurrentlySelectedCapability, true, distance); if (intensity > 0) { DDD_Global.Instance.RangeFinderIntensityString = String.Format("{0}", intensity); } else { DDD_Global.Instance.RangeFinderIntensityString = string.Empty; } } //check if a capability is selected, if so get ranges, and then use disance to calculate intensity. } // obj.DrawRangeRings(canvas); //moved above obj.DrawUnmanagedAssetLabel = DrawUnmanagedAssetLabels; obj.SetDiffuseColor(); if (obj.IsPathCalculatorRunning()) { if (!obj.IsWeapon) { obj.HeadingColor = Color.DodgerBlue; } else { obj.HeadingColor = Color.Red; } obj.DrawHeading(canvas); } if ((obj != selected_asset) && (obj != selected_target)) { obj.TextColor = Color.White; obj.BorderColor = Color.Black; obj.Draw(canvas, Fonts["Small"]); obj.DrawSpecial(canvas, Fonts["Small"]); } } } //Render selected objects last. if (selected_target != null) { //selected_asset.DiffuseColor = Color.Yellow; selected_target.TextColor = Color.Yellow; selected_target.BorderColor = Color.Yellow; selected_target.Draw(canvas, Fonts["Small"]); selected_target.DrawSpecial(canvas, Fonts["Small"]); } if (selected_asset != null) { //selected_asset.DiffuseColor = Color.Yellow; selected_asset.TextColor = Color.Yellow; selected_asset.BorderColor = Color.Yellow; selected_asset.Draw(canvas, Fonts["Small"]); selected_asset.DrawSpecial(canvas, Fonts["Small"]); } } if (DrawDistanceLine) { canvas.DrawLine(Color.Lime, 1, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y); double distance = Math.Sqrt(Math.Pow((LineEndLocation.X - LineStartLocation.X), 2) + Math.Pow((LineEndLocation.Y - LineStartLocation.Y), 2)); Fonts["Small"].DrawText(null, string.Format("{0} m", Math.Round(UTM_Mapping.HorizontalPixelsToMeters((float)(distance/Scale)))), LineEndLocation.X+12, LineEndLocation.Y - 12, Color.Lime); } }
public override void DrawSpecial(Microsoft.DirectX.Direct3D.Font font, RectangleF overlay_rect, Rectangle text_rect, Canvas canvas) { _overlay_rect = overlay_rect; _text_rect = text_rect; _progressbar_rect = text_rect; _border_rect = text_rect; if ((OwnerID == DDD_Global.Instance.PlayerID) && (DrawProgressBar)) { _progressbar_rect.Y += text_rect.Height; _progressbar_rect.Height = _ProgressBarHeight_; _progressbar_rect.Width = _ProgressBarWidth_; _progressbar_rect.X += ((text_rect.Width - _progressbar_rect.Width) / 2); _border_rect.Height = _ProgressBarHeight_ + _text_rect.Height + 2; canvas.DrawFillRect(_border_rect, _textbox_color_material); DrawObjectID(canvas, font); canvas.DrawRect(_border_rect, BorderColor); if (FuelCapacity > 0) { canvas.DrawProgressBar(_progressbar_rect, progress_bar_background_material, progress_bar_foreground_material, FuelAmount / FuelCapacity); } else { canvas.DrawProgressBar(_progressbar_rect, progress_bar_background_material, progress_bar_foreground_material, 0); } } else { if (DrawUnmanagedAssetLabel) { DrawObjectID(canvas, font); canvas.DrawRect(_border_rect, BorderColor); } } foreach (DDDObjects attacker in Attackers) { float _destinationX = attacker.SpriteArea.X + (attacker.SpriteArea.Width / 2); float _destinationY = attacker.SpriteArea.Y + (attacker.SpriteArea.Height / 2); canvas.DrawLine(Color.Red, 1, SpriteArea.X + (SpriteArea.Width / 2), SpriteArea.Y + (SpriteArea.Height / 2), _destinationX, _destinationY ); //engagment_rect.X = (int)(_destinationX - 3); //engagment_rect.Y = (int)(_destinationY - 3); //engagment_rect.Height = 6; //engagment_rect.Width = 6; //canvas.DrawFillRect(engagment_rect, red_material); } if (IsBeingAttacked) { engagment_rect = font.MeasureString(null, _engagementTimeStr, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.Red); engagment_rect.Width += 10; engagment_rect.X = (int)(_overlay_rect.X + (_overlay_rect.Width - engagment_rect.Width) / 2); engagment_rect.Y = (int)(_overlay_rect.Y + (_overlay_rect.Height - engagment_rect.Height) / 2); canvas.DrawFillRect(engagment_rect, black_material); canvas.DrawRect(engagment_rect, Color.Red); font.DrawText(null, _engagementTimeStr, engagment_rect, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.Red); } // Draw object "Tags" if (Tag != string.Empty && (DDD_Global.Instance.TagPosition != TagPositionEnum.INVISIBLE)) { Rectangle tag_rect = font.MeasureString(null, Tag, DrawTextFormat.Center, Color.Black); switch (DDD_Global.Instance.TagPosition) { case TagPositionEnum.ABOVE: tag_rect.Y = (int)(overlay_rect.Y - tag_rect.Height); tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f)); break; case TagPositionEnum.BELOW: if (!DrawUnmanagedAssetLabel && (OwnerID != DDD_Global.Instance.PlayerID)) { tag_rect.Y = (int)(overlay_rect.Bottom + 1); tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f)); } else { tag_rect.Y = (int)(_border_rect.Bottom + 2); tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f)); } break; case TagPositionEnum.CENTER: //tag_rect.Y = (int)(overlay_rect.Y + ((overlay_rect.Height - tag_rect.Height) * .5f)); tag_rect.Y = (int)(overlay_rect.Bottom - tag_rect.Height - 2); tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f)); break; } canvas.DrawFillRect(tag_rect, tag_material); font.DrawText(null, Tag, tag_rect, DrawTextFormat.VerticalCenter | DrawTextFormat.Center, Color.Black); } }