Beispiel #1
0
    public static int?PlaySound(this SoundComponent soundComponent, string assetName, StarForce.Entity bindingEntity = null, object userData = null)
    {
        //IDataTable<DRSound> dtSound = GameEntry.DataTable.GetDataTable<DRSound>();
        //DRSound drSound = dtSound.GetDataRow(soundId);
        //if (drSound == null) {
        //    Log.Warning("Can not load sound '{0}' from data table.", soundId.ToString());
        //    return null;
        //}

        PlaySoundParams playSoundParams = PlaySoundParams.Create();

        playSoundParams.Priority           = 0;
        playSoundParams.Loop               = false;
        playSoundParams.VolumeInSoundGroup = 1;
        playSoundParams.SpatialBlend       = 1;
        return(soundComponent.PlaySound(AssetUtility.GetSoundAsset(assetName), "Sound", Constant.AssetPriority.SoundAsset, playSoundParams, bindingEntity != null ? bindingEntity.Entity : null, userData));
    }
Beispiel #2
0
    public static int?PlayUISound(this SoundComponent soundComponent, string soundAssetName, object userData = null)
    {
        //IDataTable<DRUISound> dtUISound = GameEntry.DataTable.GetDataTable<DRUISound>();
        //DRUISound drUISound = dtUISound.GetDataRow(uiSoundId);
        //if (drUISound == null) {
        //    Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString());
        //    return null;
        //}

        PlaySoundParams playSoundParams = PlaySoundParams.Create();

        playSoundParams.Priority           = 0;
        playSoundParams.Loop               = false;
        playSoundParams.VolumeInSoundGroup = 1;
        playSoundParams.SpatialBlend       = 0f;
        return(soundComponent.PlaySound(AssetUtility.GetUISoundAsset(soundAssetName), "UISound", Constant.AssetPriority.UISoundAsset, playSoundParams, userData));
    }
Beispiel #3
0
        public static int?PlaySound(this SoundComponent soundComponent, int soundId, Entity bindingEntity = null, object userData = null)
        {
            IDataTable <DRSound> dtSound = GameEntry.DataTable.GetDataTable <DRSound>();
            DRSound drSound = dtSound.GetDataRow(soundId);

            if (drSound == null)
            {
                Log.Warning("Can not load sound '{0}' from data table.", soundId.ToString());
                return(null);
            }

            PlaySoundParams playSoundParams = PlaySoundParams.Create();

            playSoundParams.Priority           = drSound.Priority;
            playSoundParams.Loop               = drSound.Loop;
            playSoundParams.VolumeInSoundGroup = drSound.Volume;
            playSoundParams.SpatialBlend       = drSound.SpatialBlend;
            return(soundComponent.PlaySound(AssetUtility.GetSoundAsset(drSound.AssetName), "Sound", Constant.AssetPriority.SoundAsset, playSoundParams, bindingEntity != null ? bindingEntity.Entity : null, userData));
        }
    public int PlayUISound(int uiSoundId, object userData = null)
    {
        DataTableComponent     dataTableComponent = UnityGameFramework.Runtime.GameEntry.GetComponent <DataTableComponent>();
        IDataTable <DRUISound> dtUISound          = dataTableComponent.GetDataTable <DRUISound>();
        DRUISound drUISound = dtUISound.GetDataRow(uiSoundId);

        if (drUISound == null)
        {
            Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString());
            return(-1);
        }

        PlaySoundParams playSoundParams = PlaySoundParams.Create();

        playSoundParams.Priority           = drUISound.Priority;
        playSoundParams.Loop               = false;
        playSoundParams.VolumeInSoundGroup = drUISound.Volume;
        playSoundParams.SpatialBlend       = 0f;
        return(soundComponent.PlaySound(AssetUtility.GetUISoundAsset(drUISound.AssetName), "UISound", Demo15.Constant.AssetPriority.UISoundAsset, playSoundParams, userData));
    }
Beispiel #5
0
        public static int?PlaySound(this SoundComponent soundComponent, int soundId, Entity bindingEntity = null, object userData = null)
        {
            SoundData soundData = GameEntry.Data.GetData <DataSound>().GetSoundDataBySoundId(soundId);

            PlaySoundParams playSoundParams = PlaySoundParams.Create();

            playSoundParams.Time               = soundData.SoundPlayParam.Time;
            playSoundParams.MuteInSoundGroup   = soundData.SoundPlayParam.Mute;
            playSoundParams.Loop               = soundData.SoundPlayParam.Loop;
            playSoundParams.Priority           = soundData.SoundPlayParam.Priority;
            playSoundParams.VolumeInSoundGroup = soundData.SoundPlayParam.Volume;
            playSoundParams.FadeInSeconds      = soundData.SoundPlayParam.FadeInSeconds;
            playSoundParams.Pitch              = soundData.SoundPlayParam.Pitch;
            playSoundParams.PanStereo          = soundData.SoundPlayParam.PanStereo;
            playSoundParams.SpatialBlend       = soundData.SoundPlayParam.SpatialBlend;
            playSoundParams.MaxDistance        = soundData.SoundPlayParam.MaxDistance;
            playSoundParams.DopplerLevel       = soundData.SoundPlayParam.DopplerLevel;

            return(soundComponent.PlaySound(soundData.AssetPath, soundData.SoundGroupData.Name, Constant.AssetPriority.MusicAsset, playSoundParams, bindingEntity, userData));
        }
Beispiel #6
0
        public static int?PlayMusic(this SoundComponent soundComponent, string assetName, object userData = null)
        {
            soundComponent.StopMusic();

            //IDataTable<DRMusic> dtMusic = GameEntry.DataTable.GetDataTable<DRMusic>();
            //DRMusic drMusic = dtMusic.GetDataRow(musicId);
            //if (drMusic == null)
            //{
            //    Log.Warning("Can not load music '{0}' from data table.", musicId.ToString());
            //    return null;
            //}

            PlaySoundParams playSoundParams = PlaySoundParams.Create();

            playSoundParams.Priority           = 64;
            playSoundParams.Loop               = true;
            playSoundParams.VolumeInSoundGroup = 1f;
            playSoundParams.FadeInSeconds      = FadeVolumeDuration;
            playSoundParams.SpatialBlend       = 0f;
            s_MusicSerialId = soundComponent.PlaySound(AssetUtility.GetMusicAsset(assetName), "Music", Constant.AssetPriority.MusicAsset, playSoundParams, null, userData);
            return(s_MusicSerialId);
        }