public override void HandleInput(InputState input)
 {
     if (input.InGameSelect)
     {
         Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport;
         Vector3 nearPoint = viewport.Unproject(new Vector3(input.CursorPosition, 0f), this.projection, this.view, Matrix.Identity);
         Viewport viewport1 = base.ScreenManager.GraphicsDevice.Viewport;
         Vector3 farPoint = viewport1.Unproject(new Vector3(input.CursorPosition, 1f), this.projection, this.view, Matrix.Identity);
         Vector3 direction = farPoint - nearPoint;
         direction.Normalize();
         Ray pickRay = new Ray(nearPoint, direction);
         float k = -pickRay.Position.Z / pickRay.Direction.Z;
         Vector3 pickedPosition = new Vector3(pickRay.Position.X + k * pickRay.Direction.X, pickRay.Position.Y + k * pickRay.Direction.Y, 0f);
         if (Vector3.Distance(pickedPosition, this.planetSO.WorldBoundingSphere.Center) < this.planetSO.WorldBoundingSphere.Radius)
         {
             AudioManager.PlayCue("sd_bomb_impact_01");
             Vector3 VectorToCenter = pickedPosition - this.planetSO.WorldBoundingSphere.Center;
             VectorToCenter = Vector3.Normalize(VectorToCenter);
             VectorToCenter = this.planetSO.WorldBoundingSphere.Center + (VectorToCenter * this.planetSO.WorldBoundingSphere.Radius);
         }
     }
     this.currentMouse = input.CurrentMouseState;
     Vector2 MousePos = new Vector2((float)this.currentMouse.X, (float)this.currentMouse.Y);
     bool okcomet = true;
     foreach (UIButton b in this.Buttons)
     {
         if (!HelperFunctions.CheckIntersection(b.Rect, MousePos))
         {
             b.State = UIButton.PressState.Normal;
         }
         else
         {
             okcomet = false;
             if (b.State != UIButton.PressState.Hover && b.State != UIButton.PressState.Pressed)
             {
                 AudioManager.PlayCue("mouse_over4");
             }
             b.State = UIButton.PressState.Hover;
             if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Pressed)
             {
                 b.State = UIButton.PressState.Pressed;
             }
             if (this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
             {
                 continue;
             }
             string launches = b.Launches;
             string str = launches;
             if (launches == null)
             {
                 continue;
             }
             if (str == "New Campaign")
             {
                 AudioManager.PlayCue("sd_ui_tactical_pause");
                 this.OnPlayGame();
             }
             else if (str == "Tutorials")
             {
                 AudioManager.PlayCue("sd_ui_tactical_pause");
                 base.ScreenManager.AddScreen(new TutorialScreen());
             }
             else if (str == "Load Game")
             {
                 AudioManager.PlayCue("sd_ui_tactical_pause");
                 base.ScreenManager.AddScreen(new LoadSaveScreen(this));
             }
             else if (str == "Options")
             {
                 OptionsScreen opt = new OptionsScreen(this, new Rectangle(0, 0, 600, 600))
                 {
                     TitleText = Localizer.Token(4),
                     MiddleText = Localizer.Token(4004)
                 };
                 base.ScreenManager.AddScreen(opt);
             }
             else if (str == "Mods")
             {
                 ModManager mm = new ModManager(this);
                 base.ScreenManager.AddScreen(mm);
             }
             else if (str == "Exit")
             {
                 Game1.Instance.Exit();
             }
         }
     }
     if (input.C && input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift))
     {
         base.ScreenManager.AddScreen(new ShipToolScreen());
         this.ExitScreen();
     }
     if (okcomet && input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
     {
         MainMenuScreen.Comet c = new MainMenuScreen.Comet();
         //{
         c.Position = new Vector2(RandomMath.RandomBetween(-100f, (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth + 100)), 0f);
             c.Velocity = HelperFunctions.FindVectorToTarget(c.Position, input.CursorPosition);
         //};
         c.Velocity = Vector2.Normalize(c.Velocity);
         c.Rotation = (float)MathHelper.ToRadians(HelperFunctions.findAngleToTarget(c.Position, c.Position + c.Velocity));
         this.CometList.Add(c);
     }
     this.previousMouse = input.LastMouseState;
     base.HandleInput(input);
 }
 public override void HandleInput(InputState input)
 {
     this.currentMouse = input.CurrentMouseState;
     Vector2 MousePos = new Vector2((float)this.currentMouse.X, (float)this.currentMouse.Y);
     if (input.CurrentKeyboardState.IsKeyDown(Keys.O) && !input.LastKeyboardState.IsKeyDown(Keys.O) && !GlobalStats.TakingInput)
     {
         AudioManager.PlayCue("echo_affirm");
         this.ExitScreen();
     }
     if (input.Escaped || input.RightMouseClick)
     {
         this.ExitScreen();
     }
     foreach (UIButton b in this.Buttons)
     {
         if (!HelperFunctions.CheckIntersection(b.Rect, MousePos))
         {
             b.State = UIButton.PressState.Normal;
         }
         else
         {
             string launches = b.Launches;
             string str = launches;
             if (launches != null)
             {
                 if (str == "Save")
                 {
                     if (SavedGame.thread == null || SavedGame.thread != null && !SavedGame.thread.IsAlive)
                     {
                         b.State = UIButton.PressState.Hover;
                     }
                 }
                 else if (str == "Load Game")
                 {
                     if (SavedGame.thread == null || SavedGame.thread != null && !SavedGame.thread.IsAlive)
                     {
                         b.State = UIButton.PressState.Hover;
                     }
                 }
                 else if (str == "Options")
                 {
                     b.State = UIButton.PressState.Hover;
                 }
                 else if (str == "Return to Game")
                 {
                     b.State = UIButton.PressState.Hover;
                 }
                 else if (str == "Exit to Main Menu")
                 {
                     b.State = UIButton.PressState.Hover;
                 }
                 else if (str == "Exit to Windows")
                 {
                     if (SavedGame.thread == null || SavedGame.thread != null && !SavedGame.thread.IsAlive)
                     {
                         b.State = UIButton.PressState.Hover;
                     }
                 }
             }
             if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Pressed)
             {
                 b.State = UIButton.PressState.Pressed;
             }
             if (this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
             {
                 continue;
             }
             string launches1 = b.Launches;
             string str1 = launches1;
             if (launches1 == null)
             {
                 continue;
             }
             if (str1 == "Save")
             {
                 if (SavedGame.thread == null || SavedGame.thread != null && !SavedGame.thread.IsAlive)
                 {
                     SaveGameScreen sgs = new SaveGameScreen(this.screen);
                     base.ScreenManager.AddScreen(sgs);
                 }
                 else
                 {
                     AudioManager.PlayCue("UI_Misc20");
                 }
             }
             else if (str1 == "Load Game")
             {
                 if (SavedGame.thread == null || SavedGame.thread != null && !SavedGame.thread.IsAlive)
                 {
                     LoadSaveScreen lss = new LoadSaveScreen(this.screen);
                     base.ScreenManager.AddScreen(lss);
                     this.ExitScreen();
                 }
                 else
                 {
                     AudioManager.PlayCue("UI_Misc20");
                 }
             }
             else if (str1 == "Options")
             {
                 OptionsScreen options = new OptionsScreen(this.screen, this, new Rectangle(0, 0, 600, 600))
                 {
                     TitleText = Localizer.Token(4),
                     MiddleText = Localizer.Token(4004)
                 };
                 base.ScreenManager.AddScreen(options);
             }
             else if (str1 == "Return to Game")
             {
                 this.ExitScreen();
             }
             else if (str1 == "Exit to Main Menu")
             {
                 this.ExitScreen();
                 if (this.caller != null)
                 {
                     base.ScreenManager.RemoveScreen(this.caller);
                 }
                 this.screen.ExitScreen();
                 base.ScreenManager.AddScreen(new MainMenuScreen());
             }
             else if (str1 == "Exit to Windows")
             {
                 if (SavedGame.thread == null || SavedGame.thread != null && !SavedGame.thread.IsAlive)
                 {
                     Game1.Instance.Exit();
                 }
                 else
                 {
                     AudioManager.PlayCue("UI_Misc20");
                 }
             }
         }
     }
     this.previousMouse = input.LastMouseState;
     base.HandleInput(input);
 }