void Awake () { gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>(); gameController.onGameLose += MoveLock; gameController.onGameWin += MoveLock; gameController.onGameRestart += Start; soundmanager = GameObject.Find ("SoundManager").GetComponent<SoundClip>(); psMoveWrapper = gameObject.GetComponent<PSMoveWrapper>(); psMoveWrapper.Connect(); // TODO: activate this line if the player can't stop reaching the monster //gameController.onGamePlayStart += MoveLockThenUnlock; }
void Awake() { gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); gameController.onGameLose += MoveLock; gameController.onGameWin += MoveLock; gameController.onGameRestart += Start; soundmanager = GameObject.Find("SoundManager").GetComponent <SoundClip>(); psMoveWrapper = gameObject.GetComponent <PSMoveWrapper>(); psMoveWrapper.Connect(); // TODO: activate this line if the player can't stop reaching the monster //gameController.onGamePlayStart += MoveLockThenUnlock; }
public void Awake() { // Check if we are in calibration scene ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI; if(ruisNGUIMenu != null) { if(ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration) { this.enablePSMove = ruisNGUIMenu.originalEnablePSMove; this.enableKinect = ruisNGUIMenu.originalEnableKinect; this.enableKinect2 = ruisNGUIMenu.originalEnableKinect2; this.jumpGestureEnabled = ruisNGUIMenu.originalEnableJumpGesture; this.enableRazerHydra = ruisNGUIMenu.originalEnableHydra; this.kinectDriftCorrectionPreferred = ruisNGUIMenu.originalKinectDriftCorrection; this.PSMoveIP = ruisNGUIMenu.originalPSMoveIP; this.PSMovePort = ruisNGUIMenu.originalPSMovePort; } } wandDelayed = new bool[4] {moveWand0, moveWand1, moveWand2, moveWand3}; disabledWands = new List<GameObject>(); if (!Application.isEditor || loadFromTextFileInEditor) { if (!Import(filename)) { Debug.LogError("Could not load input configuration file. Creating file based on current settings."); Export(filename); } } if (!enableKinect) { Debug.Log("Kinect is disabled from RUISInputManager."); GetComponentInChildren<RUISKinectDisabler>().KinectNotAvailable(); } else { GetComponentInChildren<NIPlayerManagerCOMSelection>().m_MaxNumberOfPlayers = maxNumberOfKinectPlayers; } psMoveWrapper = GetComponentInChildren<PSMoveWrapper>(); if (enablePSMove) { if (psMoveWrapper && connectToPSMoveOnStartup) { StartCoroutine("CheckForMoveConnection"); psMoveWrapper.Connect(PSMoveIP, PSMovePort); psMoveWrapper.enableDefaultInGameCalibrate = enableMoveCalibrationDuringPlay; if(delayedWandActivation) { string names = ""; foreach (RUISPSMoveWand moveController in FindObjectsOfType(typeof(RUISPSMoveWand)) as RUISPSMoveWand[]) { if( moveController != null && moveController.controllerId < 4 && moveController.controllerId >= 0 && wandDelayed[moveController.controllerId] ) { // Make sure that the found RUISPSMoveWand is not under InputManager->MoveControllers GameObject if( moveController.gameObject.transform.parent == null || moveController.gameObject.transform.parent.parent == null || ( moveController.gameObject.transform.parent.GetComponent<RUISInputManager>() == null && moveController.gameObject.transform.parent.parent.GetComponent<RUISInputManager>() == null)) { moveController.gameObject.SetActive(false); disabledWands.Add(moveController.gameObject); if(names.Length > 0) names += ", "; names += moveController.gameObject.name; } } } if(disabledWands.Count > 0) { Debug.Log( "DELAYED CONTROLLER ACTIVATION INITIALIZATION: Following objects are disabled: " + names + ". If their input devices are found, they will be re-activated in " + delayTime + " seconds, as configured in RUISInputManager."); StartCoroutine("DelayedWandActivation"); } } } } else { Debug.Log("PS Move is disabled from RUISInputManager."); //psMoveWrapper.gameObject.SetActiveRecursively(false); } sixense = FindObjectOfType(typeof(SixenseInput)) as SixenseInput; if(enableRazerHydra) { if(sixense == null) Debug.LogError( "Could not connect with Razer Hydra! Your RUIS InputManager settings indicate " + "that you want to use Razer Hydra, but this scene does not have a gameobject " + "with SixenseInput script, which is required. Add SixenseInput prefab " + "into the scene."); // IsBaseConnected() seems to crash Unity at least when called here // else if(!SixenseInput.IsBaseConnected(0)) // TODO: *** Apparently there can be multiple bases // Debug.LogError( "Could not connect with Razer Hydra! Check the USB connection."); } else { if(sixense != null) { sixense.gameObject.SetActive(false); Debug.Log( "Razer Hydra is disabled from RUISInputManager. Disabling object " + sixense.name + " that has the SixenseInput script."); } } DisableUnneededMoveWands(); DisableUnneededRazerHydraWands(); }
void OnGUI() { GUI.Label(new Rect(10, 10, 150, 100), "PS Move count : " + psMoveWrapper.moveCount); GUI.Label(new Rect(140, 10, 150, 100), "PS Nav count : " + psMoveWrapper.navCount); if (GUI.Button(new Rect(20, 40, 100, 35), connectStr)) { if (connectStr == "Connect") { psMoveWrapper.Connect(); if (psMoveWrapper.isConnected) { connectStr = "Disconnect"; } } else { psMoveWrapper.Disconnect(); connectStr = "Connect"; Reset(); } } if (psMoveWrapper.isConnected) { //camera stream on/off if (GUI.Button(new Rect(5, 80, 130, 35), cameraStr)) { if (cameraStr == "Camera Switch On") { psMoveWrapper.CameraFrameResume(); cameraStr = "Camera Switch Off"; } else { psMoveWrapper.CameraFramePause(); cameraStr = "Camera Switch On"; } } //color and rumble for move number 0 if (psMoveWrapper.moveConnected[0]) { //Set Color and Track GUI.Label(new Rect(300, 50, 200, 20), "R,G,B are floats that fall in 0 ~ 1"); GUI.Label(new Rect(260, 20, 20, 20), "R"); rStr = GUI.TextField(new Rect(280, 20, 60, 20), rStr); GUI.Label(new Rect(350, 20, 20, 20), "G"); gStr = GUI.TextField(new Rect(370, 20, 60, 20), gStr); GUI.Label(new Rect(440, 20, 20, 20), "B"); bStr = GUI.TextField(new Rect(460, 20, 60, 20), bStr); if (GUI.Button(new Rect(550, 30, 160, 35), "SetColorAndTrack")) { try { float r = float.Parse(rStr); float g = float.Parse(gStr); float b = float.Parse(bStr); psMoveWrapper.SetColorAndTrack(0, new Color(r, g, b)); } catch (Exception e) { Debug.Log("input problem"); } } //Rumble rumbleStr = GUI.TextField(new Rect(805, 20, 40, 20), rumbleStr); GUI.Label(new Rect(800, 50, 200, 20), "0 ~ 19"); if (GUI.Button(new Rect(870, 30, 100, 35), "Rumble")) { try { int rumbleValue = int.Parse(rumbleStr); psMoveWrapper.SetRumble(0, rumbleValue); } catch (Exception e) { Debug.Log("input problem"); } } } //move controller information for (int i = 0; i < PSMoveWrapper.MAX_MOVE_NUM; i++) { if (psMoveWrapper.moveConnected[i]) { string display = "PS Move #" + i + "\nPosition:\t\t" + psMoveWrapper.position[i] + "\nVelocity:\t\t" + psMoveWrapper.velocity[i] + "\nAcceleration:\t\t" + psMoveWrapper.acceleration[i] + "\nOrientation:\t\t" + psMoveWrapper.orientation[i] + "\nAngular Velocity:\t\t" + psMoveWrapper.angularVelocity[i] + "\nAngular Acceleration:\t\t" + psMoveWrapper.angularAcceleration[i] + "\nHandle Position:\t\t" + psMoveWrapper.handlePosition[i] + "\nHandle Velocity:\t\t" + psMoveWrapper.handleVelocity[i] + "\nHandle Acceleration:\t\t" + psMoveWrapper.handleAcceleration[i] + "\n" + "\nTrigger Value:\t\t" + psMoveWrapper.valueT[i] + "\nButtons:\t\t" + GetButtonStr(i) + "\nSphere Color:\t\t" + psMoveWrapper.sphereColor[i] + "\nIs Tracking:\t\t" + psMoveWrapper.isTracking[i] + "\nTracking Hue:\t\t" + psMoveWrapper.trackingHue[i]; GUI.Label(new Rect(10 + 650 * (i / 2), 120 + 310 * (i % 2), 300, 400), display); } } for (int j = 0; j < PSMoveWrapper.MAX_NAV_NUM; j++) { if (psMoveWrapper.navConnected[j]) { string navDisplay = "PS Nav #" + j + "\nAnalog X:\t\t" + psMoveWrapper.valueNavAnalogX[j] + "\nAnalog Y:\t\t" + psMoveWrapper.valueNavAnalogY[j] + "\nL2 Value:\t\t" + psMoveWrapper.valueNavL2[j] + "\nButtons:\t\t" + GetNavButtonStr(j); GUI.Label(new Rect(400, 100 + 95 * j, 150, 95), navDisplay); } } } }
void Start() { controllers[0].transform.rotation = Quaternion.LookRotation(Vector3.up); psMoveWrapper.Connect(); }
public void Awake() { // Check if we are in calibration scene ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI; if (ruisNGUIMenu != null) { if (ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration) { this.enablePSMove = ruisNGUIMenu.originalEnablePSMove; this.enableKinect = ruisNGUIMenu.originalEnableKinect; this.enableKinect2 = ruisNGUIMenu.originalEnableKinect2; this.jumpGestureEnabled = ruisNGUIMenu.originalEnableJumpGesture; this.enableRazerHydra = ruisNGUIMenu.originalEnableHydra; this.kinectDriftCorrectionPreferred = ruisNGUIMenu.originalKinectDriftCorrection; this.PSMoveIP = ruisNGUIMenu.originalPSMoveIP; this.PSMovePort = ruisNGUIMenu.originalPSMovePort; } } wandDelayed = new bool[4] { moveWand0, moveWand1, moveWand2, moveWand3 }; disabledWands = new List <GameObject>(); if (!Application.isEditor || loadFromTextFileInEditor) { if (!Import(filename)) { Debug.LogError("Could not load input configuration file. Creating file based on current settings."); Export(filename); } } if (!enableKinect) { Debug.Log("Kinect is disabled from RUISInputManager."); GetComponentInChildren <RUISKinectDisabler>().KinectNotAvailable(); } else { GetComponentInChildren <NIPlayerManagerCOMSelection>().m_MaxNumberOfPlayers = maxNumberOfKinectPlayers; } psMoveWrapper = GetComponentInChildren <PSMoveWrapper>(); if (enablePSMove) { if (psMoveWrapper && connectToPSMoveOnStartup) { StartCoroutine("CheckForMoveConnection"); psMoveWrapper.Connect(PSMoveIP, PSMovePort); psMoveWrapper.enableDefaultInGameCalibrate = enableMoveCalibrationDuringPlay; if (delayedWandActivation) { string names = ""; foreach (RUISPSMoveWand moveController in FindObjectsOfType(typeof(RUISPSMoveWand)) as RUISPSMoveWand[]) { if (moveController != null && moveController.controllerId < 4 && moveController.controllerId >= 0 && wandDelayed[moveController.controllerId]) { // Make sure that the found RUISPSMoveWand is not under InputManager->MoveControllers GameObject if (moveController.gameObject.transform.parent == null || moveController.gameObject.transform.parent.parent == null || (moveController.gameObject.transform.parent.GetComponent <RUISInputManager>() == null && moveController.gameObject.transform.parent.parent.GetComponent <RUISInputManager>() == null)) { moveController.gameObject.SetActive(false); disabledWands.Add(moveController.gameObject); if (names.Length > 0) { names += ", "; } names += moveController.gameObject.name; } } } if (disabledWands.Count > 0) { Debug.Log("DELAYED CONTROLLER ACTIVATION INITIALIZATION: Following objects are disabled: " + names + ". If their input devices are found, they will be re-activated in " + delayTime + " seconds, as configured in RUISInputManager."); StartCoroutine("DelayedWandActivation"); } } } } else { Debug.Log("PS Move is disabled from RUISInputManager."); //psMoveWrapper.gameObject.SetActiveRecursively(false); } sixense = FindObjectOfType(typeof(SixenseInput)) as SixenseInput; if (enableRazerHydra) { if (sixense == null) { Debug.LogError("Could not connect with Razer Hydra! Your RUIS InputManager settings indicate " + "that you want to use Razer Hydra, but this scene does not have a gameobject " + "with SixenseInput script, which is required. Add SixenseInput prefab " + "into the scene."); } // IsBaseConnected() seems to crash Unity at least when called here // else if(!SixenseInput.IsBaseConnected(0)) // TODO: *** Apparently there can be multiple bases // Debug.LogError( "Could not connect with Razer Hydra! Check the USB connection."); } else { if (sixense != null) { sixense.gameObject.SetActive(false); Debug.Log("Razer Hydra is disabled from RUISInputManager. Disabling object " + sixense.name + " that has the SixenseInput script."); } } DisableUnneededMoveWands(); DisableUnneededRazerHydraWands(); }
void Start() { OpenNISettingsManager settingsManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (settingsManager.UserGenrator == null || !settingsManager.UserGenrator.Valid) { Debug.LogError("Could not start OpenNI! Check your Kinect connection."); kinectAvailable = false; settingsManager.transform.parent.gameObject.SetActive(false); userViewer.gameObject.SetActive(false); } else { sceneAnalyzer = new OpenNI.SceneAnalyzer((FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager).CurrentContext.BasicContext); sceneAnalyzer.StartGenerating(); } RUISMenu ruisMenu = FindObjectOfType(typeof(RUISMenu)) as RUISMenu; if (ruisMenu) { usePSMove = ruisMenu.enablePSMove; psMoveIP = ruisMenu.psMoveIP; psMovePort = ruisMenu.psMovePort; } if (usePSMove) { StartCoroutine("CheckForMoveConnection"); psMoveWrapper.ipAddress = psMoveIP; psMoveWrapper.port = psMovePort; psMoveWrapper.Connect(psMoveIP, psMovePort); psMoveWrapper.CameraFrameResume(4); } else { (FindObjectOfType(typeof(CameraTiltTextUpdater)) as CameraTiltTextUpdater).gameObject.SetActive(false); } //moveController.gameObject.SetActiveRecursively(false); /*psEyeTexture = new Texture2D(640, 480, TextureFormat.ARGB32, false); * * psEyeGUITexture.texture = psEyeTexture; * * psMoveWrapper.CameraFrameResume();*/ calibrationSpheres = new List <GameObject>(); SetCalibrationReviewShowing(false); /*List<Vector3> testList = new List<Vector3>(); * testList.Add(Vector3.right * 1.5f); * testList.Add(new Vector3(0.5f, 1f, 0.5f)); * testList.Add(Vector3.forward * 2.0f); * Orthonormalize(ref testList); * foreach (Vector3 v in testList) * { * Debug.Log(v); * }*/ }