Exemplo n.º 1
0
    private void UpdateInputData()
    {
        GameInput.PlayerActions playerInput = gameInput.Player;

        InputData result = InputData.none;

        Vector2 move = playerInput.Move.ReadValue <Vector2>();

        move = Quaternion.AngleAxis(LookAtYAngle, Vector3.back) * move;

        ActionKeyCode keyCode = ActionKeyCode.None;

        if (move.x != 0)
        {
            keyCode |= move.x < 0 ? ActionKeyCode.Left : ActionKeyCode.Right;
        }

        if (move.y != 0)
        {
            keyCode |= move.y > 0 ? ActionKeyCode.Up : ActionKeyCode.Down;
        }

        if (playerInput.Move.phase == InputActionPhase.Started)
        {
            keyCode |= ActionKeyCode.Axis;
        }

        if (playerInput.Attack.triggered)
        {
            keyCode |= ActionKeyCode.Attack;
        }

        if (playerInput.Attack.phase == InputActionPhase.Started)
        {
            keyCode |= ActionKeyCode.Attacking;
        }

        if (playerInput.Skill.triggered)
        {
            keyCode |= ActionKeyCode.Skill;
        }

        if (playerInput.Dash.triggered)
        {
            keyCode |= ActionKeyCode.Dash;
        }
        result.SetKeyCode(keyCode);
        result.SetAxisFromDir(move);

        AddInput(inputTargetId, result);
        lastInput = result;
    }
Exemplo n.º 2
0
    private void UpdateGlobalInputData()
    {
        GameInput.PlayerActions playerInput = gameInput.Player;
        Vector2 lookDelta = playerInput.Look.ReadValue <Vector2>();

        if (Mathf.Abs(lookDelta.x) > 0.3f)
        {
            lookDelta.y = 0f;
        }

        lookAtOffset      = (lookAtOffset + lookDelta.x) % 360f;
        lookAtHeightScale = Mathf.Clamp01(lookAtHeightScale - lookDelta.y * Time.deltaTime);
    }