Ejemplo n.º 1
0
 public override void HandleInput(InputState input)
 {
     if (input.IsNewKeyPress(Keys.Enter) || input.IsNewKeyPress(Keys.Escape) || input.IsNewKeyPress(Keys.Space))
     {
         ScreenManager.RemoveScreen(this);
     }
 }
Ejemplo n.º 2
0
        // handle key presses
        public override void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.Up))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }
            if (input.IsNewKeyPress(Keys.Down))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }
            if (input.IsNewKeyPress(Keys.Enter))
            {
                switch (selectedEntry)
                {
                    case (int)MainMenuEntry.Start:
                        ScreenManager.AddScreen(new ProfileScreen(this));
                        break;
                    case (int)MainMenuEntry.Options:
                        ScreenManager.AddScreen(new OptionsScreen(this));
                        break;
                    case (int)MainMenuEntry.Exit:
                        ScreenManager.Game.Exit();
                        break;
                }
            }
        }
Ejemplo n.º 3
0
 public override void HandleInput(InputState input)
 {
     if (input.IsNewKeyPress(Keys.Up))
     {
         player.DoAction("Move", new MoveArgs(MoveArgs.Direction.Up));
     }
     else if (input.IsNewKeyPress(Keys.Down))
     {
         player.DoAction("Move", new MoveArgs(MoveArgs.Direction.Down));
     }
     else if (input.IsNewKeyPress(Keys.Left))
     {
         player.DoAction("Move", new MoveArgs(MoveArgs.Direction.Left));
     }
     else if (input.IsNewKeyPress(Keys.Right))
     {
         player.DoAction("Move", new MoveArgs(MoveArgs.Direction.Right));
     }
 }
Ejemplo n.º 4
0
        public override void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.Up))
            {
                if (OnProfiles)
                {
                    SelectedProfileEntry--;

                    if (SelectedProfileEntry < 0)
                    {
                        SelectedProfileEntry = -1;
                        SelectedMenuEntry = MenuEntries.Count - 1;
                        OnProfiles = false;
                        OnMenu = true;
                    }
                }
                else if (OnMenu)
                {
                    SelectedMenuEntry--;

                    if (SelectedMenuEntry < 0)
                    {
                        if (ProfileEntries.Count > 0)
                        {
                            SelectedMenuEntry = -1;
                            SelectedProfileEntry = ProfileEntries.Count - 1;
                            OnProfiles = true;
                            OnMenu = false;
                        }
                        else
                        {
                            SelectedMenuEntry = MenuEntries.Count - 1;
                        }
                    }
                }
            }
            if (input.IsNewKeyPress(Keys.Down))
            {
                if (OnProfiles)
                {
                    SelectedProfileEntry++;

                    if (SelectedProfileEntry >= ProfileEntries.Count)
                    {
                        SelectedProfileEntry = -1;
                        SelectedMenuEntry = 0;
                        OnProfiles = false;
                        OnMenu = true;
                    }
                }
                else if (OnMenu)
                {
                    SelectedMenuEntry++;

                    if (SelectedMenuEntry >= MenuEntries.Count)
                    {
                        if (ProfileEntries.Count > 0)
                        {
                            SelectedMenuEntry = -1;
                            SelectedProfileEntry = 0;
                            OnProfiles = true;
                            OnMenu = false;
                        }
                        else
                        {
                            SelectedMenuEntry = 0;
                        }
                    }
                }
            }
            if (input.IsNewKeyPress(Keys.Enter))
            {
                if (OnMenu)
                {
                    switch (SelectedMenuEntry)
                    {
                        case (int)ProfileEntry.New:
                            if (NewProfileActive)
                            {
                                // done typing (save it)
                                string newProfileName = KeyboardInput.ToString();
                                if (ProfileFiles != null && ProfileFiles.Length > 0)
                                {
                                    if (DoesProfileExist(newProfileName))
                                    {
                                       ScreenManager.AddScreen(new PopUpWarningScreen(this, "Profile with this name already exists."));
                                    }
                                    else
                                    {
                                        CreateNewProfile(newProfileName);
                                    }
                                }
                                else
                                {
                                    CreateNewProfile(newProfileName);
                                }
                                KeyboardInput.Clear();
                                NewProfileActive = false;
                            }
                            else if (!NewProfileActive)
                            {
                                // start taking keystrokes
                                NewProfileActive = true;
                            }
                            break;
                        case (int)ProfileEntry.Cancel:
                            ScreenManager.RemoveScreen(this);
                            ParentScreen.CurrentScreenState = ScreenState.Active;
                            break;
                    }
                }
                else if (OnProfiles)
                {
                    ScreenManager.AddScreen(new MainGameScreen());
                    ScreenManager.RemoveScreen(this);
                }
            }
            if (input.IsNewKeyPress(Keys.Escape))
            {
                if (NewProfileActive)
                {
                    KeyboardInput.Clear();
                    NewProfileActive = false;
                }
                ScreenManager.RemoveScreen(this);
                ParentScreen.CurrentScreenState = ScreenState.Active;
            }
        }
Ejemplo n.º 5
0
 public virtual void HandleInput(InputState input)
 {
 }
Ejemplo n.º 6
0
        public override void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.Up))
            {
                if (!ResolutionActive)
                {
                    SelectedEntry--;

                    if (SelectedEntry < 0)
                        SelectedEntry = MenuEntries.Count - 1;
                }
                else if (ResolutionActive)
                {
                    ResolutionSelectedEntry--;

                    if (ResolutionSelectedEntry < 0)
                        ResolutionSelectedEntry = ResolutionEntries.Count - 1;
                }
            }
            if (input.IsNewKeyPress(Keys.Down))
            {
                if (!ResolutionActive)
                {
                    SelectedEntry++;

                    if (SelectedEntry >= MenuEntries.Count)
                        SelectedEntry = 0;
                }
                else if (ResolutionActive)
                {
                    ResolutionSelectedEntry++;

                    if (ResolutionSelectedEntry >= ResolutionEntries.Count)
                        ResolutionSelectedEntry = 0;
                }
            }
            if (input.IsNewKeyPress(Keys.Enter))
            {
                switch (SelectedEntry)
                {
                    case (int)OptionsEntry.Resolution:
                        if (ResolutionActive)
                        {
                            Resolution res = Resolutions[ResolutionSelectedEntry];
                            this.ScreenManager.Graphics.PreferredBackBufferWidth = res.Width;
                            this.ScreenManager.Graphics.PreferredBackBufferHeight = res.Height;
                            ClientOptions.SetResolution(res.Height, res.Width);

                            ResolutionChanged = true;
                            ResolutionActive = false;
                        }
                        else if (!ResolutionActive)
                        {
                            ResolutionActive = true;
                        }
                        break;
                    case (int)OptionsEntry.Fullscreen:
                        if (ClientOptions.Fullscreen)
                        {
                            this.ScreenManager.Graphics.ToggleFullScreen();
                            ClientOptions.SetFullscreen(false);
                        }
                        else
                        {
                            this.ScreenManager.Graphics.ToggleFullScreen();
                            ClientOptions.SetFullscreen(true);
                        }
                        FullscreenChanged = true;
                        break;
                    case (int)OptionsEntry.Exit:
                        ClientOptions.Save(); // save client options
                        ScreenManager.RemoveScreen(this);
                        ParentScreen.CurrentScreenState = ScreenState.Active;
                        break;
                }
            }
            if (input.IsNewKeyPress(Keys.Escape))
            {
                if (ResolutionActive)
                {
                    ResolutionActive = false;
                }
                else
                {
                    ClientOptions.Save();
                    ScreenManager.RemoveScreen(this);
                    ParentScreen.CurrentScreenState = ScreenState.Active;
                }
            }
        }
Ejemplo n.º 7
0
 public virtual void HandleInput(InputState input)
 {
 }