Exemple #1
0
        private InputSystem()
        {
            keyboardState = Keyboard.GetState();
            gamePadState  = GamePad.GetState(PlayerIndex.One);

            virtualButtonConfigs = new List <VirtualButtonConfig>();

            XDocument xdoc = XDocument.Load(@"Content\Config\Config.xml");

            foreach (XElement element in xdoc.Descendants("Input"))
            {
                VirtualButtons virtualButton = (VirtualButtons)Enum.Parse(typeof(VirtualButtons), element.Attribute("virtual_button").Value);
                Keys           key           = (Keys)Enum.Parse(typeof(Keys), element.Attribute("key").Value);
                Buttons        button        = (Buttons)Enum.Parse(typeof(Buttons), element.Attribute("button").Value);
                AddAction(virtualButton, key, button);
            }

            LeftThumbSticks  = Vector2.Zero;
            RightThumbSticks = Vector2.Zero;

            LeftTrigger  = 0f;
            RightTrigger = 0f;

            PreviousActions = new List <VirtualButtons>();
            CurrentActions  = new List <VirtualButtons>();
        }
Exemple #2
0
        public override void SetButtonUp(string name)
        {
            if (!VirtualButtons.ContainsKey(name))
            {
                AddButton(name);
            }

            VirtualButtons[name].Released();
        }
Exemple #3
0
        public override void SetButtonDown(string name)
        {
            if (!VirtualButtons.ContainsKey(name))
            {
                AddButton(name);
            }

            VirtualButtons[name].Pressed();
        }
Exemple #4
0
        public override bool GetButton(string name)
        {
            if (VirtualButtons.ContainsKey(name))
            {
                return(VirtualButtons[name].GetButton);
            }

            AddButton(name);
            return(VirtualButtons[name].GetButton);
        }
 protected override void OnButtonReleased(VirtualButtons button)
 {
     switch (button) {
       case VirtualButtons.Left:
     detailsTemplate.SelectPrev();
     break;
       case VirtualButtons.Right:
     detailsTemplate.SelectNext();
     break;
       case VirtualButtons.Select:
       case VirtualButtons.Context:
     detailsTemplate.Confirm();
     break;
       case VirtualButtons.Delete:
     OnCancel();
     break;
       }
 }
 /// <summary>
 /// Handle user input.
 /// </summary>
 /// <param name="button"></param>
 protected override void OnButtonReleased(VirtualButtons button)
 {
     switch (button) {
       case VirtualButtons.Context:
     if (!editableLevel.FindCollision())
       ScreenList.AddScreen(new GameplayScreen(TopLevel, CreateLevel(), LevelName));
     break;
       case VirtualButtons.Pause:
     ScreenList.AddScreen(new PauseMenuScreen(TopLevel, editableLevel, LevelName));
     break;
       case VirtualButtons.Select:
     target = null;
     break;
       }
 }
 protected override void OnButtonPressed(VirtualButtons button)
 {
     switch (button) {
       case VirtualButtons.Select:
     prevPosition = Controller.Point;
     target = FindTarget(Controller.Point);
     break;
       case VirtualButtons.Delete:
     editableLevel.MoveablePlatforms.Remove((Platform)FindTarget(Controller.Point));
     break;
       }
 }
 protected override void OnButtonReleased(VirtualButtons button)
 {
     switch (button) {
       case VirtualButtons.Up:
     menuTemplate.SelectPrev();
     break;
       case VirtualButtons.Down:
     menuTemplate.SelectNext();
     break;
       case VirtualButtons.Select:
       case VirtualButtons.Context:
     menuTemplate.Confirm();
     break;
       case VirtualButtons.Delete:
     OnCancel();
     break;
       }
 }
 protected override void OnButtonReleased(VirtualButtons button)
 {
     switch (button) {
       case VirtualButtons.Left:
     messageBoxTemplate.SelectPrev();
     break;
       case VirtualButtons.Right:
     messageBoxTemplate.SelectNext();
     break;
       case VirtualButtons.Select:
       case VirtualButtons.Context:
     messageBoxTemplate.Confirm();
     break;
       }
 }
 protected virtual void OnButtonPressed(VirtualButtons button)
 {
 }
        protected override void OnButtonPressed(VirtualButtons button)
        {
            switch (button) {
              case VirtualButtons.Up:
            launcherChange.Y += 1;
            break;
              case VirtualButtons.Down:
            launcherChange.Y -= 1;
            break;

              case VirtualButtons.Left:
            launcherChange.X += 1;
            break;
              case VirtualButtons.Right:
            launcherChange.X -= 1;
            break;
              }
        }
 public bool IsButtonPressed(VirtualButtons type)
 {
     switch (type) {
       case VirtualButtons.Up:
     return Up;
       case VirtualButtons.Down:
     return Down;
       case VirtualButtons.Left:
     return Left;
       case VirtualButtons.Right:
     return Right;
       case VirtualButtons.Select:
     return Select;
       case VirtualButtons.Delete:
     return Delete;
       case VirtualButtons.Context:
     return Context;
       case VirtualButtons.Mode:
     return Mode;
       case VirtualButtons.Pause:
     return Pause;
       case VirtualButtons.Debug:
     return Debug;
       case VirtualButtons.Easter:
     return Easter;
       default:
     throw new ArgumentException("Invalid valud for type: " + type.ToString());
       }
 }
 protected override void OnButtonPressed(VirtualButtons button)
 {
     switch (button) {
       case VirtualButtons.Select:
     prevPosition = Controller.Point;
     target = FindTarget(Controller.Point);
     break;
       case VirtualButtons.Delete:
     delete(Controller.Point);
     break;
       }
 }
Exemple #14
0
 public VirtualButtonConfig(VirtualButtons virtualButton, Keys key, Buttons button)
 {
     VirtualButton = virtualButton;
     Key           = key;
     Button        = button;
 }
 protected virtual void OnButtonReleased(VirtualButtons button)
 {
 }
 public bool IsButtonPressed(VirtualButtons button)
 {
     return buttons[(int)button];
 }
Exemple #17
0
        private void AddAction(VirtualButtons virtualButton, Keys key, Buttons button)
        {
            VirtualButtonConfig virtualButtonConfig = new VirtualButtonConfig(virtualButton, key, button);

            virtualButtonConfigs.Add(virtualButtonConfig);
        }
 public void SetButtonState(VirtualButtons button, bool state)
 {
     buttons[(int)button] = state;
 }
        protected override void OnButtonReleased(VirtualButtons button)
        {
            switch (button) {
              case VirtualButtons.Up:
            launcherChange.Y -= 1;
            break;
              case VirtualButtons.Down:
            launcherChange.Y += 1;
            break;

              case VirtualButtons.Left:
            launcherChange.X -= 1;
            break;
              case VirtualButtons.Right:
            launcherChange.X += 1;
            break;

              case VirtualButtons.Pause:
            ScreenList.AddScreen(new PauseMenuScreen(TopLevel, simulation, LevelName));
            break;
              case VirtualButtons.Select:
            simulation.HandleConfirm();
            break;

              case VirtualButtons.Debug:
            Console.WriteLine("Completely restarted.");
            simulation.Restart();
            break;
              }
        }
        protected override void OnButtonReleased(VirtualButtons button)
        {
            if (button == VirtualButtons.Delete) {
            if (Accepted != null)
              Accepted();

            ExitScreen();
              }
        }