Exemplo n.º 1
0
    private void UpdateBattle()
    {
        if (_actions.Get(EControllerBtns.Pause).WasReleased)
        {
            UiManager.Show <UIPauseView>();
        }

        if (Debug.isDebugBuild)
        {
            if (_actions.Get(EControllerBtns.Debug).WasPressed)
            {
                if (Player.Instance)
                {
                    Player.Instance.OnPlayerHit();
                }
            }
        }
    }
Exemplo n.º 2
0
    //摇杆行为绑定按键
    public static ControllerActions CreateWithDefaultBindings()
    {
        var p = new ControllerActions();

        p.Get(EControllerBtns.Debug).AddDefaultBinding(Key.F);

        //sure
        p.Get(EControllerBtns.Sure).AddDefaultBinding(Key.Return);
        p.Get(EControllerBtns.Sure).AddDefaultBinding(Key.Z);
        p.Get(EControllerBtns.Sure).AddDefaultBinding(Key.J);
        p.Get(EControllerBtns.Sure).AddDefaultBinding(InputControlType.Action1);

        //back
        p.Get(EControllerBtns.Cancel).AddDefaultBinding(Key.Escape);
        p.Get(EControllerBtns.Cancel).AddDefaultBinding(Key.X);
        p.Get(EControllerBtns.Cancel).AddDefaultBinding(Key.K);
        p.Get(EControllerBtns.Cancel).AddDefaultBinding(InputControlType.Action2);

        //pause
        p.Get(EControllerBtns.Pause).AddDefaultBinding(Key.Escape);
        p.Get(EControllerBtns.Pause).AddDefaultBinding(InputControlType.Action4);

        //shoot
        p.Get(EControllerBtns.Shoot).AddDefaultBinding(Key.Z);
        p.Get(EControllerBtns.Shoot).AddDefaultBinding(Key.J);
        p.Get(EControllerBtns.Shoot).AddDefaultBinding(InputControlType.Action1);

        //slowmove
        p.Get(EControllerBtns.SlowMove).AddDefaultBinding(Key.L);
        p.Get(EControllerBtns.SlowMove).AddDefaultBinding(Key.LeftShift);
        p.Get(EControllerBtns.SlowMove).AddDefaultBinding(InputControlType.Action3);

        //move
        p.Get(EControllerBtns.Up).AddDefaultBinding(Key.UpArrow);
        p.Get(EControllerBtns.Down).AddDefaultBinding(Key.DownArrow);
        p.Get(EControllerBtns.Left).AddDefaultBinding(Key.LeftArrow);
        p.Get(EControllerBtns.Right).AddDefaultBinding(Key.RightArrow);

        p.Get(EControllerBtns.Up).AddDefaultBinding(Key.W);
        p.Get(EControllerBtns.Down).AddDefaultBinding(Key.S);
        p.Get(EControllerBtns.Left).AddDefaultBinding(Key.A);
        p.Get(EControllerBtns.Right).AddDefaultBinding(Key.D);


        p.Get(EControllerBtns.Up).AddDefaultBinding(InputControlType.LeftStickUp);
        p.Get(EControllerBtns.Down).AddDefaultBinding(InputControlType.LeftStickDown);
        p.Get(EControllerBtns.Left).AddDefaultBinding(InputControlType.LeftStickLeft);
        p.Get(EControllerBtns.Right).AddDefaultBinding(InputControlType.LeftStickRight);

        //turn
        p.Get(EControllerBtns.TurnLeft).AddDefaultBinding(InputControlType.RightStickLeft);
        p.Get(EControllerBtns.TurnRight).AddDefaultBinding(InputControlType.RightStickRight);
        p.Get(EControllerBtns.TurnUp).AddDefaultBinding(InputControlType.RightStickUp);
        p.Get(EControllerBtns.TurnDown).AddDefaultBinding(InputControlType.RightStickDown);


        p.ListenOptions.IncludeUnknownControllers = true;
        p.ListenOptions.MaxAllowedBindings        = 4;
        //playerActions.ListenOptions.MaxAllowedBindingsPerType = 1;
        //playerActions.ListenOptions.AllowDuplicateBindingsPerSet = true;
        p.ListenOptions.UnsetDuplicateBindingsOnSet = true;
        //playerActions.ListenOptions.IncludeMouseButtons = true;
        //playerActions.ListenOptions.IncludeModifiersAsFirstClassKeys = true;
        //playerActions.ListenOptions.IncludeMouseButtons = true;
        //playerActions.ListenOptions.IncludeMouseScrollWheel = true;

        /*
         *  playerActions.ListenOptions.OnBindingFound = (action, binding) => {
         *      if (binding == new KeyBindingSource(Key.Escape))
         *      {
         *          action.StopListeningForBinding();
         *          return false;
         *      }
         *      return true;
         *  };*/


        p.ListenOptions.OnBindingAdded += (action, binding) => {
            Debug.Log("Binding added... " + binding.DeviceName + ": " + binding.Name);
        };

        p.ListenOptions.OnBindingRejected += (action, binding, reason) => {
            Debug.Log("Binding rejected... " + reason);
        };

        return(p);
    }