Can’t fix this damn script for almost 2 weeks. IDK what’s wrong with it. Can somebody Help please?
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Manager : MonoBehaviour
{
public GameObject vfxSource;
public AudioSource[] efxSourceArray;
private int currentSource;
private AudioSource efxSource;
public AudioSource musicSource;
public AudioSource sinLoopSource;
public AudioSource sinSource;
public AudioSource amdSource;
public static Manager instance;
public float lowPitchRange = 0.95f;
public float highPitchRange = 1.05f;
public bool playerTurn;
public string directory;
public string[] menuTxt;
public string[] dlcTxt;
public bool deadSound;
public float mute = 1f;
public bool doorsClosing;
public bool machineStatus;
public bool first = true;
public int AMDphase;
public bool dlcTransition;
public bool amdStatus;
public AudioClip amdLoopTrack;
public AudioClip sinLoopTrack;
public bool steam;
private void Awake()
{
if ((Object) Manager.instance == (Object) null)
Manager.instance = this;
else if ((Object) Manager.instance != (Object) this)
Object.Destroy((Object) this.gameObject);
Object.DontDestroyOnLoad((Object) this.gameObject);
Cursor.visible = false;
this.directory = Directory.GetCurrentDirectory();
this.menuTxt = File.ReadAllLines(this.directory + "/local/m.json");
this.dlcTxt = File.ReadAllLines(this.directory + "/localHM/hm_m.json");
this.VolumeChange(0, PlayerPrefs.GetInt("musicVol", 2));
this.VolumeChange(1, PlayerPrefs.GetInt("efxVol", 3));
}
public void PlaySingle(AudioClip clip)
{
this.efxSource.clip = clip;
this.efxSource.Play();
}
public void RandomizeSfx(bool pitchBool = true, params AudioClip[] clips)
{
if (this.deadSound && !this.doorsClosing)
return;
this.doorsClosing = false;
this.efxSource = this.efxSourceArray[this.currentSource];
++this.currentSource;
if (this.currentSource == this.efxSourceArray.Length)
this.currentSource = 0;
int index = UnityEngine.Random.Range(0, clips.Length);
this.efxSource.pitch = !pitchBool ? 1f : UnityEngine.Random.Range(this.lowPitchRange, this.highPitchRange);
this.efxSource.clip = clips[index];
this.efxSource.Play();
}
public void PlaySin(AudioClip sinClip)
{
if (this.deadSound)
return;
this.StartCoroutine(this.SinChanger());
this.sinSource.clip = sinClip;
this.sinSource.Play();
}
public void RandomizeVfx(GameObject[] clips, Vector3 place, bool random)
{
int index = UnityEngine.Random.Range(0, clips.Length);
this.vfxSource = clips[index];
if (random)
place = new Vector3(place.x + UnityEngine.Random.Range(-0.1f, 0.1f), place.y + UnityEngine.Random.Range(-0.1f, 0.1f), place.z);
UnityEngine.Object.Instantiate<GameObject>(this.vfxSource, place, this.vfxSource.transform.rotation);
}
public void VolumeChange(int type, int lvl)
{
float num = (float) lvl / 3f * this.mute;
if (lvl == 2 || lvl == 1)
num += 0.04f;
if (type == 1)
{
this.sinLoopSource.volume = num;
this.sinSource.volume = num;
this.amdSource.volume = num;
for (int index = 0; index < this.efxSourceArray.Length; ++index)
this.efxSourceArray[index].volume = num;
PlayerPrefs.SetInt("efxVol", lvl);
}
else
{
this.musicSource.volume = num;
PlayerPrefs.SetInt("musicVol", lvl);
}
}
public IEnumerator SongChanger(AudioClip track)
{
float tempVol = this.musicSource.volume;
while ((double) this.musicSource.volume > 0.0)
{
this.musicSource.volume -= 0.04f;
yield return (object) new WaitForSeconds(0.01f);
}
this.musicSource.volume = tempVol;
this.musicSource.clip = track;
this.musicSource.Play();
}
[IteratorStateMachine(typeof(Manager.<SinChanger>d__35))]
public IEnumerator SinChanger()
{
while (true)
{
int num;
switch (num)
{
case 0:
if (!this.machineStatus)
{
this.machineStatus = true;
this.sinLoopSource.mute = false;
yield return new WaitForSeconds(0.1f);
continue;
}
this.machineStatus = false;
this.sinLoopSource.mute = true;
yield return new WaitForSeconds(0.1f);
continue;
case 1:
goto IL_5D;
case 2:
goto IL_92;
}
break;
}
yield break;
IL_5D:
IL_92:
yield break;
}
public void PlayAMD(AudioClip amdClip)
{
if (this.deadSound)
return;
this.sinSource.clip = amdClip;
this.sinSource.Play();
}
public void PlayAMD(AudioClip amdClip)
{
if (this.deadSound)
return;
this.sinSource.clip = amdClip;
this.sinSource.Play();
}
public void PlayHands(AudioClip handClip)
{
if (this.deadSound)
return;
this.amdSource.clip = handClip;
this.amdSource.Play();
}
public void LoopAMD()
{
this.sinLoopSource.clip = this.amdLoopTrack;
this.sinLoopSource.Play();
this.sinLoopSource.mute = false;
this.amdStatus = true;
}
public void LoopMute()
{
this.sinLoopSource.clip = this.sinLoopTrack;
this.sinLoopSource.Play();
this.sinLoopSource.mute = true;
this.amdStatus = false;
}
}