示例#1
0
        protected override void FinishSetup()
        {
            base.FinishSetup();

            back     = GetChildControl <ButtonControl>("back");
            touchpad = GetChildControl <Vector2Control>("touchpad");
        }
示例#2
0
    /// <summary>
    /// 기본 조작키로 설정합니다.
    /// </summary>
    public void SetButtonsDefaultKey()
    {
        buttonUp        = Keyboard.current.upArrowKey;
        buttonMoveLeft  = Keyboard.current.leftArrowKey;
        buttonDown      = Keyboard.current.downArrowKey;
        buttonMoveJump  = Keyboard.current.spaceKey;
        buttonMoveRight = Keyboard.current.rightArrowKey;
        buttonMouseLeft = Mouse.current.leftButton;
        buttonCtrl      = Keyboard.current.ctrlKey;

        buttonPause = Keyboard.current.escapeKey;

        buttonScroll = Mouse.current.scroll;

        buttonEscape         = Keyboard.current.escapeKey;
        buttonCatch          = Keyboard.current.fKey;
        buttonSkillWater     = Keyboard.current.aKey;
        buttonSkillLightning = Keyboard.current.sKey;

        buttonTalkNext = Keyboard.current.spaceKey;

        buttonInteract = Keyboard.current.fKey;

        buttonCapture = Keyboard.current.pKey;

        buttonAnyKey = Keyboard.current.anyKey;

        //이 밑 키들은 아마도 안씀
        buttonPush     = Keyboard.current.cKey;
        buttonSkillUse = Keyboard.current.xKey;
    }
示例#3
0
        protected override void FinishSetup(InputDeviceBuilder builder)
        {
            base.FinishSetup(builder);

            back     = builder.GetControl <ButtonControl>("back");
            touchpad = builder.GetControl <Vector2Control>("touchpad");
        }
示例#4
0
    void Update()
    {
        //Use the new input systems binding settings file
        Vector2 sidewaysMovement = controls.DefaultActionMap.Movement.ReadValue <Vector2>();
        float   upDown           = controls.DefaultActionMap.UpDown.ReadValue <float>();

        Vector3 translation = new Vector3(sidewaysMovement.x, upDown, sidewaysMovement.y).normalized *movementSpeed *Time.deltaTime;

        transform.Translate(translation, Space.Self);

        // Hardcoded mouse
        if (Mouse.current.rightButton.isPressed)
        {
            Vector3        currentEuler  = transform.rotation.eulerAngles;
            Vector2Control mouseMovement = Mouse.current.delta;
            currentEuler.y += mouseMovement.x.ReadValue() * rotationSpeed;
            currentEuler.x += -mouseMovement.y.ReadValue() * rotationSpeed;
            // Clamp to -90(aka 270) to 90
            //TODO: Does someone have a cleaner solution than 2 branches?
            if (currentEuler.x > 180)
            {
                currentEuler.x = Mathf.Max(currentEuler.x, (float)(360 - 90));
            }
            else
            {
                currentEuler.x = Mathf.Min(currentEuler.x, 90f);
            }

            transform.rotation = Quaternion.Euler(currentEuler);
        }
    }
示例#5
0
    private void Update()
    {
        Vector2Control mousePos = Mouse.current.position;
        Vector3        worldPos = cam.ScreenToWorldPoint(new Vector3(mousePos.x.ReadValue(), mousePos.y.ReadValue()));

        worldPos.z         = 0;
        transform.position = worldPos;
    }
示例#6
0
    public void StopDrawingLine(InputAction.CallbackContext context)
    {
        Vector2Control mousePos = Mouse.current.position;

        endPos = cam.ScreenToWorldPoint(new Vector3(mousePos.x.ReadValue(), mousePos.y.ReadValue()));
        var dmg = new Damage(startPos, endPos, 5000f);

        dmg.ApplyDamage(new TileManager[] { });
    }
示例#7
0
    private void UpdateVector2(InputAction.CallbackContext context)
    {
        Vector2Control control = context.control as Vector2Control;

        if (control != null)
        {
            Vector2 value = control.ReadValue();
            status1Slider.value = value.x;
            status2Slider.value = value.y;
        }
    }
示例#8
0
 // Update visual element for Position and tilt
 private void OnVector2Change(Vector2Control control)
 {
     if (control.name == "position")
     {
         pen_holder.position = new Vector3(control.ReadValue().x *HORIZONTAL_RANGE / Screen.width, control.ReadValue().y *VERTICAL_RANGE / Screen.height, 0) + m_originalPos;
     }
     else if (control.name == "tilt")
     {
         pen_rotation.localEulerAngles = new Vector3(control.ReadValue().y, 0, control.ReadValue().x) * -90;
     }
 }
示例#9
0
        protected override void FinishSetup(InputDeviceBuilder builder)
        {
            if (builder == null)
            {
                throw new System.ArgumentNullException(nameof(builder));
            }

            touchId  = builder.GetControl <IntegerControl>(this, "touchId");
            position = builder.GetControl <Vector2Control>(this, "position");
            base.FinishSetup(builder);
        }
示例#10
0
 // callback function when a Vector2 value is passed in from mouse
 // including delta, position, radius, scroll and tilt.
 // Only delta and scroll have UI to reflect changes
 private void MouseVector2(Vector2Control control)
 {
     if (control.name == "delta")
     {
         OnMouseDelta(control.ReadValue());
     }
     else if (control.name == "scroll")
     {
         OnMouseScroll(control.ReadValue());
     }
 }
示例#11
0
        protected override void FinishSetup(InputDeviceBuilder builder)
        {
            if (builder == null)
            {
                throw new System.ArgumentNullException(nameof(builder));
            }

            base.FinishSetup(builder);

            back     = builder.GetControl <ButtonControl>("back");
            start    = builder.GetControl <ButtonControl>("start");
            touchpad = builder.GetControl <Vector2Control>("touchpad");
        }
示例#12
0
    // Update is called once per frame
    void Update()
    {
        if (playerComponent.isAlive)
        {
            Vector2Control mouseDeltaC = Pointer.current.delta;
            Vector2        mouseDelta  = new Vector2(mouseDeltaC.x.ReadValue(), mouseDeltaC.y.ReadValue());
            mouseDelta = Vector2.Scale(mouseDelta, new Vector2(sensitivity * smoothness, sensitivity * smoothness));

            smoothVector.x = Mathf.Lerp(smoothVector.x, mouseDelta.x, 1.0f / smoothness);
            smoothVector.y = Mathf.Lerp(smoothVector.y, mouseDelta.y, 1.0f / smoothness);

            mouseLook += smoothVector;

            transform.localRotation        = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
            player.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, player.transform.up);
        }
    }
示例#13
0
        protected override void FinishSetup()
        {
            base.FinishSetup();

            deviceVelocity        = GetChildControl <Vector3Control>("deviceVelocity");
            deviceAngularVelocity = GetChildControl <Vector3Control>("deviceAngularVelocity");

            touchpadClick  = GetChildControl <ButtonControl>("touchpadClick");
            touchpadTouch  = GetChildControl <ButtonControl>("touchpadTouch");
            gripPressed    = GetChildControl <ButtonControl>("gripPressed");
            triggerPressed = GetChildControl <ButtonControl>("triggerPressed");
            menu           = GetChildControl <ButtonControl>("menu");

            trigger = GetChildControl <AxisControl>("trigger");
            grip    = GetChildControl <AxisControl>("grip");

            touchpad = GetChildControl <Vector2Control>("touchpad");
            joystick = GetChildControl <Vector2Control>("joystick");
        }
示例#14
0
    /// <summary>
    /// Handle change to 3D camera from 2Dview when player click on the map
    /// </summary>
    private void ChangeTo3DCameraOnClick()
    {
        Vector2Control mousePosition = InputSystem.GetDevice <Mouse>().position;
        Vector3        mousePos      = new Vector3(mousePosition.x.ReadValue(), mousePosition.y.ReadValue(), 0);

        Ray ray = m_mainCamera.ScreenPointToRay(mousePos);

        if (Physics.Raycast(ray, out RaycastHit hit))
        {
            if (null == hit.transform)
            {
                return;
            }
            var objectHit = hit.transform;
            var parent    = objectHit.parent;

            if (null == parent)
            {
                return;
            }
            if (!parent.name.Contains("Territory"))
            {
                return;
            }
        }
        else
        {
            return;
        }

        m_canUnzoom = false;
        mousePos.y -= Screen.height / 7;
        mousePos.x -= Screen.width / 20;
        mousePos    = m_mainCamera.ScreenToWorldPoint(mousePos);
        mousePos.y -= 80;
        StartCoroutine(ChangeTo3DCamera(mousePos));
    }
示例#15
0
    void HandleInput()
    {
        Vector2 moveInput = Vector2.zero;

        moveDir = Vector3.zero;
        jumping = false;

        if (GameSettings.Instance.touchControls)
        {
            // TODO: create better joystick handler (override onscreenstick)
            Vector2Control onScreenStick  = (Vector2Control)joystick.control;
            ButtonControl  onScreenButton = (ButtonControl)jumpButton.control;
            if (onScreenStick != null)
            {
                moveInput = onScreenStick.ReadValue();
            }
            jumping = onScreenButton.wasPressedThisFrame;
        }
        else
        {
            moveInput = pInput.actions["Move"].ReadValue <Vector2> ();
            jumping   = pInput.actions["Jump"].triggered;
        }

        if (Keyboard.current.lKey.wasPressedThisFrame)
        {
            GameSettings.Instance.lefty = !GameSettings.Instance.lefty;
        }

        if (Keyboard.current.tKey.wasPressedThisFrame)
        {
            GameSettings.Instance.touchControls = !GameSettings.Instance.touchControls;
        }

        moveDir.x = moveInput.x;
        moveDir.z = moveInput.y;
    }
示例#16
0
    void OnEnable()
    {
        vector2Action.Enable();
        vector2Action.performed += UpdateVector2;
        vector2Action.started   += UpdateVector2;
        vector2Action.cancelled += UpdateVector2;

        ReadOnlyArray <InputControl> controls = vector2Action.controls;

        for (int i = 0; i < controls.Count; i++)
        {
            Vector2Control control = controls[i] as Vector2Control;
            if (control != null)
            {
                Vector2 value = control.ReadValue();
                status1Slider.value = value.x;
                status2Slider.value = value.y;
            }
            else
            {
                Debug.LogWarningFormat(this, "Vector2ControlActionStatus expects bindings of type {1}, but found {1} binding named {2}.", typeof(Vector2Control).FullName, controls[i].GetType().FullName, controls[i].name);
            }
        }
    }
示例#17
0
 public static Vector2 ToVec2(this Vector2Control control)
 {
     return(new Vector2(control.x.ReadValue(), control.y.ReadValue()));
 }
 protected override void FinishSetup(InputDeviceBuilder builder)
 {
     touchId  = builder.GetControl <IntegerControl>(this, "touchId");
     position = builder.GetControl <Vector2Control>(this, "position");
     base.FinishSetup(builder);
 }
示例#19
0
    public void StartDrawingLine(InputAction.CallbackContext context)
    {
        Vector2Control mousePos = Mouse.current.position;

        startPos = cam.ScreenToWorldPoint(new Vector3(mousePos.x.ReadValue(), mousePos.y.ReadValue()));
    }
 protected override void FinishSetup()
 {
     touchId  = GetChildControl <IntegerControl>("touchId");
     position = GetChildControl <Vector2Control>("position");
     base.FinishSetup();
 }