Пример #1
0
    private void WaitForSetup(DualInput input)
    {
        waitForInputTimer += Time.unscaledDeltaTime;

        if (waitForInputTimer > 0.1f)
        {
            for (int i = 1; i <= 2; i++)
            {
                for (int j = 0; j < 19; j++)
                {
                    string  buttonName    = ("Joystick" + i + "Button" + j);
                    KeyCode currentButton = (KeyCode)Enum.Parse(typeof(KeyCode), buttonName);

                    if (Input.GetKeyDown(currentButton))
                    {
                        input.Init(currentButton);
                        waitForInputTimer = 0;
                    }
                }
            }

            for (int i = 1; i < 9; i++)
            {
                string axisName = "axis" + i;
                if (Mathf.Abs(Input.GetAxisRaw(axisName)) > 0.75f)
                {
                    input.Init(axisName, Input.GetAxisRaw(axisName));
                    waitForInputTimer = 0;
                }
            }
        }
    }
Пример #2
0
 protected void RefreshButton(DualInput input)
 {
     if (input == InputManager.Instance.GetInput(inputName))
     {
         UpdateButtonName();
     }
 }
Пример #3
0
    void Start()
    {
        waitForInputTimer = 0;

        Up    = new DualInput("Up");
        Down  = new DualInput("Down");
        Left  = new DualInput("Left");
        Right = new DualInput("Right");

        CUp    = new DualInput("CUp");
        CDown  = new DualInput("CDown");
        CLeft  = new DualInput("CLeft");
        CRight = new DualInput("CRight");

        Shield  = new DualInput("Shield");
        Jump    = new DualInput("Jump");
        Jump2   = new DualInput("Jump2");
        Attack  = new DualInput("Attack");
        Special = new DualInput("Special");
        Grab    = new DualInput("Grab");

        Pause = new DualInput("Pause");

        TapJump = PlayerPrefs.GetInt("TapJump") == 1 ? true : false;

        Up.SetDefault(KeyCode.W);
        Down.SetDefault(KeyCode.S);
        Right.SetDefault(KeyCode.D);
        Left.SetDefault(KeyCode.A);

        Attack.SetDefault(KeyCode.LeftControl);
        Jump.SetDefault(KeyCode.Space);
        Shield.SetDefault(KeyCode.LeftShift);
        Special.SetDefault(KeyCode.LeftAlt);
        CUp.SetDefault(KeyCode.UpArrow);
        CDown.SetDefault(KeyCode.DownArrow);
        CLeft.SetDefault(KeyCode.LeftArrow);
        CRight.SetDefault(KeyCode.RightArrow);

        Inputs = new List <DualInput>();
        Inputs.Add(Left);
        Inputs.Add(Right);
        Inputs.Add(Up);
        Inputs.Add(Down);

        Inputs.Add(CLeft);
        Inputs.Add(CRight);
        Inputs.Add(CUp);
        Inputs.Add(CDown);

        Inputs.Add(Shield);
        Inputs.Add(Jump);
        Inputs.Add(Jump2);
        Inputs.Add(Attack);
        Inputs.Add(Special);
        Inputs.Add(Grab);

        Inputs.Add(Pause);
    }
Пример #4
0
 private void CheckIfBuffered(DualInput di)
 {
     if (di.GetButtonDown())
     {
         BufferedInput = di;
         bufferTimer   = bufferFrames;
     }
 }
Пример #5
0
    private void FixedUpdate()
    {
        oldDirection = Direction;

        if (Smash != Vector2.zero)
        {
            smashBufferTimer--;
        }

        if (smashBufferTimer <= 0)
        {
            Smash = Vector2.zero;
        }

        Direction = new Vector2(-Left.GetAxis() + Right.GetAxis(), Up.GetAxis() - Down.GetAxis());
        CStick    = new Vector2(-CLeft.GetAxis() + CRight.GetAxis(), CUp.GetAxis() - CDown.GetAxis());

        /*
         * if (Mathf.Abs((Direction - oldDirection).magnitude) > 0.25f)
         * {
         *  if (Mathf.Abs(Direction.x) > 0.75f)
         *  {
         *      smashBufferTimer = smashBufferFrames;
         *      Smash.x = Mathf.Sign(Direction.x);
         *  }
         *
         *  if (Mathf.Abs(Direction.y) > 0.75f)
         *  {
         *      Smash.y = Mathf.Sign(Direction.y);
         *      smashBufferTimer = smashBufferFrames;
         *  }
         * }
         */

        if (Mathf.Abs(oldDirection.x - Direction.x) > 0.25f && Mathf.Abs(Direction.x) > 0.5f)
        {
            Smash.x          = Mathf.Sign(Direction.x);
            smashBufferTimer = smashBufferFrames;
        }

        if (Mathf.Abs(oldDirection.y - Direction.y) > 0.25f && Mathf.Abs(Direction.y) > 0.5f)
        {
            Smash.y          = Mathf.Sign(Direction.y);
            smashBufferTimer = smashBufferFrames;
        }


        if (BufferedInput != null)
        {
            bufferTimer--;
        }

        if (bufferTimer <= 0)
        {
            BufferedInput = null;
        }
    }
Пример #6
0
 public static void ClearBuffer()
 {
     BufferedInput = null;
     Smash         = Vector2.zero;
 }