public void SetupControls()
        {
            string[] gamePads = Input.GetJoystickNames();
            if (gamePads.Length > 0)
            {
                foreach (string gamepad in gamePads)
                {
                    if (gamepad == "Wireless Controller") // PS4 controls
                    {
                        SetupPS4Controller();
                        //SetupKeyboardControls(); // TEST
                        Debug.Log(gamepad + " detected. Setting PS4 controls.");
                        break;
                    }
                    else if (gamepad == "Controller (Xbox One For Windows)" || gamepad == "Controller (XBOX 360 For Windows)")
                    {
                        SetupXBOX360Controller();
                        Debug.Log(gamepad + " detected. Setting XBOX360 controls.");
                        break;
                    }
                }
            }

            if (!hasGamepad)    // Set Keyboard Controls
            {
                Debug.Log(" No gamepad detected. Setting Keyboard controls.");
                SetupKeyboardControls();
            }

            currentDirection = Dpad.None; // Resets base input direction
        }
Beispiel #2
0
    void PadControl()
    {
        if (Input.GetAxis("PadX") == 0.0)
        {
            control = Dpad.None;
            flag    = true;
        }

        if (Input.GetAxis("PadX") == 1f && flag)
        {
            StartCoroutine("DpadControl", Dpad.Right);
        }
        if (Input.GetAxis("PadX") == -1f && flag)
        {
            StartCoroutine("DpadControl", Dpad.Left);
        }
        if (Input.GetAxis("PadY") == 1f && flag)
        {
            StartCoroutine("DpadControl", Dpad.Up);
        }
        if (Input.GetAxis("PadY") == -1f)
        {
            StartCoroutine("DpadControl", Dpad.Down);
        }
    }
Beispiel #3
0
 private void GenerateDirection()
 {
     // Generate first random direction
     firstDirection    = Random.Range(0, 4);
     direction1.sprite = directionSprites[firstDirection];
     key1 = keyCodes[firstDirection];
     dir1 = dpadCodes[firstDirection];
 }
    IEnumerator DpadControl(Dpad value)
    {
        flag = false;
        yield return new WaitForSeconds(0.15f); // delay it as you wish
        if (value == Dpad.Up) DPadUp();  //** go up
        if (value == Dpad.Down) DPadDown(); //** go down

        StopCoroutine("DpadControl");
    }
Beispiel #5
0
        public bool buttonPressed(Dpad arrow)
        {
            if (joystick == null)
            {
                return(false);
            }
            joystick.Poll();

            int arrowID = (int)arrow;

            return(ArrowPressed(arrowID));
        }
Beispiel #6
0
    IEnumerator DpadControl(Dpad value)
    {
        flag = false;
        yield return(new WaitForSeconds(0.15f)); // delay it as you wish

        if (value == Dpad.Up)
        {
            DPadUp();                    //** go up
        }
        if (value == Dpad.Down)
        {
            DPadDown();                     //** go down
        }
        StopCoroutine("DpadControl");
    }
 public void DpadInputCheck()
 {
     if (Input.GetAxisRaw(dpadAxisX) == -1)
     {
         if (!dpadAxisInUse)
         {
             left             = true;
             currentDirection = Dpad.Left;
             dpadAxisInUse    = true;
         }
     }
     else if (Input.GetAxisRaw(dpadAxisX) == 1)
     {
         if (!dpadAxisInUse)
         {
             right            = true;
             currentDirection = Dpad.Right;
             dpadAxisInUse    = true;
         }
     }
     else if (Input.GetAxisRaw(dpadAxisY) == 1)
     {
         if (!dpadAxisInUse)
         {
             up = true;
             currentDirection = Dpad.Up;
             dpadAxisInUse    = true;
         }
     }
     else if (Input.GetAxisRaw(dpadAxisY) == -1)
     {
         if (!dpadAxisInUse)
         {
             down             = true;
             currentDirection = Dpad.Down;
             dpadAxisInUse    = true;
         }
     }
     else // Resets dpad input
     {
         dpadAxisInUse    = false;
         left             = false;
         up               = false;
         right            = false;
         down             = false;
         currentDirection = Dpad.None;
     }
 }
Beispiel #8
0
    void PadControll()
    {
        if (Input.GetAxis("DPadYP1") == 0.0)
        {
            control = Dpad.None;
            flag    = true;
        }

        if (Input.GetAxis("DPadYP1") == 1f && flag)
        {
            StartCoroutine("DpadControl", Dpad.Up);
        }
        if (Input.GetAxis("DPadYP1") == -1f && flag)
        {
            StartCoroutine("DpadControl", Dpad.Down);
        }
    }
Beispiel #9
0
 public void Update()
 {
     LeftControlStick.Update();
     RightControlStick.Update();
     ButtonA.Update();
     ButtonB.Update();
     ButtonX.Update();
     ButtonY.Update();
     ButtonLB.Update();
     ButtonRB.Update();
     ButtonBack.Update();
     ButtonStart.Update();
     ButtonL3.Update();
     ButtonR3.Update();
     Dpad.Update();
     RightTrigger.Update();
     LeftTrigger.Update();
 }
Beispiel #10
0
        void SetSelected(object selectedButton)
        {
            List <UIView> l = new List <UIView> (this.View.Subviews);

            foreach (UIView view in l)
            {
                if (view is UIPresetButton)
                {
                    if (view.Equals(selectedButton))
                    {
                        selectedPreset = int.Parse(view.AccessibilityIdentifier) - 1;
                        ((UIPresetButton)view).Focused = true;
                    }
                    else
                    {
                        ((UIPresetButton)view).Focused = false;
                    }
                }
            }
            Dpad.Rotated = presets [selectedPreset].DPadRotated;
            Dpad.SetNeedsDisplay();
        }
Beispiel #11
0
    // your methods can go nice and easy here !
    IEnumerator DpadControl(Dpad value)
    {
        flag = false;
        yield return(new WaitForSeconds(0.15f)); // delay it as you wish

        if (value == Dpad.Right)
        {
            derecha();                       //** go right
        }
        if (value == Dpad.Left)
        {
            izquierda();                      //** go left
        }
        if (value == Dpad.Up)
        {
            rotateGroup();                    //** go up
        }
        if (value == Dpad.Down)
        {
            bajar();                     //** go down
        }
        StopCoroutine("DpadControl");
    }
Beispiel #12
0
    // Use this for initialization
    void Start()
    {
        es          = GameObject.Find("EventSystem");
        dpad        = GameObject.Find("DpadOnePiece").GetComponent <Dpad> ();
        anim        = GetComponent <Animator> (); //обращение к аниматору
        myRigidbody = GetComponent <Rigidbody2D> ();
        sfxMan      = FindObjectOfType <SFXManager> ();

        if (!playerExists)
        {
            playerExists = true;
            DontDestroyOnLoad(transform.gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        if (es)
        {
            DontDestroyOnLoad(es);
        }
    }
    void PadControll()
    {
        if(Input.GetAxis("DPadYP1") == 0.0)
        {
            control = Dpad.None;
            flag = true;
        }

        if (Input.GetAxis("DPadYP1") == 1f && flag)
        {
            StartCoroutine("DpadControl", Dpad.Up);
        }
        if (Input.GetAxis("DPadYP1") == -1f && flag)
        {
            StartCoroutine("DpadControl", Dpad.Down);

        }
    }