// Update is called once per frame void Update() { RunState runState = runManager.runState; EmotionState e = runState.emotions; // change the static background based on the time of day Sprite newStaticBG = morning; if (runState.timeSteps > 2) { newStaticBG = midday; } if (runState.timeSteps > 4) { newStaticBG = sunset; } if (runState.timeSteps > 6) { newStaticBG = night; } TransitionStaticBG(staticBase.GetComponent <Image>(), newStaticBG); // rain if sad if (e.despair >= 10 && !runState.IsSuppressed(EmotionType.despair)) { tileRain.SetActive(true); rainAudio.volume += Time.deltaTime / fadeOutDuration; rainAudio.volume = Mathf.Min(rainAudio.volume, maxVolumeFactor * e.despair); } else { tileRain.SetActive(false); rainAudio.volume -= Time.deltaTime / fadeOutDuration; } Color transparent = new Color(1, 1, 1, (float)e.despair / 20f); tileRain.GetComponent <SpriteRenderer>().color = transparent; // lightning if anxious if (e.anxiety >= 10 && !runState.IsSuppressed(EmotionType.anxiety)) { FlashLightning(.5f, Mathf.Min(0, (20f - e.anxiety) / 5f)); thunderAudio.volume += Time.deltaTime / fadeInDuration; thunderAudio.volume = Mathf.Min(thunderAudio.volume, maxVolumeFactor * e.anxiety); } else { thunderAudio.volume -= Time.deltaTime / fadeOutDuration; } // fire if frustrated if (e.frustration >= 10 && !runState.IsSuppressed(EmotionType.frustration)) { int maxPlumes = e.frustration / 4; SpawnFire(runState.CurrentActivityPlatform(), maxPlumes); fireAudio.volume += Time.deltaTime / fadeInDuration; fireAudio.volume = Mathf.Min(fireAudio.volume, maxVolumeFactor * e.frustration); } else { fireAudio.volume -= Time.deltaTime / fadeOutDuration; } // change fogginess based on total emotion level int s = e.GetSum(); int i = fogLevels.Count - 1; while (i > 0 && s < fogLevels[i]) { i--; } if (!isFogFading) { TransitionFog(tileBase.GetComponent <SpriteRenderer>(), fogSprites[i]); } }