Example #1
0
 /**
  * Draws the proper animated image to match whether we are breathing or not.
  */
 void OnGUI()
 {
     if (flapScript.isEpiglotisOpen() == true)               // if the epiglottis is open, we're not breathing
     {
         if (timePassed < animationDelay1)                   // check to see which frame to draw
         {
             // draw the first frame if the time is animationDelay1 or less
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), notBreathing[0]);
         }
         else if (timePassed > animationDelay1 && timePassed < animationDelay2)
         {
             // draw the second frame if the tie is animationDelay2 or less but more than animationDelay1
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), notBreathing[1]);
         }
         else if (timePassed > animationDelay2 && timePassed < animationDelay3)
         {
             // draw the second frame if the tie is animationDelay2 or less but more than animationDelay1
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), notBreathing[2]);
         }
         else if (timePassed > animationDelay3 && timePassed < animationDelay4)
         {
             // draw the second frame if the tie is animationDelay2 or less but more than animationDelay1
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), notBreathing[3]);
         }
         else if (timePassed > animationDelay4)
         {
             // if the time is greather than animationDelay2, start back counting from 0
             timePassed = 0f;
         }
     }
     else                                                            // otherwise the epiglottis is closed, so we're breathing
     {
         if (timePassed < animationDelay1)                           // check to see which frame to draw
         {
             // draw the first frame if the time is animationDelay1 or less
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), breathing[0]);
         }
         else if (timePassed > animationDelay1 && timePassed < animationDelay2)
         {
             // draw the second frame if the tie is animationDelay2 or less but more than animationDelay1
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), breathing[1]);
         }
         else if (timePassed > animationDelay2 && timePassed < animationDelay3)
         {
             // draw the second frame if the tie is animationDelay2 or less but more than animationDelay1
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), breathing[2]);
         }
         else if (timePassed > animationDelay3 && timePassed < animationDelay4)
         {
             // draw the second frame if the tie is animationDelay2 or less but more than animationDelay1
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), breathing[3]);
         }
         else if (timePassed > animationDelay4)
         {
             // if the time is greather than animationDelay2, start back counting from 0
             timePassed = 0f;
         }
     }
 }
Example #2
0
 void Update()
 {
     if (epiglottisObject.isEpiglotisOpen())
     {
         Epiglottis.SetActive(false);
         EpiglottisClosed.SetActive(true);
         Uvula.SetActive(false);
         UvulaClosed.SetActive(true);
     }
     else
     {
         Epiglottis.SetActive(true);
         EpiglottisClosed.SetActive(false);
         Uvula.SetActive(true);
         UvulaClosed.SetActive(false);
     }
 }
Example #3
0
    /**
     * Update is called once per frame
     * Finds out if flap is open or not and updates oxygen percentage accordingly
     */
    void Update()
    {
        previousPercent = percent;
        if (config.debugActive)                                 // check if we are using debugger values or reading from the script
        {
            depletionRate = config.oxygenDeplete;               // if necessary get the depletion rate set in the debugger
            gainRate      = config.oxygenGain;                  // if necessary get the gain rate set in the debugger
        }

        if (flap.isEpiglotisOpen() || flap.isCough())           // check if the flap is open or a cough is happening
        {
            percent -= depletionRate * Time.deltaTime;          // if either is the case the oxygen should decrease
        }
        else
        {
            percent += gainRate * Time.deltaTime;                       // otherwise the oxygen should gain
        }

        percent = Mathf.Clamp(percent, 0, 1f);                  // clamp the value between 0 and 1 so the bar doesn't over or under flow

        if (percent > 0.5 && previousPercent < 0.5)
        {
            YayPopup   = true;
            timer      = Time.time;
            AhahaPopup = false;
        }

        if (percent < 0.5 && previousPercent > 0.5)
        {
            AhahaPopup = true;
            timer      = Time.time;
            YayPopup   = false;
        }

        if (YayPopup && Time.time - timer > 2.0f)
        {
            YayPopup = false;
        }

        if (AhahaPopup && Time.time - timer > 2.0f)
        {
            AhahaPopup = false;
        }
    }
Example #4
0
    /**
     * Update is called once per frame
     * Checks for updated values from the debugger. Checks for coughs and coordinates food movement with cough actions.
     */
    void Update()
    {
        //Debug.Log ("Food Time scale:" + Time.timeScale + ", x:" + transform.position.x + ", y:" + transform.position.y);

        // check if we are using the debugger for values, and if we are the food speed is taken from the debugger
        // rather than from the script
        if (debugConfig != null && debugConfig.debugActive)
        {
            foodSpeed = debugConfig.foodSpeed;
        }

        Quaternion q = transform.rotation;

        if (flap.isCough())                                                     // if a cough is currently occuring
        {
            b.enabled = false;
            // reverse the path and set the "corrected" forward path position based on this reversed path
            transform.position = Spline.MoveOnPath(iTweenPath.GetPathReversed("Path"), transform.position, ref reversePosition, coughSpeed, 100, EasingType.Linear, false, false);
            pathPosition       = 1f - reversePosition;

            if (reversePosition > .99f)                                 // check if food near the mouth opening "fell out" of the mouth
            // if it did then we destroy this food and don't allow it to come back
            {
                // track stats
                PlayerPrefs.SetInt("MouthStats_foodLost", PlayerPrefs.GetInt("MouthStats_foodLost") + 1);
                PlayerPrefs.Save();                                     // needs to be called to write playerprefs data to disk

                Destroy(gameObject);                                    // destroy the food that fell out
            }
        }
        else                                                                            // if a cough is not occuring
        {
            if (!flap.isEpiglotisOpen())
            {
                b.enabled = true;
            }
            // move the food down the normal path and set the "corrected" reverse path position based  on this
            transform.position = Spline.MoveOnPath(iTweenPath.GetPath("Path"), transform.position, ref pathPosition, ref q, foodSpeed, 100, EasingType.Linear, false, false);
            reversePosition    = 1f - pathPosition;
        }
        quaternion.Value   = q;
        transform.rotation = quaternion;
    }
Example #5
0
	// Update is called once per frame
	void Update ()
	{
		elapsed = Time.time - startTime;
		swipeCount = flap.getSwipeCounts();
		int foodCounts = flap.getFoodLength();
		if (notPaused) {
			if (elapsed >= 15 && swipeCount <= 0 && foodCounts >= 2) {
//			Debug.Log ("popupstatus is 1");
				swipePopupStatus = 1;
				swipingDown.SetActive (true);
				swipingUp.SetActive (false);
				Time.timeScale = 0;
			} else if (flap.isEpiglotisOpen () && swipeCount <= 1 && elapsed >= 5) {
				if (swipePopupStatus == 1) {
					startTime = Time.time;
					swipePopupStatus = 0;
//				Debug.Log ("popupstatus is 0");
					swipingDown.SetActive (false);
					swipingUp.SetActive (false);
					if (!ego.getGameOver ())
						Time.timeScale = 1;
				} else {
					swipePopupStatus = 2;
//				Debug.Log ("popupstatus is 2");
					swipingDown.SetActive (false);
					swipingUp.SetActive (true);
					Time.timeScale = 0;
				}
			} else {
				swipePopupStatus = 0;
//			Debug.Log ("popupstatus is 0");
				swipingDown.SetActive (false);
				swipingUp.SetActive (false);
				if (!ego.getGameOver ())
					Time.timeScale = 1;
			}
		}
	}