private void NormalMyoPose() { Thalmic.Myo.Pose pose = _normalMyo.GetComponent <ThalmicMyo>().pose; if (pose != _normalMyoPose) { Myo_OnPose(pose); _normalMyoPose = pose; } // Access the ThalmicMyo component attached to the Myo game object. }
private void Myo_OnPose(Thalmic.Myo.Pose pose) { ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>(); flamethrow.SetActive(false); hitbox.SetActive(false); if (pose == Pose.Fist) { //thalmicMyo.Vibrate(VibrationType.Medium); if (flameON) { flamethrow.SetActive(true); hitbox.SetActive(true); } else if (gunON) { //instantiate new bullet here GameObject newBullet = Instantiate(bullet, bullet.transform.position, bullet.transform.rotation) as GameObject; newBullet.SetActive(true); newBullet.GetComponent <Rigidbody>().AddForce(bullet.transform.forward * 2000); Physics.IgnoreCollision(transform.root.GetComponent <Collider>(), newBullet.GetComponent <Collider>(), true); Destroy(newBullet, 1.0f); } ExtendUnlockAndNotifyUserAction(thalmicMyo); // Change material when wave in, wave out or double tap poses are made. } else if (pose == Pose.WaveIn) { GetComponent <Renderer>().material = waveInMaterial; flameON = false; gunON = true; ExtendUnlockAndNotifyUserAction(thalmicMyo); } else if (pose == Pose.WaveOut) { GetComponent <Renderer>().material = waveOutMaterial; gunON = false; flameON = true; ExtendUnlockAndNotifyUserAction(thalmicMyo); } if (SceneManager.GetActiveScene().buildIndex == 4) { if (pose == Pose.Fist) { result_fist++; } else if (pose == Pose.WaveIn) { result_win++; } else if (pose == Pose.WaveOut) { result_wout++; } } }
private void GUI_OnPose(Thalmic.Myo.Pose pose) { //ThalmicMyo thalmicMyo = myo.GetComponent<ThalmicMyo>(); if (pose == Pose.FingersSpread) { if (SceneManager.GetActiveScene().buildIndex == 1) { image.gameObject.SetActive(false); flag = 0; Invoke("Fist", .5f); } } if (pose == Pose.Fist) { if (SceneManager.GetActiveScene().buildIndex == 1 && flag == 0) { fist.gameObject.SetActive(false); flag++; flag22 = 0; //Invoke("Wave",5f); } if (SceneManager.GetActiveScene().buildIndex == 2 && flag2 > 0) { fist.gameObject.SetActive(false); } if (SceneManager.GetActiveScene().buildIndex == 3 && flag3 > 0) { fist.gameObject.SetActive(false); } } if (pose == Pose.WaveIn) { if (SceneManager.GetActiveScene().buildIndex == 2 && flag2 == 0 && flag22 > 0) { wave.gameObject.SetActive(false); flag2++; Invoke("Fist", .5f); } } /* * if (SceneManager.GetActiveScene().buildIndex == 1) * { * if (flag == 0) * { * image.gameObject.SetActive(true); * flag++; * } * * if (pose == Pose.FingersSpread) * { * image.gameObject.SetActive(false); * flag = 0; * Invoke("Fist", .5f); * } * * if (pose == Pose.Fist && flag == 0) * { * fist.gameObject.SetActive(false); * flag++; * flag22 = 0; * //Invoke("Wave",5f); * } * } * if (SceneManager.GetActiveScene().buildIndex == 2) * { * if (flag22 == 0) * { * flag2 = 0; * image.gameObject.SetActive(false); * fist.gameObject.SetActive(false); * wave.gameObject.SetActive(true); * flag22++; * } * * if (pose == Pose.WaveIn && flag2 == 0 && flag22 > 0) * { * wave.gameObject.SetActive(false); * flag2++; * Invoke("Fist", .5f); * } * * if (pose == Pose.Fist && flag2 > 0) * { * fist.gameObject.SetActive(false); * } * } * if (SceneManager.GetActiveScene().buildIndex == 3) * { * //timeLabel.SetActive(true); * timeCount -= Time.deltaTime; * // if (Mathf.Approximately(timeCount,Mathf.Epsilon)) * if (timeCount < Mathf.Epsilon) * { * flag++; * new_event2.lv = ScoreManager.score; * SceneManager.LoadScene("main"); * timeCount = 180; * } * timeLabel.text = string.Format("{0:N0}", timeCount); * * if (flag3 == 0) * { * image.gameObject.SetActive(false); * wave.gameObject.SetActive(false); * Invoke("Fist", .5f); * flag3++; * } * if (pose == Pose.Fist && flag3 > 0) * { * fist.gameObject.SetActive(false); * } * } */ }