Beispiel #1
0
    public static bool IsReady2Kick2Left(this HeroMover hero, IInput input)
    {
        if (!input.GetButtonDown(ButtonCode.Jump))
        {
            return(false);
        }
        if (!hero.CanKickFromWallR)
        {
            return(false);
        }

        switch (hero.Parameters.KickParams.KickKey)
        {
        case KickKey.DirAgainstWall:
            return(input.GetButton(ButtonCode.Left));

        case KickKey.DirOfWall:
            return(input.GetButton(ButtonCode.Right));

        case KickKey.Any:
            return(true);

        default:
            throw new NotImplementedException();
        }
    }
    /// <summary>
    /// Updates the player input.
    /// </summary>
    void Update()
    {
        if (input == null)
        {
            input = BlitEngine.Instance != null ? BlitEngine.Instance.Input : null;
        }

        if (input != null)
        {
            // Get all player input
            //#if UNITY_EDITOR || UNITY_STANDALONE
            //playerInput.x = input.GetHorizontal ();
            //playerInput.y = input.GetVertical ();
            //#else
            //((Mobile)input).ReadMovement ();
            //playerInput.x = input.GetHorizontal ();
            //playerInput.y = input.GetVertical ();
            //#endif

            playerInput.x = input.GetHorizontal();
            playerInput.y = input.GetVertical();

            playerInput.action = input.GetButton("Y");
            playerInput.slash  = input.GetButton("X");
            playerInput.aim    = input.GetButton("Aim");
            playerInput.dash   = input.GetButton("Dash");
            playerInput.fire   = input.GetButton("Fire");
        }
    }
Beispiel #3
0
 public override HeroState HandleInput(HeroMover hero, IInput input)
 {
     if (input.GetButtonDown(ButtonCode.Jump))
     {
         return(new StateJump());
     }
     if (input.GetButton(ButtonCode.Right) || input.GetButton(ButtonCode.Left))
     {
         return(new StateRun());
     }
     return(this);
 }
Beispiel #4
0
        void UpdateRecord()
        {
            // get input
            if (input == null)
            {
                input = rig.GetInput(hand);
            }

            // if not pressing gesture button stop recording
            if (!input.GetButton(rig.gestureButton))
            {
                state = VRGestureCaptureState.ReadyToCapture;
                if (input.GetButtonUp(rig.gestureButton))
                {
                    StopRecording();
                }
            }

            // if pressed button start recording
            if (input.GetButtonDown(rig.gestureButton) && state == VRGestureCaptureState.ReadyToCapture)
            {
                state = VRGestureCaptureState.Capturing;
                StartRecording();
            }

            // if capturing, capture points
            if (state == VRGestureCaptureState.Capturing)
            {
                CapturePoint();
            }
        }
Beispiel #5
0
 /// <summary>
 /// Gets the input logic by reading from an input object
 /// </summary>
 /// <param name="input">The input object to read from</param>
 /// <returns>Calculated input logic</returns>
 public static InputLogic GetInputLogic(IInput input)
 {
     return(GetInputLogic(
                input.GetAxis("Horizontal"),
                input.GetAxis("Vertical"),
                input.GetButtonDown("Jump"),
                input.GetButton("Jump")));
 }
Beispiel #6
0
    void Update()
    {
        if (!focusNode.Focused)
        {
            return;
        }

        float dt = Time.deltaTime;

        if (input.GetButton(ButtonCode.Up))
        {
            scrollRect.velocity += Vector2.down * scrollForce * dt;
            if (scrollRect.velocity.y < -scrollSpeedMax)
            {
                scrollRect.velocity = new Vector2(0, -scrollSpeedMax);
            }
        }
        else if (input.GetButton(ButtonCode.Down))
        {
            scrollRect.velocity += Vector2.up * scrollForce * dt;
            if (scrollRect.velocity.y > scrollSpeedMax)
            {
                scrollRect.velocity = new Vector2(0, scrollSpeedMax);
            }
        }
        else if (scrollRect.velocity.y > 0)
        {
            scrollRect.velocity += Vector2.down * scrollForce * dt * resistanceRate;
            if (scrollRect.velocity.y < 0)
            {
                scrollRect.velocity = Vector2.zero;
            }
        }
        else if (scrollRect.velocity.y < 0)
        {
            scrollRect.velocity += Vector2.up * scrollForce * dt * resistanceRate;
            if (scrollRect.velocity.y > 0)
            {
                scrollRect.velocity = Vector2.zero;
            }
        }
    }
Beispiel #7
0
    void Update()
    {
        if (!node.Manager.AcceptsInput)
        {
            return;
        }

        if (node.Focused)
        {
            if (input.GetButton(ButtonCode.Right))
            {
                slider.value += speed * Time.deltaTime;
            }

            if (input.GetButton(ButtonCode.Left))
            {
                slider.value -= speed * Time.deltaTime;
            }
        }
    }
Beispiel #8
0
    public override HeroState HandleInput(HeroMover hero, IInput input)
    {
        if (input.GetButtonDown(ButtonCode.Jump))
        {
            return(new StateJump());
        }
        if (!(input.GetButton(ButtonCode.Right) || input.GetButton(ButtonCode.Left)))
        {
            return(new StateWait());
        }

        if (hero.KeyDirection == 1 && !right)
        {
            right = true;
            hero.SetAnim("run");
        }
        if (hero.KeyDirection == -1 && right)
        {
            right = false;
            hero.SetAnim("run");
        }

        return(this);
    }
        Vector3 lastHandPos; // used to calculate velocity of the vrHand to move the gesture gallery

        void FixedUpdateGrabAndMove()
        {
            if (galleryState == GestureGalleryState.Visible)
            {
                if (vrHandInput.GetButton(InputOptions.Button.Trigger2))
                {
                    // ADD UP/DOWN/LEFT/RIGHT FORCE
                    Vector3 velocity     = vrHand.position - lastHandPos;
                    Vector3 velocityFlat = Vector3.ProjectOnPlane(velocity, -transform.forward);
                    velocityFlat *= grabVelocity;
                    galleryRB.AddForce(velocityFlat);

                    // ADD Z SPACE FORCE
                    Vector3 zVelocity = Vector3.ProjectOnPlane(velocity, -transform.right); // flatten left/right
                    zVelocity  = Vector3.ProjectOnPlane(zVelocity, transform.up);           // flatten up/down
                    zVelocity *= grabVelocity;                                              // multiply
                    galleryRB.AddForce(zVelocity);
                }
            }
            lastHandPos = vrHand.position;
        }