Ejemplo n.º 1
0
 private void OnTriggerEnter(Collider other)
 {
     if (health != 0)
     {
         if (other.tag == "Obstacle" && !invincible)
         {
             gameObject.GetComponent <AudioSource>().Play();
             Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation);
             gameObject.GetComponent <SpriteRenderer>().color = Color.red;
             Destroy(other.gameObject);
             health--;
             invincible = true;
             if (health == 0)
             {
                 invincibility_timer = 4.5f;
                 score -= 50;
                 Instantiate(score_effect, gameObject.transform.position, gameObject.transform.rotation).GetComponent <TextMesh>().text = "-50";
             }
             else
             {
                 score -= 25;
                 Instantiate(score_effect, gameObject.transform.position, gameObject.transform.rotation).GetComponent <TextMesh>().text = "-25";
             }
             if (!StressManager.GetBurnout() && !StressManager.GetResting())
             {
                 StressManager.IncreaseStressLevel(FindObjectOfType <StressTimerScript>().maxStress / 4);
             }
         }
         else if (other.tag == "Pickup")
         {
             Destroy(other.gameObject);
             if (health < 3)
             {
                 health++;
             }
             score += 20;
             Instantiate(score_effect, gameObject.transform.position, gameObject.transform.rotation).GetComponent <TextMesh>().text = "+20";
             GetComponent <Spawner>().SpawnBodyPart();
             if (!StressManager.GetBurnout() && !StressManager.GetResting())
             {
                 StressManager.DecreaseStressLevel(FindObjectOfType <StressTimerScript>().maxStress / 5);
             }
         }
     }
 }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (!StressManager.GetResting() && !StressManager.GetBurnout())
     {
         if (StressManager.GetStressLevel() < maxStress)
         {
             StressManager.IncreaseStressLevel(Time.deltaTime);
             stressBar.fillAmount = StressManager.GetStressLevel() / maxStress;
         }
         else
         {
             Debug.Log("BURNOUT");
             StressManager.SetBurnout(true);
             Debug.Log(StressManager.GetBurnout().ToString());
         }
     }
     else
     {
         if (StressManager.GetResting())
         {
             if (StressManager.GetStressLevel() > 0)
             {
                 StressManager.DecreaseStressLevel(Time.deltaTime * restRecoverySpeed);
                 stressBar.fillAmount = StressManager.GetStressLevel() / maxStress;
             }
             else
             {
                 StressManager.SetResting(false);
             }
         }
         else if (StressManager.GetBurnout())
         {
             if (StressManager.GetStressLevel() > 0)
             {
                 StressManager.DecreaseStressLevel(Time.deltaTime * burnoutRecoverySpeed);
                 stressBar.fillAmount = StressManager.GetStressLevel() / maxStress;
             }
             else
             {
                 StressManager.SetBurnout(false);
             }
         }
     }
 }