コード例 #1
0
    private void HandleControls()
    {
        if (controlBlock)
        {
            return;
        }

        if (hitActionButton)
        {
            charState = CharacterState.HEAD_BONK;
            if (!actionButtonNotPressed)
            {
                actionButtonNotPressed = true;
                golpe.Play();
            }
        }
        else
        {
            actionButtonNotPressed = false;
        }

        AnalogueInput stick = ProInput.GlobalActionStick;

        if (stick.IsActive() && !hitActionButton)
        {
            float stickAngle = stick.Angle;
            float stickCos   = Mathf.Cos(stickAngle);
            float stickSin   = Mathf.Sin(stickAngle);

            float realJoystickPress = (stick.Distance - stick.DeadZone) / (1 - stick.DeadZone);
            if (realJoystickPress > JOYSTICK_RUN)
            {
                charX += stickCos * CHAR_SPEED_RUN * deltaRun;
                charZ -= stickSin * CHAR_SPEED_RUN * deltaRun;
            }
            else
            {
                charX += stickCos * CHAR_SPEED * deltaRun;
                charZ -= stickSin * CHAR_SPEED * deltaRun;
            }
            charState    = CharacterState.WALK;
            pasos.volume = .5f;
        }
        else
        {
            pasos.volume = 0;
        }

        if (!stick.IsActive() && !hitActionButton)
        {
            charState = CharacterState.IDLE;
        }
    }
コード例 #2
0
 /**NOT SUPPORTED*/
 override public void FromAnalogueInput(AnalogueInput joystick)
 {
     throw new System.NotSupportedException("DpadButton is exclusively modified through the Button class");
 }
コード例 #3
0
ファイル: InputReceiver.cs プロジェクト: fernhw/GMTKJam2020
    public static void Parse(Deltas delta, World world, ref InputsManager controls)
    {
        // Proprietary input system
        ProInput.UpdateInput(delta.mainDelta, true);

        AnalogueInput joystick = ProInput.GlobalActionStick;

        if (joystick.IsActive())
        {
            float stickAngle = joystick.Angle;
            float stickCos   = Mathf.Cos(stickAngle);
            float stickSin   = Mathf.Sin(stickAngle);

            float realJoystickPress = (joystick.Distance - joystick.DeadZone) / (1 - joystick.DeadZone);

            if (stickCos > joystick.DeadZone)
            {
                controls.movement.x = 1;
            }

            if (stickCos < -joystick.DeadZone)
            {
                controls.movement.x = -1;
            }

            //controls.movement.x = stickCos;
            controls.movement.y = stickSin;
        }
        else
        {
            controls.movement.x = 0;
            controls.movement.y = 0;
        }


        // mouse pointer x and y
        Vector3 inputMouseRaw = Input.mousePosition;

        // Needed hack
        inputMouseRaw.z = 10;
        Vector3 mouse = world.cam.camera.ScreenToViewportPoint(inputMouseRaw);

        controls.pointer.x = mouse.x;
        controls.pointer.y = mouse.y;


        // You have to stop holding the action button to press it
        // For constant fire
        if (!controls.holdingActionButton)
        {
            controls.actionButton = ProInput.A;
        }
        if (ProInput.A)
        {
            controls.holdingActionButton = true;
        }
        else
        {
            controls.holdingActionButton = false;
        }


        // You have to stop holding the action button to press it
        // For constant fire
        if (!controls.holdingQuackButton)
        {
            controls.quak = ProInput.B;
        }
        if (ProInput.B)
        {
            controls.holdingQuackButton = true;
        }
        else
        {
            controls.holdingQuackButton = false;
        }
    }