LightLurch ability

Makes the lurch glow.
Can increase and decrease light as well as emission if the special "LightUp" ability is used.
This commit is contained in:
Jan Groß
2018-09-01 17:30:37 +02:00
parent b6ea22e42b
commit 9da1f82f20
10 changed files with 1541 additions and 3 deletions

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DarkAmbience : MonoBehaviour {
private float defaultEnvLightingIntensity, defaultEnfReflectionIntensity;
[SerializeField]
private float targetEnvLightingIntensity, targetEnfReflectionIntensity;
[SerializeField]
private float lerpSpeed;
[SerializeField]
private bool isDark = false;
private float t = 0;
// Use this for initialization
void Start () {
defaultEnvLightingIntensity = RenderSettings.ambientIntensity;
defaultEnfReflectionIntensity = RenderSettings.reflectionIntensity;
}
public void SwitchDarkness(bool dark)
{
isDark = dark;
t = 0;
}
private void OnValidate()
{
t = 0;
}
private void OnTriggerEnter(Collider other)
{
if(other.transform.root.tag == "Player")
{
SwitchDarkness(true);
}
}
private void OnTriggerExit(Collider other)
{
if (other.transform.root.tag == "Player")
{
SwitchDarkness(false);
}
}
// Update is called once per frame
void Update () {
if(isDark)
{
RenderSettings.ambientIntensity = Mathf.Lerp(defaultEnvLightingIntensity, targetEnvLightingIntensity, t);
RenderSettings.reflectionIntensity = Mathf.Lerp(defaultEnfReflectionIntensity, targetEnfReflectionIntensity, t);
}
else
{
RenderSettings.ambientIntensity = Mathf.Lerp(targetEnvLightingIntensity, defaultEnvLightingIntensity, t);
RenderSettings.reflectionIntensity = Mathf.Lerp(targetEnfReflectionIntensity, defaultEnfReflectionIntensity , t);
}
t += Time.deltaTime * lerpSpeed;
}
}