コード例 #1
0
        public void OnUpdate(IInputState input)
        {
            if (!input.ButtonSouth)
            {
                switch (_state)
                {
                case States.JumpRequested:
                    _jumpForce = _minJumpVelocity;
                    break;

                case States.Falling:
                    _state = States.MinJump;
                    break;
                }
            }
            if (input.ButtonSouth)
            {
                if (_state == States.Grounded)
                {
                    // if (!coyoteTime.IsReady)
                    // {
                    //     coyoteTime.Reset();
                    //     Jump();
                    // }
                    Jump();
                }
                else
                {
                    if ((_state == States.Falling || _state == States.MinJump) && airJumpLimit.IsReady)
                    {
                        AirJump();
                    }
                }
            }
        }
コード例 #2
0
 public void OnUpdate(IInputState input)
 {
     InputLookXAnimParam.Set(input.JoystickRight.x);
     InputLookYAnimParam.Set(input.JoystickRight.y);
     InputMoveXAnimParam.Set(input.JoystickLeft.x);
     InputMoveYAnimParam.Set(input.JoystickLeft.y);
 }
コード例 #3
0
        public void Poll(IInputState inputState)
        {
            GamePadState oldState = state;

            state = inputState.GamePadStateOf(PlayerIndex);

            ApplyKeyMap(ref state, inputState);

            foreach (var button in ButtonNames)
            {
                var oldDown = oldState.IsButtonDown(button);
                var newDown = state.IsButtonDown(button);

                if (oldDown != newDown)
                {
                    if (newDown)
                    {
                        OnButtonPressed(button);
                    }
                    else
                    {
                        OnButtonReleased(button);
                    }
                }
            }

            if (state.ThumbSticks.Left != oldState.ThumbSticks.Left)
            {
                LeftStickChanged?.Invoke(this, EventArgs.Empty);
            }
            if (state.ThumbSticks.Right != oldState.ThumbSticks.Right)
            {
                RightStickChanged?.Invoke(this, EventArgs.Empty);
            }
        }
コード例 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="inputState"></param>
 public DesktopHandler(
     InputSettings settings,
     IInputState inputState)
 {
     _settings   = settings;
     _inputState = inputState;
 }
コード例 #5
0
 public override void Update(float dt, IInputState input)
 {
     if (HasFocus && input.ButtonClicked(Buttons.A))
     {
         InvokeClickEvent();
     }
 }
コード例 #6
0
 private void SendKeyDownMessages(IInputState inputState)
 {
     foreach (var keyEvent in _keyDownEvents.Where(keyEvent => inputState.IsKeyDown(keyEvent.Key)))
     {
         keyEvent.Send(inputState);
     }
 }
コード例 #7
0
ファイル: GuiComponent.cs プロジェクト: eriksk/skoggylib
 public virtual void Update(float dt, IInputState input)
 {
     foreach (var child in _children)
     {
         child.Update(dt, input);
     }
 }
コード例 #8
0
        public WaitForJobState(InputStateMachine context, IJob job, IInputState targetState)
            : base(context)
        {
            _job             = job;
            _job.OnComplete += OnJobComplete;

            _targetState = targetState;
        }
コード例 #9
0
 public void HandleInput(IInputState input)
 {
     //var player = new PlayerIndex();
     //if (input.IsMenuCancel(null, out player))
     //{
     //	ExitScreen();
     //}
 }
コード例 #10
0
        public void SetState(IInputState state)
        {
            Debug.Log($"[GameManager] switching input state! {_currentState?.GetType().Name} -> {state?.GetType().Name}");

            _currentState?.Exit();
            _currentState = state;
            _currentState?.Enter();
        }
コード例 #11
0
ファイル: InputManager.cs プロジェクト: kds14/tatics-rpg
 private void ChangeState(IInputState state, Character enterObj = null)
 {
     if (this.state != null)
     {
         this.state.Exit();
     }
     this.state = state;
     this.state.Enter(enterObj);
 }
コード例 #12
0
ファイル: InputManager.cs プロジェクト: kds14/tatics-rpg
 private void Start()
 {
     if (state != null)
     {
         state.Exit();
     }
     state = new NoSelectionState();
     state.Enter();
 }
コード例 #13
0
ファイル: _Support.cs プロジェクト: Crwth/UltimaXNA
 public _Support(Game game)
     : base(game)
 {
     _game = game;
     _Input = Game.Services.GetService<IInputState>();
     _UserInterface = Game.Services.GetService<IUIManager>();
     _World = game.Services.GetService<IIsometricRenderer>();
     EngineVars.EngineRunning = true;
     EngineVars.InWorld = false;
 }
コード例 #14
0
 private void SendMouseMoveMessages(IInputState inputState)
 {
     // TODO: we have the "right mouse button down" requirement hardcoded here for now
     if (inputState.IsRightMouseButtonDown && (inputState.MouseDeltaX != 0 || inputState.MouseDeltaY != 0))
     {
         foreach (var moveEvent in _mouseMoveEvents)
         {
             moveEvent.Send(inputState);
         }
     }
 }
コード例 #15
0
    public void SetState(IInputState state)
    {
        m_bRunbegin = false;

        if (m_state != null)
        {
            m_state.StateEnd();
        }

        m_state = state;
    }
コード例 #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="components"></param>
 /// <param name="triggerItems"></param>
 /// <param name="collisionState"></param>
 /// <param name="input"></param>
 public PlayerModel(
     Components components,
     PlayerTriggerItems triggerItems,
     PlayerCollisionState collisionState,
     IInputState input)
 {
     _components    = components;
     TriggerItems   = triggerItems;
     CollisionState = collisionState;
     Input          = input;
 }
コード例 #17
0
        public void SetState(InputMode mode_)
        {
            if (_currentState == _states[mode_])
            {
                return;
            }
            _currentState = _states[mode_];

            Cursor.lockState = _currentState.CursorLockMode;
            Cursor.visible   = _currentState.CursorLockMode != CursorLockMode.Locked;
        }
コード例 #18
0
ファイル: GameBattle.cs プロジェクト: kuraselache/SizeEmblem
        /// <summary>
        /// Get the current player input state of the battle controller.
        /// </summary>
        /// <param name="currentState">The current plyaer input state of the battle controller. Null if it isn't in a state to receive player input.</param>
        /// <returns>True if a valid player input state was returned. False otherwise.</returns>
        public bool CurrentInputState(out IInputState currentState)
        {
            if (State != BattleStates.PlayerPhase || !_inputStateStack.Any())
            {
                currentState = null;
                return(false);
            }

            currentState = _inputStateStack.Peek();
            return(true);
        }
コード例 #19
0
ファイル: VerticalList.cs プロジェクト: eriksk/skoggylib
        public override void Update(float dt, IInputState input)
        {
            if (input.UpClicked())
            {
                Previous();
            }
            else if (input.DownClicked())
            {
                Next();
            }

            base.Update(dt, input);
        }
コード例 #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="input"></param>
 /// <param name="selectionBox"></param>
 /// <param name="selectingHandler"></param>
 /// <param name="controllingHandler"></param>
 /// <param name="cursorHandler"></param>
 public ControlsController(
     IInputState input,
     SelectionDragGuiHandler selectionBox,
     SelectingHandler selectingHandler,
     ControllingHandler controllingHandler,
     CursorHandler cursorHandler)
 {
     _input              = input;
     _selectionBox       = selectionBox;
     _selectingHandler   = selectingHandler;
     _controllingHandler = controllingHandler;
     _cursorHandler      = cursorHandler;
 }
コード例 #21
0
ファイル: BaseScene.cs プロジェクト: Crwth/UltimaXNA
        public BaseScene(Game game, bool needsUIService)
        {
            _game = game;
            _clearColor = Color.Black;
            _content = new ContentManager(_game.Services);
            _content.RootDirectory = "Content";
            _sceneState = SceneState.TransitioningOn;

            _sceneService = game.Services.GetService<ISceneService>(true);
            _inputService = game.Services.GetService<IInputState>(true);
            _worldService = game.Services.GetService<IIsometricRenderer>(true);
            _uiService = game.Services.GetService<IUIManager>();
        }
コード例 #22
0
ファイル: IsometricRenderer.cs プロジェクト: Crwth/UltimaXNA
        public IsometricRenderer(Game game)
        {
            _input = game.Services.GetService<IInputState>();
            _spriteBatch = new SpriteBatch3D(game);
            _vectors = new VectorRenderer(game.GraphicsDevice, game.Content);

            PickType = PickTypes.PickNothing;
            _vertexBufferStretched = new VertexPositionNormalTextureHue[] {
                new VertexPositionNormalTextureHue(new Vector3(), new Vector3(),  new Vector3(0, 0, 0)),
                new VertexPositionNormalTextureHue(new Vector3(), new Vector3(),  new Vector3(1, 0, 0)),
                new VertexPositionNormalTextureHue(new Vector3(), new Vector3(),  new Vector3(0, 1, 0)),
                new VertexPositionNormalTextureHue(new Vector3(), new Vector3(),  new Vector3(1, 1, 0))
            };
        }
コード例 #23
0
            public IEnumerable <Glyph> readLine(string line)
            {
                if (Format.isNotes(line))
                {
                    assert(!Format.readNotes(line, 0).Any());
                    ++nIntervalsPerBar;
                    yield break;
                }

                Signature signature = new Signature(4, 4, nIntervalsPerBar);

                yield return(signature);

                assert(nIntervalsPerBar == (signature.beatsPerBar * 2));
                newState = new StateMain(signature);
            }
コード例 #24
0
ファイル: Genesis.cs プロジェクト: XaaK/GenesisEngine
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;

            IsMouseVisible = true;

            _mainPresenter = ObjectFactory.GetInstance <MainPresenter>();
            _mainPresenter.Show();

            _inputState  = ObjectFactory.GetInstance <IInputState>();
            _inputMapper = ObjectFactory.GetInstance <IInputMapper>();

            SetInputBindings();

            base.Initialize();
        }
コード例 #25
0
ファイル: GameBattle.cs プロジェクト: kuraselache/SizeEmblem
        /// <summary>
        /// Add a new input state to the current input state stack.
        /// This will mark the current state, if any, as inactive and inform it of the new state that is taking its place.
        /// Then this will add the new state to the stack, mark it active, and call the BeginState method.
        /// </summary>
        /// <param name="nextInputState"></param>
        public void AddInputState(IInputState nextInputState)
        {
            if (nextInputState == null)
            {
                throw new ArgumentNullException(nameof(nextInputState), "Given new state passed to GameBattle AddInputState method is null");
            }

            // Deactivate any existing state on the stack
            if (_inputStateStack.Any())
            {
                var lastState = _inputStateStack.Peek();
                lastState.Deactivate();
            }

            // Add the new state to the stack and
            _inputStateStack.Push(nextInputState);
            nextInputState.Activate();
        }
コード例 #26
0
        public override void Update(float dt, IInputState input)
        {
            if (HasFocus)
            {
                if (input.ButtonClicked(Buttons.A))
                {
                    SelectCurrentItem();
                }
                else if (input.LeftClicked())
                {
                    PreviousItem();
                }
                else if (input.RightClicked())
                {
                    NextItem();
                }
            }

            base.Update(dt, input);
        }
コード例 #27
0
        // Feature is disabled because it isn't working and has questionable value.
        // If enabled, be sure to enable the unit tests.
        private void ApplyKeyMap(ref GamePadState padState, IInputState inputState)
        {
            if (KeyMap == null)
            {
                return;
            }

            var keys = inputState.KeyboardState;

            Buttons buttons = 0;

            foreach (var button in ButtonNames)
            {
                if (padState.IsButtonDown(button))
                {
                    buttons |= button;
                }
            }

            foreach (var key in KeyMap.Keys)
            {
                var map = KeyMap[key];

                if (keys.IsKeyDown(key))
                {
                    var item = KeyMap[key];

                    if (item.Button != 0)
                    {
                        buttons |= item.Button;
                    }
                }
            }

            padState = new GamePadState(
                padState.ThumbSticks.Left,
                padState.ThumbSticks.Right,
                padState.Triggers.Left,
                padState.Triggers.Right,
                buttons);
        }
コード例 #28
0
ファイル: PlayerInput.cs プロジェクト: ASarrouj/CSE5912-Game
 public void FinalizePerspective(Transform currentTransform)
 {
     if (lastKeyIndex == -1)
     {
         inputState = new MechState(transform);
         uiManager.MechUI();
     }
     else if (slots[lastKeyIndex].tag == "Weapon")
     {
         inputState = new WeaponState(transform);
         uiManager.WeaponUI();
     }
     else if (slots[lastKeyIndex].tag == "RepairTool")
     {
         inputState = new RepairState(transform);
         uiManager.MechUI();
     }
     else if (slots[lastKeyIndex].tag == "MineDeployer")
     {
         inputState = new MineState(transform);
     }
 }
コード例 #29
0
 public void DisposeState(IInputState state)
 {
     (state as IDisposable)?.Dispose();
 }
コード例 #30
0
ファイル: GameBattle.cs プロジェクト: kuraselache/SizeEmblem
 public void SetState(IInputState newInputState)
 {
     ClearInputStack();
     AddInputState(newInputState);
 }
コード例 #31
0
ファイル: GameState.cs プロジェクト: Crwth/UltimaXNA
 public static void Initialize(Game game)
 {
     _inputNew = game.Services.GetService<IInputState>();
     _world = game.Services.GetService<IIsometricRenderer>();
     _ui = game.Services.GetService<IUIManager>();
 }
コード例 #32
0
ファイル: GameScene.cs プロジェクト: eylvisaker/BallBusterX
 protected override void OnUpdateInput(IInputState input)
 {
 }
コード例 #33
0
 void IScene.UpdateInput(IInputState input)
 {
     OnUpdateInput(input);
 }
コード例 #34
0
 /// <summary>
 /// Called when the scene should process input.
 /// </summary>
 /// <param name="input"></param>
 protected virtual void OnUpdateInput(IInputState input)
 {
     UpdateInput?.Invoke(this, input);
 }