void OnApplicationQuit() { if (wiimote != null) { WiimoteManager.Cleanup(wiimote); } }
private void OnCollisionStay(Collision collision) { GameObject obj = collision.gameObject; if (obj.name.Equals("RightHand")) { RightHand = collision.gameObject; } if (TouchingFurniture() && OpenFingersRight <= 2) { transform.SetParent(RightHand.transform.parent.transform); transform.position = new Vector3(vista.transform.position.x, vista.transform.position.y, vista.transform.position.z); GetComponent <Rigidbody>().useGravity = false; GetComponent <Rigidbody>().isKinematic = true; isGrabbed = true; WiimoteManager.FindWiimotes(); controlWii = WiimoteManager.Wiimotes[0]; controlWii.SetupIRCamera(IRDataType.BASIC); if (!transform.name.Equals(nameFurni)) { nameFurni = transform.name; actualScale = transform.localScale; } } }
internal override void OnIncreaseScoreHit(IncreaseScoreType ist, double hpIncrease, HitObject h) { if (h == specialMovementNextFruit) { ResetMovementSpeed(); specialMovementNextFruit = null; } if (ist == IncreaseScoreType.FruitTickTiny || hpIncrease <= 0) { return; } ResetMovementSpeed(); //applies hyperdash checkDistanceToNextFruit(h as HitCircleFruits); WiimoteManager.Rumble(Player.KiaiActive ? 64 : 32); HpBar.KiBulge(); if (HpBar.CurrentHp > 180) { HpBar.KiExplode(); } }
void Update() { if (!_dance.IsPlaying) { if (Input.GetKey("up") || WiimoteManager.GetButton(_wmNum, ButtonData.WMBUTTON_RIGHT)) { _rb.AddForce(transform.forward * _power); } if (Input.GetKey("left") || WiimoteManager.GetButton(_wmNum, ButtonData.WMBUTTON_UP)) { transform.Rotate(Vector3.up, -_rotatePower); } if (Input.GetKey("right") || WiimoteManager.GetButton(_wmNum, ButtonData.WMBUTTON_DOWN)) { transform.Rotate(Vector3.up, _rotatePower); } if (Input.GetKey("down") || WiimoteManager.GetButton(_wmNum, ButtonData.WMBUTTON_LEFT)) { _rb.AddForce(-transform.forward * _power); } if (Input.GetKeyDown("k") || WiimoteManager.GetButton(_wmNum, ButtonData.WMBUTTON_TWO)) { _dance.Begin(); } } else { if (Input.GetKeyDown("k") || WiimoteManager.GetButton(_wmNum, ButtonData.WMBUTTON_ONE)) { _dance.Cancel(); } } }
public void FixedUpdate() { if (wiimoteMode && WiimoteManager.HasWiimote()) { Vector2 vals = wiimoteController.GetIRValues(); float distancePoints = Vector2.Distance(followingPosition, vals); float newPercentFollow; if (distancePoints < distanceToMinFollow) { newPercentFollow = .01f; } else if (distancePoints > distanceToMaxFollow) { newPercentFollow = .5f; } else { newPercentFollow = percentFollowFrame; } float x = followingPosition.x * (1 - newPercentFollow) + vals.x * newPercentFollow; float y = followingPosition.y * (1 - newPercentFollow) + vals.y * newPercentFollow; followingPosition = new Vector2(x, y); } else { followingPosition = Input.mousePosition; } }
IEnumerator searchForWiiControler() { Wiimote newWiimote; WiimoteManager.FindWiimotes(); while (WiimoteManager.Wiimotes.Count() == 0) { yield return(new WaitForSeconds(1.5f)); WiimoteManager.FindWiimotes(); } Debug.Log("found wiiMote"); newWiimote = WiimoteManager.Wiimotes.First(); newWiimote.SendPlayerLED(true, false, false, false); newWiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL); _wiimote = newWiimote; Debug.Log("Assigned wiiMote"); _wiimote.RumbleOn = true; yield return(new WaitForSeconds(0.15f)); _wiimote.RumbleOn = false; //Debug.Log("Calibratin accelerometer, put the controller facing up, and the A button side facing you"); //_wiimote.Accel.CalibrateAccel((AccelCalibrationStep)0); //_wiimote.Accel.CalibrateAccel((AccelCalibrationStep)1); //_wiimote.Accel.CalibrateAccel((AccelCalibrationStep)2); }
void SearchAndInitialize() { WiimoteManager.FindWiimotes(); if (!WiimoteManager.HasWiimote()) { return; } else { playersActive = WiimoteManager.Wiimotes.Count; Debug.Log(playersActive); for (var i = 0; i < WiimoteManager.Wiimotes.Count; i++) { wiimotes.Add(WiimoteManager.Wiimotes[i]); wiimotes[i].SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL); wiimotes[i].SetupIRCamera(IRDataType.EXTENDED); wiimotes[i].SendPlayerLED(i >= 0, i >= 1, i >= 2, i >= 3); ir_pointer_list[i].GetComponent <Image>().color = playerColors[i]; object[] changeColorUI = { i, playerColors[i] }; SendMessage("SetColorPanel", changeColorUI); } for (int i = playerColors.Count - 1; i >= playersActive; i--) { SendMessage("HidePlayerPanel", i); } } }
private void ConnectWiimotes() { WiimoteManager.FindWiimotes(); nPlayers = 0; if (!WiimoteManager.HasWiimote()) { readyToPlay = false; return; } readyToPlay = true; foreach (Wiimote remote in WiimoteManager.Wiimotes) { remote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16); int ret; do { ret = remote.ReadWiimoteData(); } while (ret > 0); remote.SendPlayerLED(nPlayers == 0, nPlayers == 1, nPlayers == 2, nPlayers == 3); nPlayers++; if (remote.current_ext != ExtensionController.NUNCHUCK) { readyToPlay = false; } } }
private void OnClosed(object sender, EventArgs e) { player.Stop(); Wiimote?.StopSound(); waveform.Stop(); WiimoteManager.Cleanup(); }
// ----------------------------------- private bool FindWiimote() { WiimoteManager.FindWiimotes(); if (WiimoteManager.HasWiimote()) { wiimote = WiimoteManager.Wiimotes[0]; wiimote.SendPlayerLED(true, false, false, false); // Mode = acceleration + extensions wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16); // Acceleration //wiimote.Accel.CalibrateAccel(AccelCalibrationStep.A_BUTTON_UP); // IR wiimote.SetupIRCamera(IRDataType.BASIC); Debug.Log("Wiimote found and set up"); return(true); } else { wiimote = null; return(false); } }
// Start is called before the first frame update void Start() { //Find and stor Wiimote ref in variable WiimoteManager.FindWiimotes(); if (WiimoteManager.Wiimotes.Count != 0) { _remote = WiimoteManager.Wiimotes[0]; _remote.SendPlayerLED(false, false, false, false); isConnected = true; //Setup IR Camera if (_remote.SetupIRCamera(IRDataType.BASIC)) { Debug.Log("IR Setup Successful!"); } else { Debug.Log("IR Setup Failed!"); } } else { isConnected = false; Debug.Log("Wiimote not connected!"); } }
void InitWiimotes() { WiimoteManager.FindWiimotes(); // Poll native bluetooth drivers to find Wiimotes int i = 0; foreach (Wiimote remote in WiimoteManager.Wiimotes) { SetWiimoteLeds(remote, i); remote.SetupIRCamera(IRDataType.BASIC); // Basic IR dot position data GameObject face = Instantiate(facePrefab, Vector3.zero, Quaternion.identity) as GameObject; faces.Add(face); animators.Add(face.GetComponent <Animator>()); pitches.Add(basePitch + i * 500); prevShootTimes.Add(0); prevSoundTimes.Add(0); reloadTimes.Add(baseReloadTime); GameObject pointer = Instantiate(pointerPrefab); pointer.GetComponent <SpriteRenderer>().color = Color.HSVToRGB(i * 0.15f % 1, 0.7f, 1); pointers.Add(pointer); ++i; } }
void FinishedWithWiimotes() { foreach (Wiimote remote in WiimoteManager.Wiimotes) { WiimoteManager.Cleanup(remote); } }
//Used to connect / disconnect wii public void ConnectWii() { //If Wiimote is detected if (wiimote != null) { //Disconnect wii WiimoteManager.Cleanup(wiimote); wiimote = null; } else { WiimoteManager.FindWiimotes(); //Find for connected Wii Mote //Check if Manager has wii mote connected if (WiimoteManager.HasWiimote()) { //Assign our variable to the first wiimote = WiimoteManager.Wiimotes[0]; if (wiimote != null) { wiimote.SendPlayerLED(true, false, false, false); } //Setup IR Camera bool IRSetUp = wiimote.SetupIRCamera(IRDataType.BASIC); print(IRSetUp); } } }
// Update is called once per frame void Update() { // If no wii remote is found, return if (!WiimoteManager.HasWiimote()) { return; } // Get the currently connected wii remote wiiMote = WiimoteManager.Wiimotes[0]; Debug.Log("Wii Remote Active"); int ret; do { ret = wiiMote.ReadWiimoteData(); if (ret > 0 && wiiMote.current_ext == ExtensionController.MOTIONPLUS) { Vector3 offset = new Vector3(-wiiMote.MotionPlus.PitchSpeed, wiiMote.MotionPlus.YawSpeed, wiiMote.MotionPlus.RollSpeed) / 95.0f; wiiMotionPlusOffset += offset; Debug.Log(wiiMotionPlusOffset.x); } } while (ret > 0); }
private void Update() { if (!WiimoteManager.HasWiimote()) { return; } wiimote = WiimoteManager.Wiimotes[0]; int ret; do { ret = wiimote.ReadWiimoteData(); } while (ret > 0); if (wiimote.Button.b) { // Retry Loader.Load(Loader.Scene.GameScene); } else if (wiimote.Button.home) { Loader.Load(Loader.Scene.MainMenu); } }
void Start() { WiimoteManager.FindWiimotes(); wiimote = WiimoteManager.Wiimotes[0]; wiimote.SendPlayerLED(true, true, false, false); wiimote.SetupIRCamera(IRDataType.FULL); }
void couleur() { switch (direction) { case "haut": this.gameObject.GetComponent <Renderer>().material.color = new Color(0, 0, 0, 1); break; case "gauche": this.gameObject.GetComponent <Renderer>().material.color = new Color(0, 0, 1, 1); break; case "droite": this.gameObject.GetComponent <Renderer>().material.color = new Color(0, 1, 0, 1); break; case "a": this.gameObject.GetComponent <Renderer>().material.color = new Color(0, 1, 1, 0); break; case "b": this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 1, 1, 1); break; case "+": this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 0, 0); break; case "-": this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 0, 1); break; case "1": this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 1, 0); break; case "2": this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 1, 1); break; case "h": this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 1, 0, 0); break; case "bas": this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 1, 0, 1); break; case "add": WiimoteManager.FindWiimotes(); break; case "rmv": WiimoteManager.Cleanup(wiimote); wiimote = null; break; } // etc }
private void OnApplicationQuit() { // Parcoure toutes les wii remotes foreach (Wiimote remote in WiimoteManager.Wiimotes) { WiimoteManager.Cleanup(remote); } }
void OnApplicationQuit() { Debug.Log("Cleanup"); while (WiimoteManager.Wiimotes.Count > 0) { WiimoteManager.Cleanup(WiimoteManager.Wiimotes[0]); } }
public void Reset() { if (WiimoteManager.HasWiimote()) { WiimoteManager.Cleanup(_wiimote); } _wiimote = null; }
private void OnApplicationQuit() { if (wiimoteRed != null) { WiimoteManager.Cleanup(wiimoteRed); wiimoteRed = null; } }
private void OnApplicationQuit() { if (!(InputManager.inputs && InputManager.inputs.enabled) && wiimote != null) { WiimoteManager.Cleanup(wiimote); wiimote = null; } }
void OnDestroy() { if (wiimote != null) { WiimoteManager.Cleanup(wiimote); wiimote = null; } }
private void OnApplicationQuit() { if (wiimoteBlue != null) { WiimoteManager.Cleanup(wiimoteBlue); wiimoteBlue = null; } }
// 更新処理 void Update() { // 接続されていなかったら終了 if (!WiimoteManager.HasWiimote()) { return; } // 1Pに保存 wm = WiimoteManager.Wiimotes[0]; //int ret; //do //{ // // リモコンの情報を更新 // ret = wm.ReadWiimoteData(); // if (ret > 0 && wm.current_ext == ExtensionController.MOTIONPLUS) // { // Vector3 offset = new Vector3(-wm.MotionPlus.PitchSpeed, // wm.MotionPlus.YawSpeed, // wm.MotionPlus.RollSpeed) / 95f; // Divide by 95Hz (average updates per second from wiimote) // wmpOffset += offset; // //wmModel.rot.Rotate(offset, Space.Self); // } //} while (ret > 0); // ボタン降下情報 //wmModel.a.enabled = wm.Button.a; //wmModel.b.enabled = wm.Button.b; //wmModel.one.enabled = wm.Button.one; //wmModel.two.enabled = wm.Button.two; //wmModel.d_up.enabled = wm.Button.d_up; //wmModel.d_down.enabled = wm.Button.d_down; //wmModel.d_left.enabled = wm.Button.d_left; //wmModel.d_right.enabled = wm.Button.d_right; //wmModel.plus.enabled = wm.Button.plus; //wmModel.minus.enabled = wm.Button.minus; //wmModel.home.enabled = wm.Button.home; // 加速度取得 //Debug.Log(wmAccel =wm.Accel.GetAccelVector()); // 振っているか判定 //wmSwing = wm.Accel.GetSwing(); // Wiiリモコンプラスでなければモデルは回転しない if (wm.current_ext != ExtensionController.MOTIONPLUS) { //wmModel.rot.localRotation = initialRotation; } // モーションプラスがアクティブになっていければ終了 if (!wm.wmp_attached) { return; } }
public void QuitGame() { if (wiiRemote != null) { WiimoteManager.Cleanup(wiiRemote); wiiRemote = null; } Application.Quit(); }
public bool onePressed() { // If no wii remote is found, return if (!WiimoteManager.HasWiimote()) { return(false); } return(wiiMote.Button.one); }
void OnApplicationQuit() { if (wiimote != null) { WiimoteManager.Cleanup(wiimote); wiimote = null; } Write_csv(); }
public void QuitGame() { if (PlateController.wiiRemote != null) { WiimoteManager.Cleanup(PlateController.wiiRemote); PlateController.wiiRemote = null; } Application.Quit(); }