GungHolo 869f066a92 Kritik Punkte im Szene 14 angegangen
-> Neues Partikel Prefab für jeweils Plattformen anderen Dimension
-> NoShift Prefab mit Trigger in dem nicht dimShifted werden kann
-> Richtige Musik
-> Plattformen laufen jetzt Synchron
-> Frank fällt hinter das Wasser
2023-06-22 16:59:42 +02:00

81 lines
2.0 KiB
C#

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;
}
}