using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// Kann sein das das nur für statische Objekte funktioniert
public class DimShift : MonoBehaviour
{
    // 0 = inactive in Dimension 1
    // 1 = active in Dimension 1
    [SerializeField] private bool inFirstDim;
    [SerializeField] public bool ShiftingEnabled;


    AudioSource Audio1;
    AudioReverbFilter Rev1;
    AudioLowPassFilter lpf;
    GameObject Dim1;
    GameObject Dim2;
    //remove if unwanted
    private Animator animator;

    void Start()
    {
        Dim1 = GameObject.Find("Dim1");
        Dim2 = GameObject.Find("Dim2");
        Audio1 = GameObject.Find("AudioController").GetComponent<AudioSource>();
        Rev1 = GameObject.Find("AudioController").GetComponent<AudioReverbFilter>();
        lpf = GameObject.Find("AudioController").GetComponent<AudioLowPassFilter>();
	//remove if unwanted
	animator = GetComponent<Animator>();

        if (inFirstDim)
        {
            Dim1.SetActive(true);
            Dim2.SetActive(false);
            MusicDim1();
        } else 
        {
            Dim1.SetActive(false);       
            Dim2.SetActive(true);
            MusicDim2();
        }
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift)&&inFirstDim&&ShiftingEnabled)
        {
            Dim2.SetActive(true);
            Dim1.SetActive(false);
            MusicDim2();
            inFirstDim = !inFirstDim;
	    //remove if unwanted
	    animator.SetTrigger("ShiftsDim");
        } else 
        {
            if (Input.GetKeyDown(KeyCode.LeftShift)&&!inFirstDim&&ShiftingEnabled)
            {
                Dim1.SetActive(true);
                Dim2.SetActive(false);
                MusicDim1();
                inFirstDim = !inFirstDim;
		//remove if unwanted
		animator.SetTrigger("ShiftsDim");
            }
        }
    }

    void MusicDim1()
    {
        Rev1.enabled = false;
        lpf.enabled = false;
    }

        void MusicDim2()
    {
        Rev1.enabled = true;
        lpf.enabled = true;
    }
}
