/// Adds a sample to the BreathAnalyser public void AddSample(float dt, float value) { if (this.isExhaling && value < this.minBreathThreshold) { // Notify the delegate that the exhaled breath is complete bool isBreathGood = this.IsBreathGood(this.breathLength, this.maxBreathLength, this.exhaledVolume, this.maxPressure); ExhalationCompleteEventArgs eventArgs = new ExhalationCompleteEventArgs( this.breathLength, this.breathCount, this.exhaledVolume, isBreathGood); this.OnExhalationComplete(this, eventArgs); // Reset the state this.breathLength = 0; this.exhaledVolume = 0; this.isExhaling = false; this.breathCount++; } else if (value >= this.minBreathThreshold) { this.isExhaling = true; this.exhaledVolume += dt * value; this.breathLength += dt; } }
/// Invoke the event - called whenever exhalation finishes protected virtual void OnExhalationComplete(object sender, ExhalationCompleteEventArgs e) { if (ExhalationComplete != null) { ExhalationComplete(this, e); } }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { if (e.BreathQuality >= 4) { StartCoroutine(Retreat()); } }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { float exhaleTime = FizzyoFramework.Instance.Recogniser.BreathLength; exhaling = false; if (exhaleTime >= minExhaleTime || exhaleTime >= lastBreathLength) { retry = false; breathCount++; breathLengthVals.Add(exhaleTime); } else if (exhaleTime > absMinExhaleTime) { if (!retry) { retry = true; DisplayText.text = "Just one more time please\n Keep going!"; breathLengthVals.Add(exhaleTime); } else { retry = false; breathCount++; breathLengthVals.Add(exhaleTime); } } if (breathCount >= requiredBreaths) { Calibrate(); NextScene(); } }
private void BreathAnalyser_ExhalationComplete(object sender, ExhalationCompleteEventArgs e) { if (e.IsBreathGood) { ScoreManager.Instance.GoodBreathAnimation(); } else { ScoreManager.Instance.BadBreathAnimation(); } }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { float exhaleTime = (Time.realtimeSinceStartup - startTime); exhaling = false; if (exhaleTime >= minExhaleTime) { breathCount++; } if (waitForEndOfBreath && breathCount >= requiredBreaths) { Calibrate(); NextScene(); } }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { float exhaleTime = FizzyoFramework.Instance.Recogniser.BreathLength; exhaling = false; if (exhaleTime >= minExhaleTime) { breathCount++; breathLengthVals.Add(exhaleTime); } if (breathCount >= requiredBreaths) { Calibrate(); NextScene(); } }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { breathing = false; if (e.BreathQuality >= 4) { canJump = true; } powerBar.fillAmount = e.BreathQuality / 4f; HealthControl.deductLife(); if (HealthControl.lives == 0) { FizzyoFramework.Instance.Recogniser.BreathStarted -= OnBreathStarted; FizzyoFramework.Instance.Recogniser.BreathComplete -= OnBreathEnded; } }
void ExhalationCompleteHandler(object sender, ExhalationCompleteEventArgs e) { this.isBad = !breath.IsBreathGood(breath.Breathlength, breath.MaxBreathLength, breath.ExhaledVolume, breath.MaxPressure); BarController.moveBar = false; string pres = ""; foreach (float f in pressures) { pres += f + ","; } pres += 0; pressures.Clear(); string ourPostData = "{\"name\": \"ed\",\"durationSeconds\": " + breath.Breathlength + ",\"pressure\": [" + pres + "] }"; byte[] pData = Encoding.ASCII.GetBytes(ourPostData.ToCharArray()); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Content-Type", "application/json"); headers.Add("Cookie", "Our session cookie"); WWW www = new WWW("https://fury.azurewebsites.net/api/NewReading", pData, headers); }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { breathCount++; //Debug.Log("Breath Quality : " + e.BreathQuality); if (e.BreathQuality >= 2) { score++; } if (e.BreathQuality >= 4) { FizzyoFramework.Instance.Achievements.UnlockAchievement(PerfectBreathUID); } if (breathCount > breaths) { FizzyoFramework.Instance.Achievements.PostScore(score); Application.Quit(); } }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { ZeroGraph(); exhaling = false; }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { breathCount++; if (breaths > 1) { breaths--; breathsToFinish.text = ("Breaths to finish:\n" + (breaths).ToString()); } else { breaths = MainMenu.breathsNo; sessions = sessions - 1; breathsToFinish.text = ("Breaths to finish:\n" + (breaths).ToString()); sessionsToFinish.text = "Sessions to finish:\n" + sessions.ToString(); } print(e.BreathQuality); print(breathCount); //e.BreathQuality; if (e.BreathQuality >= 2) { //breathCount++; //pressureShow.color = new Color32(255, 255, 255, 255); //DisplayScore.score++; //pressureShow.color = new Color32(0, 0, 0, 0); Debug.Log("mediocre breath"); } if (e.BreathQuality >= 4) { //FizzyoFramework.Instance.Achievements.UnlockAchievement(PerfectBreathUID); goodBreath = true; lastGoodBreathTime = Time.time; PopupManager.triggered = false; //PopupManager.triggered = false; FindObjectOfType <AudioManager>().Play("goodBreath"); if (Player.isAlive && goodBreathCount < 5) { goodBreathCount += 1; } Debug.Log("Excellent Breath - Double Points"); pressureShow.color = new Color32(254, 152, 203, 255); //DisplayScore.score *= 2; //pressureShow.color = new Color32(255, 255, 255, 255); } if (breaths <= 0 && sessions <= 0) { FizzyoFramework.Instance.Achievements.PostScore(score); sessionsToFinish.text = "Session Ended"; breathsToFinish.text = "No more breaths left."; //Application.Quit(); } }
private void Br_BreathComplete(object sender, ExhalationCompleteEventArgs e) { Debug.LogFormat("Breath Complete.\n Results: Quality [{0}] : Percentage [{1}] : Breath Full [{2}] : Breath Count [{3}] ", e.BreathQuality, e.BreathPercentage, e.IsBreathFull, e.BreathCount); }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { breaths++; }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { Debug.Log("Current end breath scene: " + SceneManager.GetActiveScene().name); if (unwantedBreathInput && SceneManager.GetActiveScene().name == "Game" && GoodBreathCount.goodBreathCount == -1) { GoodBreathCount.goodBreathCount = 0; } if (!unwantedBreathInput && SceneManager.GetActiveScene().name == "Game") { // Counter breath analyser and calibration problem if (GoodBreathCount.goodBreathCount == -1 || firstBreath) { GoodBreathCount.goodBreathCount = 0; if (firstBreath) { firstBreath = false; } else { firstBreath = true; } } else { Debug.Log("Breath ended"); int bq; if (BadBreathText.badBreath) { // Simulate bad breath since the Fizzyo Breath Analyser is faulty as the breath is always at 4 (best quality) bq = 2; } else { bq = e.BreathQuality; } Debug.Log("Breath quality: " + bq); SoundControl.stopWindSound(); if (!MenuButtonControl.gamePaused) { if (bq <= 2) // Low breath quality { BadBreathText.badBreath = false; BadBreathText.badBreathCloud = true; badBreath++; Debug.Log("Bad Breath Count: " + badBreath); foreach (GameObject dc in GameObject.FindGameObjectsWithTag("DarkCloud")) { Color color = dc.GetComponent <Renderer>().material.color; color.a = 1f; dc.GetComponent <Renderer>().material.color = color; } } if (bq >= 3) // Good breath quality { Debug.Log(GameObject.Find("NameInput")); if (GameObject.Find("NameInput") == null) { GoodBreathText.goodBreath = true; GoodBreathCount.goodBreathCount++; } foreach (GameObject dc in GameObject.FindGameObjectsWithTag("DarkCloud")) { Destroy(dc); } if (bq == 4) { topQualityBreath = true; } } } } } }
void ExhalationCompleteHandler(object sender, ExhalationCompleteEventArgs e) { this.isBad = !breath.IsBreathGood(breath.Breathlength, breath.MaxBreathLength, breath.ExhaledVolume, breath.MaxPressure); BarController.moveBar = false; }