예제 #1
0
        protected override void LoadContent()
        {
            #region "CONSOLE"
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(".::XNA CELESTIAL MECHANICS SIMULATION::.");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("PROGRAMMED;BIIZNILLAH; BY φConst");
            Console.WriteLine();
            Console.WriteLine("CREDITS: ");
            Console.WriteLine("THE SUN EFFECT ACHIEVED WITH THE BLOOMCOMPONENT.CS AND EFFECT FILES OF http://xbox.create.msdn.com/en-US/education/catalog/sample/bloom");
            Console.WriteLine("THE FORMULAS; PLOTTERS; METHODS;");
            Console.WriteLine("USED IN THIS APPLICATION ARE LISTED IN THE REGISTER");
            Console.WriteLine("THIS APPLICATION USES A FIXED POINT METHOD!!!");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("ATTENTION: THE CALCULATED VALUES IN THIS APPLICATION ARE APPROXIMATIONS!!!");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("SPECS: " + GraphicsDevice.DisplayMode);
            System.Threading.Thread.Sleep(1000);
            //Console.Write("VSYNCH ON/OFF: ");
            //bool vsync = Console.ReadLine().ToUpper() == "ON";
            Console.Write("SIMULATOR_MODE SOLAR/TBODY: ");
            SIMULATOR_TYPE = Console.ReadLine().ToUpper() == "SOLAR" ? SIMULATOR_MODE.SIMULATOR_SOLARSYSTEM : SIMULATOR_MODE.SIMULATOR_THREE_BODY_P;
            Console.WriteLine("Listening to commands...");
            new Thread(new ThreadStart(() =>
            {
                while (!IsExit)
                {
                    Console.Write("root>");
                    string data = Console.ReadLine();
                    switch (data.ToUpper())
                    {
                    case "EXIT":
                        Exit();
                        Environment.Exit(Environment.ExitCode);
                        break;

                    case "RESTART":
                        Exit();
                        System.Windows.Forms.Application.Restart();
                        Environment.Exit(Environment.ExitCode);
                        break;
                    }
                }
            })).Start();
            #endregion
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Loading content...");
            Console.ForegroundColor = ConsoleColor.Gray;
            this.IsFixedTimeStep    = false;
            this.GraphicsDeviceManager.PreferredBackBufferWidth       = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            this.GraphicsDeviceManager.PreferredBackBufferHeight      = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            this.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = false;
            this.GraphicsDeviceManager.ApplyChanges();

            spriteBatch  = new SpriteBatch(GraphicsDevice);
            InputManager = new InputManager();
            DebugFont    = Content.Load <SpriteFont>("DebugFont");

            LineBatch.Init(GraphicsDevice);
            Observer = new Observer(this, GraphicsDevice, "Observer1");
            CelestialBody.GLOBALSCALE = 50000.0f;
            CelestialBody.DEBUGFONT   = DebugFont;
            LoadCelestialBodies();
            IsGameContinuing = true;

            InputManager.BindKey(new Key(Keys.Y, true), new KeyAction(new Action(() =>
            {
                IsGameContinuing = !IsGameContinuing;
                IsMouseVisible   = !IsMouseVisible;
                if (!IsMouseVisible)
                {
                    Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
                }
            }), new Action(() => { })));

            InputManager.BindKey(new Key(Keys.Escape, true), new KeyAction(new Action(() => { IsExit = true; Exit(); }), new Action(() => { })));
            InputManager.BindKey(new Key(Keys.F11, true), new KeyAction(new Action(() => { ShowDebug = !ShowDebug; }), new Action(() => { })));

            UI = new GUI.UI(this, new System.Drawing.Point(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - 288, 0), CelestialBodies[1]);
            UI.Show();

            SpeechRecognizer = new SpeechRecognizer(this);

            //ADD COMMANDS
            SpeechRecognizer.AddCommand("Beende", new Action(() => { SpeechRecognizer.IsRunning = false; Exit(); }));
            SpeechRecognizer.AddCommand("Vogelperspektive", new Action(() =>
            {
                Observer.Camera.SetPosition(new Vector3(Observer.Camera.CameraPosition.X, 3945000.0f, 0));
            }));


            for (int i = 0; i < CelestialBodies.Count; i++)
            {
                var Body = CelestialBodies[i];
                SpeechRecognizer.AddCommand("Markiere " + Body.Name, new Action(() =>
                {
                    Body.SetFocus();
                    UI.SetPlanet(Body);
                }));
                SpeechRecognizer.AddCommand("Folge " + Body.Name, new Action(() =>
                {
                    Body.Follow();
                }));
                SpeechRecognizer.AddCommand("Gehe zu " + Body.Name, new Action(() =>
                {
                    Observer.Camera.SetPosition(new Vector3((float)Body.XCoord, Observer.Camera.CameraPosition.Y, (float)Body.YCoord));
                    Observer.Camera.CameraPosition = new Vector3(Observer.Camera.CameraPosition.X, MathHelper.Lerp(Observer.Camera.CameraPosition.Y, 0, 0.8f), Observer.Camera.CameraPosition.Z);
                }));
            }

            SpeechRecognizer.Run();

            //NetworkAPI = new NetworkAPI(this, "p5cms.esy.es", "P5", "Input.php");
            //NetworkAPI.Start();

            Grid            = new Grid3D(GraphicsDevice);
            Grid.MaxColumn  = 50;
            Grid.MaxRows    = 50;
            Grid.StepHeight = 150000;
            Grid.StepWidth  = 150000;
            Grid.Color      = new Color(55, 55, 55);
            Grid.CreateGrid();

            MouseInteraction = new MouseInteraction();
        }