Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        int   id = myController.GetID();
        float x  = UnsignedCmp.Max(Input.GetAxis("Horizontal" + myController.GetID()), XCI.GetAxis(XboxAxis.LeftStickX, id));
        float y  = UnsignedCmp.Max(Input.GetAxis("Vertical" + myController.GetID()), XCI.GetAxis(XboxAxis.LeftStickY, id));

        destination = (new Vector2(x, y).normalized) * speed;
    }
Exemple #2
0
 void Update()
 {
     for (int i = 0; i < 4; i++)
     {
         int j = i + 1;
         if (Input.GetButtonDown("Fire" + j) || XCI.GetButtonDown(XboxButton.A, j))
         {
             if (players [i].PressOK())
             {
                 TryNext();
             }
             players [i].Colorise(possibleColors [players [i].colorIndex]);
         }
         if (Input.GetButtonDown("Cancel" + j) || XCI.GetButtonDown(XboxButton.B, j) || XCI.GetButtonDown(XboxButton.X, j))
         {
             if (players [i].PressBack())
             {
                 TryBack();
             }
             players [i].Colorise(possibleColors [players [i].colorIndex]);
         }
         if (players [i].status == playerState.JOINED)
         {
             float y = UnsignedCmp.Max(Input.GetAxis("Vertical" + j), XCI.GetAxis(XboxAxis.LeftStickY, j));
             if (Mathf.Abs(y) < 0.5f)
             {
                 up [i] = down [i] = false;
             }
             else if (y <= -0.5f)
             {
                 audioSource.PlayOneShot(chooseClip);
                 if (!up [i])
                 {
                     // player was not pressing UP before
                     players [i].colorIndex = NextColorIndexFrom(players [i].colorIndex, true);
                     players [i].Colorise(possibleColors [players [i].colorIndex]);
                 }
                 up [i]   = true;
                 down [i] = false;
             }
             else if (y >= 0.5f)
             {
                 audioSource.PlayOneShot(chooseClip);
                 if (!down [i])
                 {
                     // player was not pressing DOWN before
                     players [i].colorIndex = NextColorIndexFrom(players [i].colorIndex, false);
                     players [i].Colorise(possibleColors [players [i].colorIndex]);
                 }
                 up [i]   = false;
                 down [i] = true;
             }
         }
     }
 }