private void HandleInputUpdate(ulong updateTick, float deltaTime) { CheckForPauseButton(); int count = InputManager.Devices.Count; for (int i = 0; i < count; i++) { InputDevice inputDevice = InputManager.Devices[i]; inputDevice.Vibrate(inputDevice.LeftTrigger, inputDevice.RightTrigger); } }
// Map controllers to players void buttonClicked(InputDevice player,int playerIndex) { player.Vibrate(.2f, .2f); StartCoroutine("vibrateControllerStop", player); if (player.Action2.WasPressed) { buttonList[0].GetComponent<Image>().color = new Color32(50, 50, 50, 255); buttonList[0].GetComponentInChildren<Text>().enabled = false; buttonsSet[0] = true; Main.S.carTop.GetComponent<ArcadeVehicle>().first = playerIndex; } else if (player.Action1.WasPressed) { buttonList[1].GetComponent<Image>().color = new Color32(50, 50, 50, 255); buttonList[1].GetComponentInChildren<Text>().enabled = false; buttonsSet[1] = true; Main.S.carTop.GetComponent<ArcadeVehicle>().second = playerIndex; } else if (player.Action4.WasPressed) { buttonList[2].GetComponent<Image>().color = new Color32(50, 50, 50, 255); buttonList[2].GetComponentInChildren<Text>().enabled = false; buttonsSet[2] = true; Main.S.carBottom.GetComponent<ArcadeVehicle>().first = playerIndex; } else if (player.Action3.WasPressed) { buttonList[3].GetComponent<Image>().color = new Color32(50, 50, 50, 255); buttonList[3].GetComponentInChildren<Text>().enabled = false; buttonsSet[3] = true; Main.S.carBottom.GetComponent<ArcadeVehicle>().second = playerIndex; } countSet++; // If all connected devices have chosen a team prompt for start of game if (countSet == InputManager.Devices.Count) { text.GetComponent<Text>().text = "Press Any Button To Continue"; for (int i = 0; i < buttonsSet.Count; i++) { if (buttonsSet[i] == false) { if (i == 0 && buttonsSet[i + 1] == true) { Main.S.carTop.GetComponent<ArcadeVehicle>().first = Main.S.carTop.GetComponent<ArcadeVehicle>().second; } else if (i == 1 && buttonsSet[i - 1] == true) { Main.S.carTop.GetComponent<ArcadeVehicle>().second = Main.S.carTop.GetComponent<ArcadeVehicle>().first; } else if (i == 2 && buttonsSet[i + 1] == true) { Main.S.carBottom.GetComponent<ArcadeVehicle>().first = Main.S.carBottom.GetComponent<ArcadeVehicle>().second; } else if (i == 3 && buttonsSet[i - 1] == true) { Main.S.carBottom.GetComponent<ArcadeVehicle>().second = Main.S.carBottom.GetComponent<ArcadeVehicle>().first; } } } cooldown = Time.realtimeSinceStartup; } }
IEnumerator vibrateControllerStop(InputDevice player) { float pauseEndTime = Time.realtimeSinceStartup + .2f; while (Time.realtimeSinceStartup < pauseEndTime) { yield return 0; } player.Vibrate(0, 0); }