コード例 #1
0
 ///<summary>
 /// Invoke the event - called whenever exhalation finishes
 ///</summary>
 protected virtual void OnExhalationComplete(object sender, ExhalationCompleteEventArgs e)
 {
     if (BreathComplete != null)
     {
         BreathComplete(this, e);
     }
 }
コード例 #2
0
ファイル: BreathRecogniser.cs プロジェクト: leestott/Games
        /// Adds a sample to the BreathAnalyser
        public bool AddSample(float dt, float value)
        {
            if (this.isExhaling && value < this.minBreathThreshold)
            {
                // Notify the delegate that the exhaled breath is complete
                this.isBreathGood = this.IsBreathGood(this.breathLength, this.maxBreathLength, this.exhaledVolume, this.maxPressure);
                ExhalationCompleteEventArgs eventArgs = new ExhalationCompleteEventArgs(
                    this.breathLength,
                    this.breathCount,
                    this.exhaledVolume,
                    this.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.isBreathGood   = false;
                this.isExhaling     = true;
                this.exhaledVolume += dt * value;
                this.breathLength  += dt;
            }
            return(isBreathGood);
        }
コード例 #3
0
 private void Breath_ExhalationComplete(object sender, Fizzyo.ExhalationCompleteEventArgs e)
 {
     ai.breathComplete = true;
     if (e.IsBreathGood)
     {
         Score.UpdateScore();
         great.SetActive(true);
     }
 }
コード例 #4
0
        /// <summary>
        /// Breathing event from the breath recognizer
        /// </summary>
        private void Recogniser_BreathComplete(object sender, ExhalationCompleteEventArgs e)
        {
            if (e.IsBreathFull)
            {
                currentBreathCount += 1;
                lastBreathLength    = e.Breathlength;
                lastMaxPressure     = e.ExhaledVolume;
                lastQuality         = e.BreathQuality;

                //If we have reached the last breath for the set, finish the set
                if (currentBreathCount >= SessionBreathCount)
                {
                    FinishSet();
                }
            }
        }
コード例 #5
0
        ///<summary>
        /// Adds a sample to the BreathAnalyser
        ///</summary>
        /// <param name="dt">Float value indicating the delta time </param>
        /// <param name="value">Float value indicating breath strength </param>
        public void AddSample(float dt, float value)
        {
            if (this.isExhaling && value < this.minBreathThreshold)
            {
                // Notify the delegate that the exhaled breath is complete
                bool isBreathFull  = this.IsBreathFull(this.breathLength, this.maxBreathLength, this.exhaledVolume, this.maxPressure);
                int  breathQuality = GetBreathQuality(this.breathPercentage);
                ExhalationCompleteEventArgs eventArgs = new ExhalationCompleteEventArgs(
                    this.breathLength,
                    this.breathCount,
                    this.exhaledVolume,
                    isBreathFull,
                    this.breathPercentage,
                    breathQuality);

                BreathComplete?.Invoke(this, eventArgs);

                //is.OnExhalationComplete(this, eventArgs);

                // Reset the state
                this.breathLength  = 0;
                this.exhaledVolume = 0;
                this.isExhaling    = false;
                this.breathCount++;
                this.breathPercentage = 0;
            }
            else if (value >= this.minBreathThreshold)
            {
                if (!this.isExhaling)
                {
                    OnExhalationStarted(this);
                }

                this.isExhaling       = true;
                this.exhaledVolume   += dt * value;
                this.breathLength    += dt;
                this.breathPercentage = this.breathLength / (BreathRecogniser.kTollerance * this.maxBreathLength);
            }
        }