internal bool UpdateLocation() { if (Points.Count == 0) { return(false); } if (CurrentIndex == Points.Count) { return(false); } var dist = Math2.GetDistance(Points[CurrentIndex], Timeline.CurrentLocation); double dist_max = 50; if (CurrentIndex > 0 && CurrentIndex + 1 < Points.Count - 1) { var nextLine = Math2.GetPolarHeadingFromLine(Points[CurrentIndex], Points[CurrentIndex + 1]); var angle_delta = Math.Abs(Math2.DiffAngles(Math2.GetPolarHeadingFromLine(TargetLine), nextLine)); dist_max += angle_delta * 2.5; } if (dist < dist_max) { CurrentIndex++; Trace.WriteLine($"Flight Plan: Advance: {CurrentIndex}"); App.Current.Dispatcher.BeginInvoke((Action)(() => { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentIndex))); })); } return(dist < dist_max); }
private void AddPosition(Point pt) { double heading = double.NaN; if (lastPoint != default(Point)) { var l = new Line { X1 = pt.X, Y1 = pt.Y, X2 = lastPoint.X, Y2 = lastPoint.Y }; l.Stroke = Brushes.Magenta; l.StrokeThickness = 0.4; canvas.Children.Insert(canvas.Children.Count - 1, l); heading = Math2.GetPolarHeadingFromLine(pt.ToPointF(), lastPoint.ToPointF()); } Ellipse dot = new Ellipse(); dot.Fill = Brushes.Gray; dot.Height = dot.Width = 1; Canvas.SetTop(dot, pt.Y - dot.Height / 2); Canvas.SetLeft(dot, pt.X - dot.Width / 2); canvas.Children.Add(dot); lastPoint = pt; }
private void AddPosition(Point pt, bool save = true) { double heading = double.NaN; if (lastPoint != default(Point)) { var l = new Line { X1 = pt.X, Y1 = pt.Y, X2 = lastPoint.X, Y2 = lastPoint.Y }; l.Stroke = Brushes.Blue; l.StrokeThickness = 1; canvas.Children.Insert(canvas.Children.Count - 1, l); heading = Math2.GetPolarHeadingFromLine(pt.ToPointF(), lastPoint.ToPointF()); } Ellipse dot = new Ellipse(); dot.Fill = Brushes.Red; dot.Height = dot.Width = 2; Canvas.SetTop(dot, pt.Y - dot.Height / 2); Canvas.SetLeft(dot, pt.X - dot.Width / 2); canvas.Children.Add(dot); lastPoint = pt; if (save) { Positions.Add(new Position { pt = pt }); Points.Add(new System.Drawing.PointF((float)pt.X * Metrics.SCALE_Map4_20_TO_100, (float)pt.Y * Metrics.SCALE_Map4_20_TO_100)); } }
public static void ResetGameFromSavePointByMenu() { IsInGame = false; new Thread(() => { SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.START, 10); SystemManager.Instance.App.Controller.Flush(); while (!SystemManager.Instance.IndicatorHost.Menu.IsInMenu) { Thread.Sleep(100); } Thread.Sleep(800); SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.A, 10); SystemManager.Instance.App.Controller.Flush(); Thread.Sleep(1200); var location = SystemManager.Instance.IndicatorHost.Menu.Location; while (location == default(PointF)) { // Trace.WriteLine("wait for location"); Thread.Sleep(400); location = SystemManager.Instance.IndicatorHost.Menu.Location; } SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.B, 10); SystemManager.Instance.App.Controller.Flush(); Thread.Sleep(900); var line = new LineSegment2DF(Timeline.CurrentLocation, location); Trace.WriteLine($"MOVE: {Math.Round(line.Length)} {Math.Round(Math2.GetPolarHeadingFromLine(line))}"); Trace.WriteLine($"Location: {location}"); // Trace.WriteLine("now in menu!"); while (!SystemManager.Instance.IndicatorHost.Menu.SelectedMenuItem.Contains("GAME")) { // Trace.WriteLine("SELECTED: " + SystemManager.Instance.IndicatorHost.Menu.SelectedMenuItem); SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.DPAD_LEFT, 10); SystemManager.Instance.App.Controller.Flush(); Thread.Sleep(500); } // Trace.WriteLine("now in game!"); Thread.Sleep(200); SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.A, 10); SystemManager.Instance.App.Controller.Flush(); // Trace.WriteLine("now game menu list"); while (SystemManager.Instance.IndicatorHost.Menu.SelectedGameMenuItem != "LOADGAME") { // Trace.WriteLine("SELECTED: " + SystemManager.Instance.IndicatorHost.Menu.SelectedGameMenuItem); SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.DPAD_DOWN, 10); SystemManager.Instance.App.Controller.Flush(); Thread.Sleep(500); } // Trace.WriteLine("now save list"); SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.A, 10); SystemManager.Instance.App.Controller.Flush(); Thread.Sleep(800); SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.A, 10); SystemManager.Instance.App.Controller.Flush(); Thread.Sleep(800); SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.A, 10); SystemManager.Instance.App.Controller.Flush(); Thread.Sleep(800); SystemManager.Instance.App.Controller.Press(Interop.XINPUT_GAMEPAD_BUTTONS.A, 10); SystemManager.Instance.App.Controller.Flush(); // Trace.WriteLine("now game should be loading"); while (!SystemManager.Instance.IndicatorHost.Loading.IsLoading) { // Trace.WriteLine("wait for loading " + SystemManager.Instance.IndicatorHost.Loading.LoadingTextRead); Thread.Sleep(1000); } // Trace.WriteLine("confirm loading!"); while (SystemManager.Instance.IndicatorHost.Loading.IsLoading) { // Trace.WriteLine("wait for no loading " + SystemManager.Instance.IndicatorHost.Loading.LoadingTextRead); Thread.Sleep(1000); } SystemManager.Instance.FlightPlan.CurrentIndex = 0; Reset(); Trace.WriteLine("GAME READY!"); Timeline.Begin(); Thread.Sleep(2000); SystemManager.Instance.MCP.IAS = 120; SystemManager.Instance.MCP.ALT = 1200; SystemManager.Instance.MCP.AltitudeHold = true; SystemManager.Instance.MCP.LNAV = true; SystemManager.Instance.MCP.IASHold = true; }).Start(); }