Пример #1
0
        public override void HandleInput( InputState input )
        {
            PlayerIndex playerIndex;

              if ( input.IsMenuSelect( ControllingPlayer, out playerIndex ) )
              {
            // Raise the accepted event, then exit the message box.
            if ( Accepted != null )
              Accepted( this, new PlayerIndexEventArgs( playerIndex ) );

            GameCore.Instance.AudioManager.Play2DCue( "selectItem", 1f );

            ExitScreen();
              }
              else if ( input.IsMenuCancel( ControllingPlayer, out playerIndex ) )
              {
            // Raise the cancelled event, then exit the message box.
            if ( Cancelled != null )
              Cancelled( this, new PlayerIndexEventArgs( playerIndex ) );

            GameCore.Instance.AudioManager.Play2DCue( "onCancel", 1f );

            ExitScreen();
              }
        }
Пример #2
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput( InputState input )
        {
            ReadOnlyCollection<MenuEntry> menuEntries = MenuEntries;
              ReadOnlyCollection<ImageMenuEntry> imageMenuEntries = ImageMenuEntries;

              PlayerIndex playerIndex;

              // If there is a wheel menu, handle left and right input
              if ( menuItems.AllObjectsList.Exists( item => item is WheelMenu ) )
              {
            WheelMenu wheel = menuItems.GetObjects<WheelMenu>()[0];
            if ( wheel.AcceptingInput )
            {
              if ( input.IsMenuLeft( ControllingPlayer ) )
            wheel.RotateCW();
              if ( input.IsMenuRight( ControllingPlayer ) )
            wheel.RotateCCW();
            }
              }
              else if ( imageMenuEntries != null && imageMenuEntries.Count != 0 )
              {
            // Move to the previous menu entry?
            if ( input.IsMenuUp( ControllingPlayer ) )
            {
              imageMenuEntries[selectedEntry--].Focused = false;

              if ( selectedEntry < 0 )
            selectedEntry = imageMenuEntries.Count - 1;

              imageMenuEntries[selectedEntry].Focused = true;

              GameCore.Instance.AudioManager.Play2DCue( "whoosh", 1f );
            }

            // Move to the next menu entry?
            if ( input.IsMenuDown( ControllingPlayer ) )
            {
              imageMenuEntries[selectedEntry++].Focused = false;

              if ( selectedEntry >= imageMenuEntries.Count )
            selectedEntry = 0;

              imageMenuEntries[selectedEntry].Focused = true;

              GameCore.Instance.AudioManager.Play2DCue( "whoosh", 1f );
            }
              }
              else if ( menuEntries != null && menuEntries.Count != 0 )
              {
            // Move to the previous menu entry?
            if ( input.IsMenuUp( ControllingPlayer ) )
            {
              menuEntries[selectedEntry--].Focused = false;

              if ( selectedEntry < 0 )
            selectedEntry = menuEntries.Count - 1;

              menuEntries[selectedEntry].Focused = true;

              GameCore.Instance.AudioManager.Play2DCue( "whoosh", 1f );
            }

            // Move to the next menu entry?
            if ( input.IsMenuDown( ControllingPlayer ) )
            {
              menuEntries[selectedEntry++].Focused = false;

              if ( selectedEntry >= menuEntries.Count )
            selectedEntry = 0;

              menuEntries[selectedEntry].Focused = true;

              GameCore.Instance.AudioManager.Play2DCue( "whoosh", 1f );
            }
              }

              if ( input.IsMenuSelect( ControllingPlayer, out playerIndex ) )
            OnSelectEntry( playerIndex );
              else if ( input.IsMenuRight( ControllingPlayer, out playerIndex ) )
            OnIncrementEntry( playerIndex );
              else if ( input.IsMenuLeft( ControllingPlayer, out playerIndex ) )
            OnDecrementEntry( playerIndex );
              else if ( input.IsMenuCancel( ControllingPlayer, out playerIndex ) )
            OnCancel( playerIndex );
        }