コード例 #1
0
        void Update()
        {
            Vector3 displacement = Vector3.zero;

            #if JamToolsUseInControl
            switch (inputMode)
            {
            case InputMode.DefaultUnityAxes:
                displacement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
                if (Input.GetButtonDown("Jump"))
                {
                    puppetAbilities.Jump();
                }
                break;

            case InputMode.InControl:
                if (inputDevice == null)
                {
                    //Debug.Log("no input device");
                    if (InputManager.Devices.Count > playerIndex && playerIndex >= 0)
                    {
                        inputDevice = InputManager.Devices[playerIndex];
                    }
                }
                else
                {
                    if (allowDPad)
                    {
                        displacement = new Vector3(inputDevice.Direction.X, 0, inputDevice.Direction.Y);
                    }
                    else
                    {
                        displacement = new Vector3(inputDevice.LeftStick.X, 0, inputDevice.LeftStick.Y);
                    }

                    if (inputDevice.Action1.WasPressed)
                    {
                        puppetAbilities.Jump();
                    }
                }
                break;

            case InputMode.InControlTouchAnalogue:
                touchDevice  = TouchManager.Device;
                displacement = new Vector3(touchDevice.Direction.X, 0, touchDevice.Direction.Y);
                break;

            case InputMode.Any:
                bool jumpedForAnother = false;
                displacement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
                if (InputManager.Devices.Count > playerIndex && playerIndex >= 0)
                {
                    inputDevice = InputManager.Devices[playerIndex];

                    if (displacement.magnitude < 0.1f)
                    {
                        displacement = new Vector3(inputDevice.Direction.X, 0, inputDevice.Direction.Y);
                    }
                    if (inputDevice.Action1.WasPressed && !jumpedForAnother)
                    {
                        puppetAbilities.Jump();
                        jumpedForAnother = true;
                    }
                }

                touchDevice = TouchManager.Device;

                if (touchDevice != null && displacement.magnitude < 0.1f)
                {
                    displacement = new Vector3(touchDevice.Direction.X, 0, touchDevice.Direction.Y);
                }

                if (Input.GetButtonDown("Jump"))
                {
                    puppetAbilities.Jump();
                }

                tapReleaseJumpTimer -= Time.deltaTime;

                break;
            }
            if (inputMode == InputMode.InControlTouchAnalogue || inputMode == InputMode.Any)
            {
                touchButtonPad.UpdateTouchButtonPad();
            }
            #else
            displacement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
            if (Input.GetButtonDown("Jump"))
            {
                puppetAbilities.Jump();
            }
            #endif

            if (CameraTrack.s_currentCamera != null)
            {
                displacement = MapInputToCamera(displacement, CameraTrack.s_currentCamera.constrainZ);
            }
            else
            {
                displacement = MapInputToCamera(displacement, CameraTrackConstrainZ.Off);
            }
            puppetAbilities.MoveInput(displacement);
        }