예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     if (controller == null)
     {
         controller = gameObject.AddComponent <AudioSourceController>();
     }
 }
예제 #2
0
 void StartChargeDownSound()
 {
     if (SoundManager.instance != null)
     {
         chargeDownWeaponAudioController = SoundManager.instance.PlaySFX(chargeDownSound);
     }
 }
    public static void PlaySound(string name, GameObject gameObject)
    {
        if (!Instance.soundDictionary.ContainsKey(name))
        {
            Debug.LogError("The sound named <color=blue>" + name + "</color> doesn't exists.");
            return;
        }

        if (Instance.gameObjectDictionary.ContainsKey(gameObject))
        {
            AudioSourceController audioSourceControlle = Instance.gameObjectDictionary[gameObject];
            PlaySoundInternal(name, audioSourceControlle);
        }
        else
        {
            GameObject audioSource = new GameObject("Audio Source Controller");
            audioSource.transform.SetParent(gameObject.transform, true);

            AudioSourceController audioSourceController = audioSource.AddComponent <AudioSourceController>();
            audioSourceController.Initialize(Instance.numberChannelPerGameObject);
            Instance.gameObjectDictionary.Add(gameObject, audioSourceController);

            PlaySoundInternal(name, audioSourceController);
        }
    }
예제 #4
0
 public void PutController(AudioSourceController controller)
 {
     if (_pool.Contains(controller) == false)
     {
         _pool.Add(controller);
     }
 }
예제 #5
0
    protected override void OnTouch()
    {
        Squish();
        AudioSource audio = AudioSourceController.GetAudioSourceController().GetComponent <AudioSource>();

        audio.PlayOneShot(floaterSound, soundVolume);
    }
예제 #6
0
    public AudioSourceController Play(Transform parent)
    {
        AudioSourceController controller = Play(parent.position);

        controller.ParentTransform = parent;
        return(controller);
    }
예제 #7
0
 // Start is called before the first frame update
 void Start()
 {
     if (audioSourceController == null)
     {
         audioSourceController = AudioSourcesManager.ApplyAudioSourceController();
     }
 }
예제 #8
0
    private AudioSourceController ReturnNewAudioSourceController(AUDIO_SOURCE_TYPE audioSourceType)
    {
        GameObject            newAudioSource           = null;
        AudioSourceController newAudioSourceController = null;

        switch (audioSourceType)
        {
        case AUDIO_SOURCE_TYPE.MUSIC:
            newAudioSource = ObjectPooler.Instance.CreateObjectFromPool_Reuseable("MusicAudioSource", Vector3.zero, Quaternion.identity);
            break;

        case AUDIO_SOURCE_TYPE.SOUND_EFFECT:
            newAudioSource = ObjectPooler.Instance.CreateObjectFromPool_Reuseable("SoundEffectAudioSource", Vector3.zero, Quaternion.identity);

            break;

        case AUDIO_SOURCE_TYPE.DIALOGUE:
            newAudioSource = ObjectPooler.Instance.CreateObjectFromPool_Reuseable("DialogueAudioSource", Vector3.zero, Quaternion.identity);
            break;
        }

        newAudioSourceController = newAudioSource.GetComponent <AudioSourceController>();

        return(newAudioSourceController);
    }
예제 #9
0
    //显示字条。 itemName道具名,showTime淡入/淡出时间,间隔waitTime后再显示关闭按钮
    public void Show(string itemName, float showTime = 0.5f, float waitTime = 2f, int count = 2)
    {
        //音效
        if (m_AudioSourceController == null)
        {
            m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController();
        }
        if (itemName == "收音机")
        {
            m_AudioSourceController.Play("收音机杂音循环", transform);
        }
        else
        {
            m_AudioSourceController.Play("阅读字条", transform);
        }

        transform.Find("Canvas/Close Button").gameObject.SetActive(false);
        if (itemName != "收音机" && itemName != "收据1")
        {
            transform.Find("Canvas/Note Text").GetComponent <Text>().text = GameObject.Find("ItemsData").GetComponent <ItemsData>().GetItemByItemName(itemName).introduce;
        }
        if (itemName == "纸条" || itemName == "日记")
        {
            transform.Find("Canvas/Note Text").GetComponent <Text>().fontSize = 26;
        }
        GetComponent <ShowAndHideUI>().Show(showTime, delegate() { StartCoroutine(IE_ShowButton(1f, itemName, count)); });

        //禁用输入
        InputController.BanButton(true);
        InputController.BanMouse(true);

        GameObject.Find("EventSystem").GetComponent <EventSystem>().enabled = false;
    }
예제 #10
0
    public AudioSourceController GetController()
    {
        if (SFX_ANCHOR == null)
        {
            GameObject go = new GameObject("_SFXAnchor");
            SFX_ANCHOR = go.transform;
            //go.transform.SetParent(this.transform);
        }

        AudioSourceController output = null;

        if (_pool.Count > 0)
        {
            output = _pool[0];
            _pool.Remove(output);
            return(output);
        }
        else
        {
            GameObject go = new GameObject("AudioController");
            output = go.AddComponent <AudioSourceController>();
            if (mixer != null)
            {
                output.GetComponent <AudioSource>().outputAudioMixerGroup = mixer.FindMatchingGroups("SFX")[0];
            }
            go.transform.SetParent(SFX_ANCHOR, true);
            return(output);
        }
    }
예제 #11
0
    private IEnumerator Start()
    {
        if (this._playOnStart)
        {
            AudioSourceController audioSourceController = this._audioSourcePlayer.AquireAudioSourceController();

            //! Calling `Play` each iteration.
            do
            {
                audioSourceController.Play(
                    audioClip: this._audioClip
                    );

                yield return(new WaitForSecondsRealtime(this._audioClip.length));
            }while (this._loop);

            ObjectPool.Instance.Release(audioSourceController);

            //? How to do it without calling `Play` each iteration?
            //? Why is it not recommended in this cae?
            //!? Because you are modifything a state of an entity that has been pooled.
            //!? It sure seems an easier and a better choice, but it may lead to unexpected bugs like something playing again when it shouldn't have.

            //audioSourceController.AudioSource.loop = this._loop;

            //audioSourceController.Play(
            //	audioClip: this._audioClip
            //);

            //yield return new WaitForSecondsRealtime(this._audioClip.length);
        }
    }
예제 #12
0
    private void Start()
    {
        _resetDelay = Mathf.Clamp(_resetDelay, 0f, float.MaxValue);

        _audioSourceController = GetComponent <AudioSourceController>();
        _renderer  = GetComponent <Renderer>();
        _rigidbody = GetComponent <Rigidbody>();
    }
예제 #13
0
    void Start()
    {
        GetTerrainProps();

        audioController          = GetComponent <AudioSourceController>();
        wheelSmokeParticleSystem = GetComponent <ParticleSystem>();
        carController            = GetComponentInParent <CarController>();
    }
예제 #14
0
 void StopChargeDownSound()
 {
     if (chargeDownWeaponAudioController != null)
     {
         chargeDownWeaponAudioController.StopPlaying();
         chargeDownWeaponAudioController = null;
     }
 }
예제 #15
0
    void Start()
    {
        if (!audioCategory.IsMuted)
        {
            sceneSongController = sceneSong.Play();
        }

        gameEndEvent.RegisterListener(stopSceneSong);
    }
    private static void PlaySoundInternal(string name, AudioSourceController audioSourController)
    {
        Sound     sound     = Instance.soundDictionary[name];
        AudioClip audioClip = sound.clips[Random.Range(0, sound.clips.Length)];
        float     volume    = sound.volume + Random.Range(-sound.volumeVariance, sound.volumeVariance);
        float     pitch     = sound.pitch + Random.Range(-sound.pitchVariance, sound.pitchVariance);

        audioSourController.PlaySound(audioClip, volume, pitch);
    }
예제 #17
0
    public void Play(AudioSourceController source, float currentSfx)
    {
        if (clip == null || source == null)
        {
            return;
        }

        source.Play(clip, volume * currentSfx, pitch);
    }
예제 #18
0
 private void Start()
 {
     last_time = 0f;
     is_Cough  = false;
     child     = transform.GetChild(0).gameObject;
     if (audioSourceController == null)
     {
         audioSourceController = AudioSourcesManager.ApplyAudioSourceController();
     }
 }
예제 #19
0
 private void FinishCough()
 {
     InputController.BanButton(false);
     child.GetComponent <Animator>().SetBool("IsCough", false);
     audioSourceController.Stop();
     audioSourceController = AudioSourcesManager.ApplyAudioSourceController();
     last_time             = 0f;
     is_Cough = false;
     InputController.GetKey();
 }
    //public void PlayUI(AudioClip audioClip)
    //{
    //	AudioSourceController audioSourceController = ObjectPool.Instance.Aquire<AudioSourceController>(
    //		poolable: this._audioSourceControllerPrefab
    //	);

    //	audioSourceController.Play(audioClip: audioClip);
    //}

    public AudioSourceController Play(AudioClip audioClip)
    {
        AudioSourceController audioSourceController = ObjectPool.Instance.Aquire <AudioSourceController>(
            poolable: this._audioSourceControllerPrefab
            );

        audioSourceController.Play(audioClip: audioClip);

        return(audioSourceController);
    }
예제 #21
0
    public AudioSourceController Play()
    {
        AudioSourceController controller = AudioPoolManager.Instance.GetController();

        controller.SetSourceProperties(GetClip(), volume, pitch, loop, spacialBlend);
        controller.Category = Category;
        controller.Play();

        return(controller);
    }
예제 #22
0
    private IEnumerator PlayProcess()
    {
        AudioSourceController audioSourceController = this._audioSourcePlayer.Play(
            audioClip: this._audioClip
            );

        yield return(new WaitForSecondsRealtime(this._audioClip.length));

        ObjectPool.Instance.Release(audioSourceController);
    }
예제 #23
0
    public void StartForeshadowing(AudioCueType cueType)
    {
        if (StateManager.State == GameState.Playing)
        {
            AudioSource foreshadow = gameObject.AddComponent <AudioSource>();

            SyncSourceSettings(audio, ref foreshadow);
            MusicWithInformation foreshadowTrack;

            if (cueType == AudioCueType.Foreshadow_Long)
            {
                foreshadowTrack = foreshadowTracksLong[0];
                CycleList(ref foreshadowTracksLong);
            }
            else if (cueType == AudioCueType.Foreshadow_Short)
            {
                foreshadowTrack = foreshadowTracksShort[0];
                CycleList(ref foreshadowTracksShort);
            }
            else
            {
                return;
            }

            foreshadow.clip   = foreshadowTrack.clip;
            foreshadow.volume = foreshadowTrack.volume;

            double initTime = GetTimeOfNextBar();
            foreshadow.PlayScheduled(initTime);
            foreshadow.SetScheduledStartTime(initTime);
            AudioSourceController controller = new AudioSourceController(initTime, foreshadow, foreshadowTracksLong[0].cueType);
            foreshadowSourceControllers.Add(controller);

            int id = foreshadowID++;

            //EventManager.Music_ForeshadowBegin(id, foreshadow.clip.length);

            double currentBeatDuration = 60.0 / (currentlyPlayingTrack.BPM);

            if (cueType == AudioCueType.Foreshadow_Long)
            {
                StartCoroutine(CallForeshadowBegin(initTime - AudioSettings.dspTime, id, currentBeatDuration * 8));
                StartCoroutine(CallForeshadowEvent(initTime - AudioSettings.dspTime + currentBeatDuration * 8, id, foreshadow.clip.length));
            }
            else if (cueType == AudioCueType.Foreshadow_Short)
            {
                StartCoroutine(CallForeshadowBegin(initTime - AudioSettings.dspTime, id, currentBeatDuration * 4));
                StartCoroutine(CallForeshadowEvent(initTime - AudioSettings.dspTime + currentBeatDuration * 4, id, foreshadow.clip.length));
            }
            else if (controller.cueType == AudioCueType.UNDEFINED)
            {
                Debug.LogWarning("Tried to activate a foreshadow countdown but the clip had the UNDEFINED cue type");
            }
        }
    }
예제 #24
0
파일: Skill.cs 프로젝트: 1173710111/Godie
    public void GetSkill()
    {
        AudioSourceController audioSourceController = AudioSourcesManager.ApplyAudioSourceController();

        audioSourceController.Play("修理轮椅", transform);
        m_Disable = false;
        GetComponent <ShowAndHideUI>().Show();
        GetComponent <Image>().sprite = normalSprite;
        GetComponent <Image>().color  = new Color(1f, 1f, 1f, 1f);
        transform.GetChild(0).GetComponent <Image>().color = new Color(1, 1, 1, 0);
    }
예제 #25
0
    //Button继续游戏
    public void ContinueButton()
    {
        //音效
        if (m_AudioSourceController == null)
        {
            m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController();
        }
        m_AudioSourceController.Play("按钮", transform);

        Debug.Log("Continue");
    }
예제 #26
0
파일: PauseUI.cs 프로젝트: 1173710111/Godie
    public void MusicButton()
    {
        //音效
        if (m_AudioSourceController == null)
        {
            m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController();
        }
        m_AudioSourceController.Play("按钮", transform);

        transform.Find("PauseCanvas/BackgroundPanel/BasicPanel").gameObject.SetActive(false);
        transform.Find("PauseCanvas/BackgroundPanel/MusicPanel").gameObject.SetActive(true);
    }
예제 #27
0
    //Button退出
    public void ExitButton()
    {
        //音效
        if (m_AudioSourceController == null)
        {
            m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController();
        }
        m_AudioSourceController.Play("按钮", transform);

        Application.Quit();
        Debug.Log("Exit");
    }
예제 #28
0
    public AudioSourceController Play(Vector3 position)
    {
        controller = AudioPoolManager.Instance.GetController();
        float volGen   = AudioUtils.DecibelToLinear(Volume + Random.Range(RandomVolume, 0));
        float pitchVar = (RandomPitch / 2);
        float pitchGen = AudioUtils.St2pitch(Random.Range(Pitch - pitchVar, Pitch + pitchVar));

        controller.SetSourceProperties(GetClip(), volGen, pitchGen, Loop, SpatialBlend);
        controller.SetPosition(position);
        controller.Play();
        return(controller);
    }
예제 #29
0
    //Button开始新游戏
    public void NewStartButton()
    {
        //音效
        if (m_AudioSourceController == null)
        {
            m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController();
        }
        m_AudioSourceController.Play("按钮", transform);

        SceneManager.LoadScene(1); //加载场景1
        Debug.Log("NewStart");
    }
예제 #30
0
    void Start()
    {
        ASC_Ambient = GetComponent <AudioSourceController>();
        MM          = GameObject.FindWithTag("MenuManager").GetComponent <MenuManager>();
        Event.SetActive(true);

        PlayAmbient();

        QualitySettings.vSyncCount  = 0;
        Application.targetFrameRate = 60;

        SceneManager.sceneLoaded += OnSceneLoaded;
    }