Exemplo n.º 1
0
    private Dictionary <string, AudioSource> name2Audio = new Dictionary <string, AudioSource>(); // 名稱對應到音檔的Dictionary

    private void Awake()
    {
        // if instance is assigned
        if (instance)
        {
            // 自毀
            Destroy(gameObject);
            return;
        }
        // 我來當共享變數
        instance = this;
        // 讓自己不會因為場景切換被消滅
        DontDestroyOnLoad(gameObject);
        if (sceneClipArray) // 如果儲存音檔資訊的 list 不是 null
        {
            // 遍歷這個 list 裡的所有東西
            foreach (Sound s in sceneClipArray)
            {
                // 新增一個空的 AudioSource
                AudioSource audio = gameObject.AddComponent <AudioSource>();
                // 幫新增的 AudioSource 填資料
                s.InitAudioSource(audio);
                // 把名字和 AudioSource 的 pair 新增到 dictionary 內
                name2Audio.Add(s.name, audio);
            }
        }
        else
        {
            Debug.LogWarning("Clip array is not assigned!");
        }
    }
Exemplo n.º 2
0
 private void Awake()
 {
     audioManager = GameObject.Find("SceneAudioManager").GetComponent <SceneAudioManager>();
     if (clipArray != null)
     {
         clipArray.Initialize();
         foreach (Sound s in clipArray.sounds)
         {
             Clip newClip = new Clip();
             newClip.name                = s.name;
             newClip.hash                = s.hashCode;
             newClip.isFX                = s.isFX;
             newClip.volume              = s.volume;
             newClip.source              = gameObject.AddComponent <AudioSource>();
             newClip.source.playOnAwake  = false;
             newClip.source.clip         = s.clip;
             newClip.source.volume       = s.volume;
             newClip.source.pitch        = s.pitch;
             newClip.source.loop         = s.loop;
             newClip.source.spatialBlend = s.blend;
             clips.Add(newClip);
             if (s.loop)
             {
                 loopClips.Add(newClip);
             }
         }
     }
 }
Exemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     message[1]    += System.DateTime.Now.ToString("yyyy-MM-dd");
     player         = GameObject.FindGameObjectWithTag("Player");
     control        = player.GetComponent <PlayerControl>();
     playerRenderer = player.GetComponent <SpriteRenderer>();
     image          = this.GetComponentInChildren <Image>();
     startScreen    = this.transform.Find("StartScreen").gameObject;
     cutScene       = this.transform.Find("CutScene").gameObject;
     if (startScreen != null)
     {
         title      = startScreen.transform.Find("Title").GetComponent <TMPro.TextMeshProUGUI>();
         subTitle   = startScreen.transform.Find("SubTitle").GetComponent <TMPro.TextMeshProUGUI>();
         indication = startScreen.transform.Find("Indication").GetComponent <TMPro.TextMeshProUGUI>();
         underLine  = startScreen.transform.Find("UnderLine").GetComponent <TMPro.TextMeshProUGUI>();
     }
     if (cutScene != null)
     {
         runMessage = cutScene.transform.Find("RunMessage").GetComponent <TMPro.TextMeshProUGUI>();
         error      = cutScene.transform.Find("Error").GetComponent <TMPro.TextMeshProUGUI>();
         suggestion = cutScene.transform.Find("Suggestion").GetComponent <TMPro.TextMeshProUGUI>();
     }
     if (level != null)
     {
         levelSprites = level.GetComponentsInChildren <SpriteRenderer>();
     }
     control.isCutScene = true;
     audioManager       = GameObject.Find("SceneAudioManager").GetComponent <SceneAudioManager>();
     StartCoroutine(PlayCutScene());
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Awake()
 {
     audio_manager = SceneAudioManager.Instance;
     audio_process = AudioProcessor.Instance;
     Pause         = false;
     PauseHUD      = false;
     Tracks        = new List <AudioClip>(Resources.LoadAll <AudioClip>("Audio/"));
 }
Exemplo n.º 5
0
 void Start()
 {
     player            = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>();
     image             = this.GetComponentInChildren <Image>();
     image.color       = Color.black;
     glitch            = Camera.main.GetComponent <GlitchEffect>();
     player.isCutScene = true;
     audioManager      = GameObject.Find("SceneAudioManager").GetComponent <SceneAudioManager>();
     StartCoroutine(PlayCutScene());
 }
Exemplo n.º 6
0
 void Start()
 {
     counter         = Resources.Load <Counter>("Scriptable Object/Counter");
     audioManager    = GameObject.Find("SceneAudioManager").GetComponent <SceneAudioManager>();
     title           = this.transform.Find("Title").gameObject.GetComponent <TextMeshProUGUI>();
     textRect        = this.transform.Find("TextRect").gameObject.GetComponent <TextMeshProUGUI>();
     resultText      = this.transform.Find("ResultText").gameObject.GetComponent <TextMeshProUGUI>();
     indication      = this.transform.Find("Indication").gameObject.GetComponent <TextMeshProUGUI>();
     title.text      = "";
     resultText.text = "";
     textRect.text   = "";
 }
Exemplo n.º 7
0
 // Start is called before the first frame update
 void Start()
 {
     canvas     = this.GetComponent <Canvas>();
     texts      = this.transform.Find("LevelComplete").gameObject.GetComponent <TextMeshProUGUI>();
     indication = this.transform.Find("Indication").gameObject.GetComponent <TextMeshProUGUI>();
     thank      = this.transform.Find("ThankYou").gameObject.GetComponent <TextMeshProUGUI>();
     image      = this.GetComponentInChildren <Image>();
     if (button == null)
     {
         DontDestroyOnLoad(this.gameObject);
     }
     audioManager = GameObject.Find("SceneAudioManager").GetComponent <SceneAudioManager>();
 }
Exemplo n.º 8
0
 // Start is called before the first frame update
 void Start()
 {
     anim         = this.GetComponent <Animator>();
     user         = this.transform.Find("UserText").gameObject.GetComponent <TMPro.TextMeshProUGUI>();
     access       = this.transform.Find("AccessText").gameObject.GetComponent <TMPro.TextMeshProUGUI>();
     message      = this.transform.Find("MessageText").gameObject.GetComponent <TMPro.TextMeshProUGUI>();
     audioManager = GameObject.Find("SceneAudioManager").GetComponent <SceneAudioManager>();
     userText     = user.text;
     accessText   = access.text;
     messageText  = message.text;
     user.text    = "";
     access.text  = "";
     message.text = "";
     isRunning    = false;
 }
Exemplo n.º 9
0
    // Start is called before the first frame update
    void Start()
    {
        sceneAudio = GetComponent <SceneAudioManager>();

        objsToEnable.Add(GameObject.Find("Master").GetComponent <GuestSpawner>());
        objsToEnable.Add(GameObject.Find("Player").GetComponent <ControlsManager>());


        foreach (var item in objsToEnable)
        {
            item.enabled = false;
        }


        clock            = GameObject.Find("TimeDisplay").GetComponent <TextMeshProUGUI>();
        complaintManager = GameObject.Find("Master").GetComponent <ComplaintManager>();
    }
Exemplo n.º 10
0
 void OnEnable()
 {
     buttonList[0].color = Color.yellow;
     control             = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>();
     audioManager        = GameObject.Find("SceneAudioManager").GetComponent <SceneAudioManager>();
     counter             = Resources.Load <Counter>("Scriptable Object/Counter");
     control.enabled     = false;
     selectedButton      = 0;
     canPress            = false;
     canMove             = true;
     canInput            = false;
     if (input != null)
     {
         if (this.name == "ThirdCarrier")
         {
             showKey = this.transform.Find("KeyInput").gameObject;
         }
         if (showKey != null)
         {
             key = showKey.transform.Find("Key").gameObject.GetComponent <TMPro.TextMeshProUGUI>();
         }
         foreach (TMPro.TextMeshProUGUI gui in buttonList)
         {
             if (gui.name == "Key" && gui.GetComponentInChildren <TMPro.TextMeshProUGUI>() != null)
             {
                 gui.transform.Find(gui.text).gameObject.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = input.giveKeyCode(gui.text);
             }
             else if (gui.name == "BGM")
             {
                 gui.transform.Find("Volume").gameObject.GetComponent <TMPro.TextMeshProUGUI>().text = "< " + Mathf.RoundToInt(audioManager.musicAmp * 10).ToString() + " >";
             }
             else if (gui.name == "BGFX")
             {
                 gui.transform.Find("Volume").gameObject.GetComponent <TMPro.TextMeshProUGUI>().text = "< " + Mathf.RoundToInt(audioManager.fxAmp * 10).ToString() + " >";
             }
             else if (gui.name == "Timer")
             {
                 gui.transform.Find("Switch").gameObject.GetComponent <TMPro.TextMeshProUGUI>().text = ((counter.enableTimer == true)? "On" : "Off");
             }
         }
     }
 }
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        if (sceneClipArray != null)
        {
            foreach (Sound s in sceneClipArray.sounds)
            {
                Clip newClip = new Clip();
                newClip.name                     = s.name;
                newClip.hash                     = s.hashCode;
                newClip.isFX                     = s.isFX;
                newClip.volume                   = s.volume;
                newClip.source                   = gameObject.AddComponent <AudioSource>();
                newClip.source.clip              = s.clip;
                newClip.source.playOnAwake       = false;
                newClip.source.volume            = s.volume;
                newClip.source.pitch             = s.pitch;
                newClip.source.loop              = s.loop;
                newClip.source.spatialBlend      = s.blend;
                newClip.source.bypassEffects     = true;
                newClip.source.bypassReverbZones = true;
                sceneClips.Add(newClip);
                clip2Sound.Add(newClip, s);
            }
        }

        SceneManager.activeSceneChanged += OnSceneChange;
    }
Exemplo n.º 12
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        if (generalClipArray != null)
        {
            generalClipArray.Initialize();
            foreach (Sound s in generalClipArray.sounds)
            {
                Clip newClip = new Clip();
                newClip.name                     = s.name;
                newClip.hash                     = s.hashCode;
                newClip.isFX                     = s.isFX;
                newClip.volume                   = s.volume;
                newClip.source                   = gameObject.AddComponent <AudioSource>();
                newClip.source.playOnAwake       = false;
                newClip.source.clip              = s.clip;
                newClip.source.volume            = s.volume;
                newClip.source.pitch             = s.pitch;
                newClip.source.loop              = s.loop;
                newClip.source.spatialBlend      = s.blend;
                newClip.source.bypassReverbZones = true;
                generalClips.Add(newClip);
            }
        }
    }
 private void Start()
 {
     audioManager = SceneAudioManager.instance;
 }