Пример #1
0
        private bool ButtonCheck(string controlname, ButtonAction bAction)
        {
            Sinput.SinputUpdate();

            for (int i = 0; i < joystickIndeces.Count; i++)
            {
                if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(controlname, (InputDeviceSlot)joystickIndeces[i]))
                {
                    return(true);
                }
                if (bAction == ButtonAction.HELD && Sinput.GetButton(controlname, (InputDeviceSlot)joystickIndeces[i]))
                {
                    return(true);
                }
                if (bAction == ButtonAction.UP && Sinput.GetButtonUp(controlname, (InputDeviceSlot)joystickIndeces[i]))
                {
                    return(true);
                }
                if (bAction == ButtonAction.REPEATING && Sinput.GetButtonDownRepeating(controlname, (InputDeviceSlot)joystickIndeces[i]))
                {
                    return(true);
                }
            }


            return(false);
        }
Пример #2
0
 public bool ButtonCheck(ButtonAction bAction, InputDeviceSlot slot)
 {
     if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(positiveControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(negativeControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.HELD && Sinput.GetButton(positiveControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.HELD && Sinput.GetButton(negativeControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.UP && Sinput.GetButtonUp(positiveControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.UP && Sinput.GetButtonUp(negativeControl, slot))
     {
         return(true);
     }
     return(false);
 }
Пример #3
0
    public void Air_Update()
    {
        if (this.velocity.y > 0)
        {
            PlayAnim(this.objectBeingCarried ? PlayerAnim.Carry_Jump : PlayerAnim.Jump);
        }
        else
        {
            PlayAnim(this.objectBeingCarried ? PlayerAnim.Carry_Fall : PlayerAnim.Fall);
        }

        if (Sinput.GetButtonUp("Jump"))
        {
            velocity.y *= 0.5f;
        }

        if (velocity.y > 0)
        {
            this.currentGravityModifier = this.gravityModifier;
        }
        else
        {
            this.currentGravityModifier = this.fallGravityModifier;
        }

        if (grounded)
        {
            fsm.ChangeState(PlayerState.Ground);
        }
        if (Sinput.GetButtonDown("Jump") && !doubleJumped)
        {
            doubleJumped = true;
            SfxManager.instance.PlaySound(SoundType.JUMP);
            Stretch();
            velocity.y = jumpSpeed;
        }

        if (Sinput.GetButtonDown("Down") && objectBeingCarried && objectBeingCarried.GetComponent <Slime>())
        {
            objectBeingCarried.transform.parent    = null;
            objectBeingCarried.transform.position += Vector3.down * (spriteRenderer.bounds.size.y);

            objectBeingCarried.Throw(0);
            objectBeingCarried = null;
            objectToGrab       = null;
        }


        HandleLeftRightMovement();
        HandleObjectThrow();
        if (!objectBeingCarried)
        {
            CheckGrabs();
        }
    }
Пример #4
0
    void attacks()
    {
        if (Sinput.GetButtonDown("BasicAttack", slot))
        {
            warrior.startBasicAttack();
        }



        if (Sinput.GetButton("SpecialAttack", slot))
        {
            warrior.startSpecialAttack();
        }


        if (Sinput.GetButtonUp("SpecialAttack", slot))
        {
            warrior.endSpecialAttack();
        }
    }
    void CheckInput()
    {
        for (int n = 0; n < buttons.Length; n++)
        {
            if (Sinput.GetButtonDown(buttons[n].name))
            {
                buttons[n].SetState(true);
                buttons[n].events.Pressed?.Invoke();
            }

            if (Sinput.GetButtonUp(buttons[n].name))
            {
                buttons[n].SetState(false);
                buttons[n].events.Released?.Invoke();
            }
        }

        for (int n = 0; n < axes.Length; n++)
        {
            bool state = false;
            for (int i = 0; i < axes[n].names.Length; i++)
            {
                float value = Sinput.GetAxis(axes[n].names[i]);
                state = Mathf.Abs(value) > 0f;
                if (axes[n].sendWhenZeroToo || state)
                {
                    axes[n].AxisValue?.Invoke(value);
                    break;
                }
            }

            bool prevState = axes[n].isPressed;
            axes[n].SetState(state);

            if (state)
            {
                if (!prevState)
                {
                    axes[n].events.Pressed?.Invoke();
                }
            }
            else if (prevState)
            {
                axes[n].events.Released?.Invoke();
            }
        }

        for (int n = 0; n < joysticks.Length; n++)
        {
            bool state = false;
            for (int i = 0; i < joysticks[n].names.Length; i++)
            {
                Vector2 value = Sinput.GetVector(joysticks[n].names[i].x, joysticks[n].names[i].y,
                                                 joysticks[n].normalizationMode != NormalizationMode.NotNormalize);
                state = value.sqrMagnitude > 0f;

                if (state && (joysticks[n].normalizationMode == NormalizationMode.NormalizeWithoutPithagoras))
                {
                    if (Mathf.Abs(value.x) > Mathf.Abs(value.y))
                    {
                        value.x = Mathf.Sign(value.x);
                    }
                    else if (Mathf.Abs(value.x) < Mathf.Abs(value.y))
                    {
                        value.y = Mathf.Sign(value.y);
                    }
                    else
                    {
                        value.x = Mathf.Sign(value.x); value.y = Mathf.Sign(value.y);
                    }
                }

                if (joysticks[n].sendWhenZeroToo || state)
                {
                    joysticks[n].JoystickValue?.Invoke(value);
                    joysticks[n].JoystickMagnitude?.Invoke(value.magnitude);
                    break;
                }
            }

            bool prevState = joysticks[n].isPressed;
            joysticks[n].SetState(state);

            if (state)
            {
                if (!prevState)
                {
                    joysticks[n].events.Pressed?.Invoke();
                }
            }
            else if (prevState)
            {
                joysticks[n].events.Released?.Invoke();
            }
        }

        for (int n = 0; n < buttonStates.Length; n++)
        {
            bool state = true;
            foreach (SButtonState button in buttonStates[n].buttonsState)
            {
                if (Sinput.GetButton(button.name) != button.state)
                {
                    state = false;
                    break;
                }
            }

            bool prevState = buttonStates[n].isPressed;
            buttonStates[n].SetState(state);

            if (state)
            {
                if (!prevState)
                {
                    buttonStates[n].events.Pressed?.Invoke();
                }
            }
            else if (prevState)
            {
                buttonStates[n].events.Released?.Invoke();
            }
        }
    }