void Awake() { active = false; blinkController = GetComponent <BlinkController>(); currentInfection = 0f; infectionLevel = InfectionLevel.LEVEL0; infectionNumberMat = infectionNumberTxt.material; currentBrightness = 1f; currentColor = Color.white; infectionNumberTxt.text = "0%"; infectionBar.value = 0; if (brightnessCicleDuration > 0) { brightnessSpeed = 1 / brightnessCicleDuration; } else { brightnessSpeed = 1; } tutorialTriggered = false; SetColor(); }
public void CalculateInfection() { float escapes = numRecentEnemyEscapes; float cap = numRecentEnemiesCounted; //Debug.Log(escapes/cap); infectionLevel = (float)(escapes / cap) * 100; blackOutImage.GetComponent <RawImage>().color = new Color(0.6f, 0, 0, (infectionLevel / 200)); if (infectionLevel <= 20) { infectionState = InfectionLevel.Healthy; } else if (infectionLevel <= 60) { infectionState = InfectionLevel.Sick; } else if (infectionLevel <= 90) { infectionState = InfectionLevel.VerySick; } else if (infectionLevel <= 100) { infectionState = InfectionLevel.DeathlySick; } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); InfectionLevel infectionLevel = target as InfectionLevel; GUILayout.BeginHorizontal(); GUILayout.Label("infection:"); GUILayout.TextField(infectionLevel.level.ToString()); GUILayout.EndHorizontal(); }
void Update() { if (!active) { return; } if (!shouldDisinfectSoundBePlayed && disinfectSoundFx.isPlaying) { disinfectSoundFx.Stop(); } infectionNumberTxt.text = (Mathf.CeilToInt(currentInfection)) + "%"; infectionBar.value = Mathf.CeilToInt(currentInfection); currentBrightness = (Mathf.Sin(Time.time * Mathf.PI * brightnessSpeed) / 2) + 1; //Values between 0.5 and 1.5 switch (infectionLevel) { case InfectionLevel.LEVEL0: currentColor = Color.Lerp(Color.white, colorOnLevel0To1, currentInfection / level0To1Threshold); if (currentInfection >= level2To3Threshold) { infectionLevel = InfectionLevel.LEVEL3; ManageInfectionChange(); } else if (currentInfection >= level1To2Threshold) { infectionLevel = InfectionLevel.LEVEL2; ManageInfectionChange(); } else if (currentInfection >= level0To1Threshold) { infectionLevel = InfectionLevel.LEVEL1; ManageInfectionChange(); } break; case InfectionLevel.LEVEL1: currentColor = Color.Lerp(colorOnLevel0To1, colorOnLevel1To2, (currentInfection - level0To1Threshold) / (level1To2Threshold - level0To1Threshold)); if (currentInfection >= level2To3Threshold) { infectionLevel = InfectionLevel.LEVEL3; ManageInfectionChange(); } else if (currentInfection >= level1To2Threshold) { infectionLevel = InfectionLevel.LEVEL2; ManageInfectionChange(); } else if (currentInfection < level0To1Threshold) { infectionLevel = InfectionLevel.LEVEL0; ManageInfectionChange(); } break; case InfectionLevel.LEVEL2: currentColor = Color.Lerp(colorOnLevel1To2, colorOnLevel2To3, (currentInfection - level1To2Threshold) / (level2To3Threshold - level1To2Threshold)); if (currentInfection >= level2To3Threshold) { infectionLevel = InfectionLevel.LEVEL3; ManageInfectionChange(); } else if (currentInfection < level0To1Threshold) { infectionLevel = InfectionLevel.LEVEL0; ManageInfectionChange(); } else if (currentInfection < level1To2Threshold) { infectionLevel = InfectionLevel.LEVEL1; ManageInfectionChange(); } break; case InfectionLevel.LEVEL3: currentColor = colorOnLevel2To3; if (currentInfection < level0To1Threshold) { infectionLevel = InfectionLevel.LEVEL0; ManageInfectionChange(); } else if (currentInfection < level1To2Threshold) { infectionLevel = InfectionLevel.LEVEL1; ManageInfectionChange(); } else if (currentInfection < level2To3Threshold) { infectionLevel = InfectionLevel.LEVEL2; ManageInfectionChange(); } break; default: break; } SetColor(); shouldDisinfectSoundBePlayed = false; }