public bool IsSuppressed(EmotionType emotionType) { return(runState.IsSuppressed(emotionType)); }
void Update() { RunState runState = runManager.runState; EmotionState e = runState.emotions; // fill meters List <int> values = new List <int> { runState.energy, e.despair, e.anxiety, e.frustration }; int emoCap = emotionMeterCap; List <int> caps = new List <int> { gameManager.profile.energyCap, emoCap, emoCap, emoCap }; List <GameObject> meters = new List <GameObject> { energyMeter, despairMeter, anxietyMeter, frustrationMeter }; for (int i = 0; i < meters.Count; i++) { // Find filler image (meters must have a child called "Filler") Image fillerImage = meters[i].transform.Find("Filler").GetComponent <Image>(); fillerImage.type = Image.Type.Filled; fillerImage.fillMethod = Image.FillMethod.Horizontal; float newFillAmount = Mathf.Min(1, (float)values[i] / (float)caps[i]); // activate change markers Transform increaseMarker = meters[i].transform.Find("IncreaseMarker"); if (increaseMarker) { if (newFillAmount > fillerImage.fillAmount) { increaseMarker.GetComponent <FadeImage>().Reset(); } } // set filler image fill amount fillerImage.fillAmount = newFillAmount; // color gray and draw X if being suppressed EmotionType emotionType = EmotionType.None; if (meters[i] == anxietyMeter) { emotionType = EmotionType.anxiety; } if (meters[i] == frustrationMeter) { emotionType = EmotionType.frustration; } if (meters[i] == despairMeter) { emotionType = EmotionType.despair; } Activity activity = runState.CurrentActivity(); if (activity && runState.IsSuppressed(emotionType)) { fillerImage.color = new Color(.4f, .4f, .4f); Image XMark = meters[i].transform.Find("XMark").GetComponent <Image>(); if (gameManager.showSuppressionTutorial) { tutorialManager.ActivateSuppressionTutorial(); } // XMark.color = emotionFillColors[emotionType]; XMark.enabled = true; } else if (emotionType != EmotionType.None) { fillerImage.color = emotionFillColors[emotionType]; Image XMark = meters[i].transform.Find("XMark").GetComponent <Image>(); XMark.enabled = false; } // set text (meters must have a child called "Text") Transform textObject = meters[i].transform.Find("Text"); if (textObject) { textObject.GetComponent <TextMeshProUGUI>().text = values[i].ToString(); } } ; // rotate timer wheel (must have a child called "Disc") Transform disc = timerWheel.transform.Find("Disc"); float targetRotation = 345 - ((float)runState.timeSteps / 15f * 360f) % 360; if (System.Math.Abs(disc.localRotation.eulerAngles.z - targetRotation) > System.Math.Abs(timeRotationStep)) { disc.Rotate(new Vector3(0, 0, timeRotationStep)); } // update the score display Transform scoreText = scoreDisplay.transform.Find("Text"); if (scoreText) { scoreText.GetComponent <TextMeshProUGUI>().text = runState.score.ToString(); } Transform scoreMultiplierText = scoreDisplay.transform.Find("MultiplierText"); if (scoreMultiplierText) { string multiplierString = runState.scoreMultiplier.ToString() + "x"; scoreMultiplierText.GetComponent <TextMeshProUGUI>().text = multiplierString; scoreMultiplierText.GetComponent <TextMeshProUGUI>().color = new Color(0, 0, 0); if (runState.scoreMultiplier < 1) { scoreMultiplierText.GetComponent <TextMeshProUGUI>().color = new Color(255, 0, 0); } if (runState.scoreMultiplier > 1) { scoreMultiplierText.GetComponent <TextMeshProUGUI>().color = new Color(0, 255, 0); } } Transform comboText = comboCounter.transform.Find("Text"); if (comboText) { string comboString = "x" + runState.rhythmCombo.ToString(); if (comboString != comboText.GetComponent <TextMeshProUGUI>().text) { comboText.GetComponent <FadeTMPro>().Reset(); } comboText.GetComponent <TextMeshProUGUI>().text = comboString; } }
// 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]); } }