67 lines
1.7 KiB
C#

using UnityEngine;
// Kann sein das das nur für statische Objekte funktioniert
public class DimShift : MonoBehaviour
{
// true if start in first dim wanted
[SerializeField] private bool inFirstDim;
// controlled by other gameobjects
public bool shiftingEnabled;
private GameObject dim1;
private GameObject dim2;
private Animator animator;
// these filters are also controlled by TempMusicChange.cs
private AudioReverbFilter rev;
private AudioLowPassFilter lpf;
void Start()
{
// temp variable to reduce find calls
GameObject audioController = GameObject.Find("AudioController");
dim1 = GameObject.Find("Dim1");
dim2 = GameObject.Find("Dim2");
animator = GetComponent<Animator>();
rev = audioController.GetComponent<AudioReverbFilter>();
lpf = audioController.GetComponent<AudioLowPassFilter>();
// default start in dim1
dim1.SetActive(true);
dim2.SetActive(false);
rev.enabled = false;
lpf.enabled = false;
// if start in dim2 is wanted
if (!inFirstDim)
{
ToggleDims();
ToggleFilters();
}
}
void Update()
{
if (shiftingEnabled && Input.GetKeyDown(KeyCode.LeftShift))
{
ToggleDims();
ToggleFilters();
animator.SetTrigger("ShiftsDim");
}
}
private void ToggleDims()
{
dim1.SetActive(!dim1.activeSelf);
dim2.SetActive(!dim2.activeSelf);
}
private void ToggleFilters()
{
rev.enabled = !rev.enabled;
lpf.enabled = !lpf.enabled;
}
}