Exemplo n.º 1
0
        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();
        }