public override void DestinationUpdate() { if ((DestChangeX != Destination.X) || (DestChangeY != Destination.Y) || (DestChangeZ != Destination.Z)) { DestChangeX = Destination.X; DestChangeY = Destination.Y; DestChangeZ = Destination.Z; DestinationStr = string.Format("E: {0}, N: {1}", Math.Round(UTM_Mapping.HorizontalPixelsToMeters(Destination.X)), Math.Round(UTM_Mapping.VerticalPixelsToMeters(Destination.Y)) ); FullDestinationStr = string.Format("Destination: E: {0}, N: {1}", Math.Round(UTM_Mapping.HorizontalPixelsToMeters(Destination.X)), Math.Round(UTM_Mapping.VerticalPixelsToMeters(Destination.Y)) ); } }
public override void OnMouseMove(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: if ((Control.ModifierKeys & Keys.Alt) != 0) { LineEndLocation = e.Location; if ((Math.Abs(LineEndLocation.X - LineStartLocation.X) > 5) || (Math.Abs(LineEndLocation.Y - LineStartLocation.Y) > 5)) { DrawDistanceLine = true; this.DeselectAll(); } } break; case MouseButtons.Middle: Rectangle PlayfieldRect = _client_area; Rectangle SpriteRect = Map.ToRectangle(); int distanceX = (e.X - MouseDownLocation.X); SpriteRect.X += distanceX; int distanceY = (e.Y - MouseDownLocation.Y); SpriteRect.Y += distanceY; if (SpriteRect.Contains(PlayfieldRect)) { Pan(distanceX, distanceY); MouseDownLocation = e.Location; } break; } float xMap = UTM_Mapping.HorizontalPixelsToMeters((e.X - Map.Position.X) / Scale); float yMap = UTM_Mapping.HorizontalPixelsToMeters(Map.TextureHeight - (e.Y - Map.Position.Y) / Scale); DDD_Global.Instance.RangeFinderX = xMap; DDD_Global.Instance.RangeFinderY = yMap; DDD_Global.Instance.RangeFinderXDisplay = e.X + 10; DDD_Global.Instance.RangeFinderYDisplay = e.Y + 20; }
public override void PositionUpdate() { if ((ChangeX != Position.X) || (ChangeY != Position.Y) || (ChangeZ != Position.Z)) { ChangeX = Position.X; ChangeY = Position.Y; ChangeZ = Position.Z; PositionStr = string.Format("E: {0}, N: {1}", Math.Round(UTM_Mapping.HorizontalPixelsToMeters(Position.X)), Math.Round(UTM_Mapping.VerticalPixelsToMeters(Position.Y))); if (_callback_class != null) { _callback_class.PositionChange(this); } PositionStr = string.Format("E: {0}, N: {1}", Math.Round(UTM_Mapping.HorizontalPixelsToMeters(Position.X)), Math.Round(UTM_Mapping.VerticalPixelsToMeters(Position.Y))); } }
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); } }