Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- public class AppeasementMeter : MonoBehaviour
- {
- public float maxAppeasement = 100;
- public float appeasement;
- public Slider slider;
- public float appeasementDrainRate = 1;
- public enum Mood { Praised, Pleased, Indifferent, Displeased, Angered }
- public Mood currentMood;
- public GameObject praised;
- public GameObject pleased;
- public GameObject indifferent;
- public GameObject displeased;
- public GameObject angered;
- // Skybox Settings
- public Material skyboxMaterial;
- public float initialAtmosphereThickness = 1f;
- public float targetAtmosphereThickness = 5f;
- public float initialExposure = 1.3f;
- public float targetExposure = 5.9f;
- // Light Settings
- public Light directionalLight;
- public float initialTemperature = 5000f;
- public float targetTemperature = 1500f;
- public float initialIntensity = 1f;
- public float targetIntensity = 0.5f;
- // Fog Settings
- public Color initialFogColor = new Color(0.8f, 0.85f, 0.85f);
- public Color targetFogColor = new Color(0f, 0f, 0f);
- public float effectStartThreshold = 20f; // Adjustable value for when effects start
- private float lerpTime = 0f;
- // Reference to DayNightCycle for starting ApocalypseMode
- public DayNightCycle dayNightCycle;
- public bool apocalypseStarted = false;
- void Start()
- {
- appeasement = maxAppeasement;
- if (skyboxMaterial != null)
- {
- skyboxMaterial.SetFloat("_AtmosphereThickness", initialAtmosphereThickness);
- skyboxMaterial.SetFloat("_Exposure", initialExposure);
- }
- if (directionalLight != null)
- {
- directionalLight.colorTemperature = initialTemperature;
- directionalLight.intensity = initialIntensity;
- }
- RenderSettings.fogColor = initialFogColor;
- }
- void Update()
- {
- if (appeasement >= 80)
- {
- currentMood = Mood.Praised;
- appeasementDrainRate = 0.30f;
- }
- else if (appeasement >= 60)
- {
- currentMood = Mood.Pleased;
- appeasementDrainRate = 0.50f;
- }
- else if (appeasement >= 40)
- {
- currentMood = Mood.Indifferent;
- appeasementDrainRate = 1f;
- }
- else if (appeasement >= 20)
- {
- currentMood = Mood.Displeased;
- appeasementDrainRate = 1.25f;
- }
- else
- {
- currentMood = Mood.Angered;
- appeasementDrainRate = 1.5f;
- lerpTime += Time.deltaTime * appeasementDrainRate;
- }
- UpdateSprites();
- slider.value = Mathf.Lerp(slider.value, appeasement, Time.deltaTime * 1f);
- SetAppeasement(appeasement);
- if (appeasement <= 0 && apocalypseStarted == false)
- {
- if (dayNightCycle != null)
- {
- dayNightCycle.StartApocalypseMode();
- dayNightCycle.apocalypseActive = true; // Ensures that Apocalypse Mode is marked as active
- apocalypseStarted = true;
- Debug.Log("Apocalypse Mode started: apocalypseActive is set to true.");
- }
- }
- // Updates appeasement after the checks above
- appeasement -= Time.deltaTime * appeasementDrainRate;
- appeasement = Mathf.Clamp(appeasement, 0, maxAppeasement);
- if (appeasement <= effectStartThreshold)
- {
- float progression = Mathf.InverseLerp(effectStartThreshold, 0f, appeasement);
- skyboxMaterial.SetFloat("_AtmosphereThickness", Mathf.Lerp(initialAtmosphereThickness, targetAtmosphereThickness, progression));
- skyboxMaterial.SetFloat("_Exposure", Mathf.Lerp(initialExposure, targetExposure, progression));
- directionalLight.colorTemperature = Mathf.Lerp(initialTemperature, targetTemperature, progression);
- directionalLight.intensity = Mathf.Lerp(initialIntensity, targetIntensity, progression);
- RenderSettings.fogColor = Color.Lerp(initialFogColor, targetFogColor, progression);
- }
- }
- void UpdateSprites()
- {
- praised.SetActive(currentMood == Mood.Praised);
- pleased.SetActive(currentMood == Mood.Pleased);
- indifferent.SetActive(currentMood == Mood.Indifferent);
- displeased.SetActive(currentMood == Mood.Displeased);
- angered.SetActive(currentMood == Mood.Angered);
- }
- void SetAppeasement(float appeasement)
- {
- slider.value = appeasement;
- }
- public void ResetWeatherAndLighting()
- {
- if (skyboxMaterial != null)
- {
- skyboxMaterial.SetFloat("_AtmosphereThickness", initialAtmosphereThickness);
- skyboxMaterial.SetFloat("_Exposure", initialExposure);
- }
- if (directionalLight != null)
- {
- directionalLight.colorTemperature = initialTemperature;
- directionalLight.intensity = initialIntensity;
- }
- RenderSettings.fogColor = initialFogColor;
- apocalypseStarted = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement