void Update() { if (isCalibrationStarted) { LastRecordedPressure = FizzyoDevice.Instance().Pressure(); cumPressure += LastRecordedPressure * Time.deltaTime; // Start a new breath if (CurrentBreathDuration == 0 && LastRecordedPressure > breathStartPressureThreshold) { CurrentBreathDuration += Time.deltaTime; } // Track breath duration else if (CurrentBreathDuration > 0 && LastRecordedPressure > breathStartPressureThreshold) { CurrentBreathDuration += Time.deltaTime; } // End a breath else if (CurrentBreathDuration > 0 && LastRecordedPressure <= breathStartPressureThreshold) { CurrentBreathDuration = 0; } if (LastRecordedPressure > MaximumRecordedPressure) { MaximumRecordedPressure = LastRecordedPressure; } } }
private void HandleCharging() { //TODO replace with a better algorithm float breathingEfficiency = FizzyoDevice.Instance().Pressure(); shootController.SetChargeEfficiency(breathingEfficiency); }
// Update is called once per frame void Update() { //get the pressure value of our fizzyo device communicated as a joystick axis 0-1 blow out -1-0 breath in //float fizzyoVal = Input.GetAxisRaw("Horizontal"); //get the pressure value from our fizzyo device or logged pressure data if useRecordedData is set to true. float pressure = FizzyoDevice.Instance().Pressure(); float destHeight = maxHeight * Mathf.Min((pressure / maxFizzyoPressure), 1); float y = transform.position.y + ((destHeight - transform.position.y) * smoothing); float x = transform.position.x; if (y > 0.1f) { xSpeed += (destXSpeed - xSpeed) * smoothing; x += xSpeed; } else { xSpeed = 0; } transform.position = new Vector3(x, y, transform.position.z); if (FizzyoDevice.Instance().ButtonDown() || Input.GetKeyDown(KeyCode.Space)) { var pos = transform.position; pos.y += 0.5f; GameObject missile = (GameObject)Instantiate(missilePrefab, pos, transform.rotation); } }
// Update is called once per frame void Update() { float pressure = FizzyoDevice.Instance().Pressure(); //float y = transform.position.y + ((pressure * 5) - pressureBar.transform.position.y) * smoothing; //pressureBar.transform.position = new Vector3(pressureBar.transform.position.x,y , pressureBar.transform.position.z); slider.value = (pressure * 5) * smoothing; if (pressure > minPressureThreshold) { maxPressureReading = pressure; blowingStopwatch.Start(); int timeToStart = (int)(countdownToStart - (blowingStopwatch.ElapsedMilliseconds / 1000)); if (timeToStart > 0) { startText.text = "" + timeToStart; } else { //Save the max recorded pressure to use to scale sensor input during gameplay. PlayerPrefs.SetFloat("Max Fizzyo Pressure", maxPressureReading); SceneManager.LoadScene("playGame"); } } else { blowingStopwatch.Stop(); } }
// Update is called once per frame void Update() { float pressure = FizzyoDevice.Instance().Pressure(); Debug.Log(pressure.ToString()); if (pressure <= pressureNotExhaling) { breathPressureCounter = 0; numShotsLeft = maxNumShotsPerBreath; } else if (pressure >= minPressure) { breathPressureCounter++; } }
// Update is called once per frame void Update() { breathAnalyser.AddSample(Time.deltaTime, FizzyoDevice.Instance().Pressure()); FizzyoPressure = FizzyoDevice.Instance().Pressure(); breathVolume = breathAnalyser.ExhaledVolume; // Set Visuals OuterBarFill = breathAnalyser.Breathlength / breathAnalyser.MaxBreathLength; OuterBar.fillAmount = OuterBarFill; InnerBarFill = (float)ScoreManager.Instance.CurrentLevel.ExhalationCount / (float)ScoreManager.Instance.CurrentLevel.ExhalationMax; InnerBar.fillAmount = InnerBarFill; }
// Update is called once per frame void Update() { float pressure = FizzyoDevice.Instance().Pressure(); //animate breath particles //particleSystem.startSpeed = pressure * 500; //particleSystem.startLifetime = pressure * 1; ////set pressure bar height //float destHeight = -20 * pressure; //float y = pressureBar.transform.localPosition.y + ((destHeight - pressureBar.transform.localPosition.y) * smoothing); //pressureBar.transform.localPosition = new Vector3(pressureBar.transform.localPosition.x, y, pressureBar.transform.localPosition.z); if (pressure > minPressureThreshold) { maxPressureReading = pressure; blowingStopwatch.Start(); int timeToStart = (int)(countdownToStart - (blowingStopwatch.ElapsedMilliseconds / 1000)); //Debug.Log("Time To Start = " + timeToStart); if (timeToStart > 0) { //startText.text = "" + timeToStart; } else { //Save the max recorded pressure to use to scale sensor input during gameplay. PlayerPrefs.SetFloat("Max Fizzyo Pressure", maxPressureReading); } } else { blowingStopwatch.Stop(); } Debug.Log("Pressure =" + pressure); }
// Use this for initialization void Start() { pressures = new List <float>(); this.isBad = true; FizzyoDevice insatnce = FizzyoDevice.Instance(); this.gameObject.GetComponent <SpriteRenderer>().enabled = false; if (PlayerPrefs.HasKey("Max Fizzyo Pressure")) { maxFizzyoPressure = PlayerPrefs.GetFloat("Max Fizzyo Pressure"); } breath = new BreathRecogniser(maxFizzyoPressure, 11f); breath.ExhalationComplete += ExhalationCompleteHandler; //apply default material if (lineMaterial == null) { lineMaterial = new Material(Shader.Find("Sprites/Default")); } // Store inital position respawn = this.transform.position; // spawn trajectoryPoints if (trajectoryPointPrefab != null) { for (int i = 0; i < noOfTrajectoryPoints; i++) { GameObject dot = (GameObject)Instantiate(trajectoryPointPrefab); //dot.tag = "trajectoryPoint"; dot.GetComponent <Renderer>().enabled = false; trajectoryPoints.Insert(i, dot); } for (int i = 0; i < noOfTrajectoryPoints; i++) { GameObject dot = (GameObject)Instantiate(trajectoryPointPrefab); //dot.tag = "trajectoryPoint"; dot.GetComponent <Renderer>().enabled = false; oldTrajectoryPoints.Insert(i, dot); } } else { Debug.LogWarning("Trajectory prefab is null. Please choose one."); } // Setup a line renderer if (enableSolidLine) { GameObject m_line_object = new GameObject("line"); m_line_object.AddComponent <LineRenderer>(); m_line = m_line_object.GetComponent <LineRenderer>(); m_line.positionCount = noOfTrajectoryPoints; m_line.colorGradient = lineColour; m_line.numCornerVertices = cornerVerts; m_line.numCapVertices = endVerts; m_line.widthCurve = widthCurve; m_line.textureMode = textureMode; m_line.material = lineMaterial; m_line.material.SetFloat("RepeatX", tileAmount); } }
private bool ShouldClear() { return(FizzyoDevice.Instance().Pressure() >= breathThreshold); }