// Update is called once per frame void Update() { if (StressManager.GetBurnout()) { max_timer = (new_max_timer * 0.6f) + 0.125f; } else { max_timer = new_max_timer; } //when timer reaches 0 spawn an instance of obstacle or item at randomised spawner pos; timer -= Time.deltaTime; if (timer <= 0.0f) { timer = max_timer; last_spawner = chooseSpawner(last_spawner); Vector3 position = spawners[last_spawner].transform.position; GameObject spawn; if (pickup_counter == 0) { pickup_counter = pickup_rate; spawn = prefabs[1]; } else { spawn = prefabs[0]; } Instantiate(spawn, position, Quaternion.identity); pickup_counter--; } }
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.GetBurnout()) { if (Burned.color.a < 1.0f) { Burned.color = new Color(Burned.color.r, Burned.color.g, Burned.color.b, Burned.color.a + (Time.deltaTime * 2)); } } else { if (Burned.color.a > 0.0f) { Burned.color = new Color(Burned.color.r, Burned.color.g, Burned.color.b, Burned.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); } } } }
// Update is called once per frame void Update() { if (StressManager.GetBurnout()) { speed = max_speed * 1.6f; } else { speed = max_speed; } //move downwards and delete if reach the bottom Vector3 pos = gameObject.transform.position; pos.y -= speed * Time.deltaTime; gameObject.transform.position = pos; if (pos.y <= -6) { Destroy(gameObject); } }