Esempio n. 1
0
    private void UpdateAudioState(EffectAudioSourceItem item, PlayState ps, bool useSwitch)
    {
        if (item == null)
        {
            return;
        }

        if (ps == PlayState.Resume)
        {
            if (item.attachedObj != null && !item.IsPlaying())
            {
                if (useSwitch)
                {
                    item.PlayWithSwitch(item.audioName, item.switchGroup, item.switchState);
                }
                else
                {
                    item.Play(item.audioName);
                }
            }
        }
        else if (ps == PlayState.Stop || ps == PlayState.Pause)
        {
            if (item.attachedObj != null)
            {
                item.Stop();
            }
        }
    }
Esempio n. 2
0
    private EffectAudioSourceItem _PlaySFX(string audioName, AudioType aType, Transform point, Vector3 pos, int sortId, EffectSoundType type)
    {
        if (string.IsNullOrEmpty(audioName))
        {
            return(null);
        }

        if (_IsEffectAudioEnabled)
        {
            CheckAudioListener();

            SafeInitSFX();

            EffectAudioSourceItem item_arranged = GetUsableItem(aType, sortId, pos, type);

            if (item_arranged != null)
            {
                item_arranged.audioName = audioName;
                if (item_arranged.id != -1 && item_arranged.attachedObj != null)
                {
                    if (type == EffectSoundType.Effect3D || type == EffectSoundType.AttachEffect3D || type == EffectSoundType.Effect2D || type == EffectSoundType.FootStep3D)
                    {
                        if (item_arranged.IsPlaying())
                        {
                            item_arranged.Stop();
                        }
                    }
                    else
                    {
                        item_arranged.Stop();
                    }

                    GetProperSettingOfItem(item_arranged, aType, audioName, sortId);

                    if (aType == AudioType.AttS3D)
                    {
                        item_arranged.attachedPos = point;
                        item_arranged.attachedObj.transform.position = point.position;
                    }
                    if (aType == AudioType.S3D)
                    {
                        item_arranged.attachedObj.transform.position = pos;
                    }

                    if (item_arranged.attachedObj != null)
                    {
                        item_arranged.Play(audioName);
                    }

                    return(item_arranged);
                }
            }
        }

        return(null);
    }