Beispiel #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();
                    }
                }
            }
        }
 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);
 }
Beispiel #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);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="inputState"></param>
 public DesktopHandler(
     InputSettings settings,
     IInputState inputState)
 {
     _settings   = settings;
     _inputState = inputState;
 }
Beispiel #5
0
 public override void Update(float dt, IInputState input)
 {
     if (HasFocus && input.ButtonClicked(Buttons.A))
     {
         InvokeClickEvent();
     }
 }
Beispiel #6
0
 private void SendKeyDownMessages(IInputState inputState)
 {
     foreach (var keyEvent in _keyDownEvents.Where(keyEvent => inputState.IsKeyDown(keyEvent.Key)))
     {
         keyEvent.Send(inputState);
     }
 }
Beispiel #7
0
 public virtual void Update(float dt, IInputState input)
 {
     foreach (var child in _children)
     {
         child.Update(dt, input);
     }
 }
        public WaitForJobState(InputStateMachine context, IJob job, IInputState targetState)
            : base(context)
        {
            _job             = job;
            _job.OnComplete += OnJobComplete;

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

            _currentState?.Exit();
            _currentState = state;
            _currentState?.Enter();
        }
Beispiel #11
0
 private void ChangeState(IInputState state, Character enterObj = null)
 {
     if (this.state != null)
     {
         this.state.Exit();
     }
     this.state = state;
     this.state.Enter(enterObj);
 }
Beispiel #12
0
 private void Start()
 {
     if (state != null)
     {
         state.Exit();
     }
     state = new NoSelectionState();
     state.Enter();
 }
Beispiel #13
0
 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;
 }
Beispiel #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);
         }
     }
 }
    public void SetState(IInputState state)
    {
        m_bRunbegin = false;

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

        m_state = state;
    }
Beispiel #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;
 }
        public void SetState(InputMode mode_)
        {
            if (_currentState == _states[mode_])
            {
                return;
            }
            _currentState = _states[mode_];

            Cursor.lockState = _currentState.CursorLockMode;
            Cursor.visible   = _currentState.CursorLockMode != CursorLockMode.Locked;
        }
Beispiel #18
0
        /// <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);
        }
Beispiel #19
0
        public override void Update(float dt, IInputState input)
        {
            if (input.UpClicked())
            {
                Previous();
            }
            else if (input.DownClicked())
            {
                Next();
            }

            base.Update(dt, input);
        }
Beispiel #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;
 }
Beispiel #21
0
        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>();
        }
Beispiel #22
0
        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))
            };
        }
Beispiel #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);
            }
Beispiel #24
0
        /// <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();
        }
Beispiel #25
0
        /// <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();
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #28
0
 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);
     }
 }
 public void DisposeState(IInputState state)
 {
     (state as IDisposable)?.Dispose();
 }
Beispiel #30
0
 public void SetState(IInputState newInputState)
 {
     ClearInputStack();
     AddInputState(newInputState);
 }
Beispiel #31
0
 public static void Initialize(Game game)
 {
     _inputNew = game.Services.GetService<IInputState>();
     _world = game.Services.GetService<IIsometricRenderer>();
     _ui = game.Services.GetService<IUIManager>();
 }
Beispiel #32
0
 protected override void OnUpdateInput(IInputState input)
 {
 }
Beispiel #33
0
 void IScene.UpdateInput(IInputState input)
 {
     OnUpdateInput(input);
 }
Beispiel #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);
 }