private void OnTouchUp() { if (!StressManager.GetBurnout()) { if (StressManager.GetResting()) { StressManager.SetResting(false); Debug.Log(StressManager.GetResting().ToString()); } else // Not Resting { StressManager.SetResting(true); Debug.Log(StressManager.GetResting().ToString()); } } }
// Update is called once per frame void Update() { if (StressManager.GetResting()) { if (Serenity.color.a < 1.0f) { Serenity.color = new Color(Serenity.color.r, Serenity.color.g, Serenity.color.b, Serenity.color.a + (Time.deltaTime * 2)); } } else { if (Serenity.color.a > 0.0f) { Serenity.color = new Color(Serenity.color.r, Serenity.color.g, Serenity.color.b, Serenity.color.a - (Time.deltaTime * 2)); } } }
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); } } } }
// 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); } } } }