Esempio n. 1
0
    public static SoundProfile GetSoundProfile(Int32 soundIndex, SoundProfileType type)
    {
        String text = String.Empty;

        switch (type)
        {
        case SoundProfileType.Music:
            text = SoundMetaData.MusicIndex[soundIndex];
            break;

        case SoundProfileType.SoundEffect:
            text = SoundMetaData.SoundEffectIndex[soundIndex];
            break;

        case SoundProfileType.MovieAudio:
            text = SoundMetaData.MovieAudioIndex[soundIndex];
            break;

        case SoundProfileType.Song:
            text = SoundMetaData.SongIndex[soundIndex];
            break;

        case SoundProfileType.Sfx:
            SoundLib.Log("GetSoundProfile does not support type SoundProfileType.Sfx");
            return((SoundProfile)null);
        }
        return(new SoundProfile
        {
            Code = soundIndex.ToString(),
            Name = text,
            SoundIndex = soundIndex,
            ResourceID = text,
            SoundProfileType = type
        });
    }
Esempio n. 2
0
 public void SetActiveSoundType(SoundProfileType type)
 {
     if (this.activeSound != null)
     {
         SoundLib.StopMusic();
         this.IsPlay = false;
     }
     this.activeType      = type;
     this.currentPlaylist = 0;
     this.GeneratePlaylistData(this.currentPlaylist);
     if (this.playlist != null)
     {
         if (this.playlist.Count > 0)
         {
             this.activeSound = this.playlist[0];
         }
     }
     else
     {
         SoundLib.LogWarning("SetActiveSoundType, playlist is null!");
     }
     if (type == SoundProfileType.Sfx)
     {
     }
 }
Esempio n. 3
0
    public void PlayMusic(Int32 soundIndex, Int32 fadeIn, SoundProfileType type = SoundProfileType.Music)
    {
        SoundProfile soundProfile = this.soundDatabase.Read(soundIndex);

        if (soundProfile == null)
        {
            soundProfile = this.onTheFlySoundDatabase.Read(soundIndex);
        }
        if (soundProfile != null)
        {
            this.PlayMusic(soundProfile, fadeIn);
        }
        else
        {
            soundProfile = SoundMetaData.GetSoundProfile(soundIndex, type);
            this.onTheFlyLoadedSoundProfile = soundProfile;
            this.onTheFlyLoadedFadeIn       = fadeIn;
            if (this.onTheFlySoundDatabase.ReadAll().Count >= 10)
            {
                SoundLib.Log("Unload on the fly sound database.");
                base.UnloadResource(this.onTheFlySoundDatabase);
            }
            base.LoadResource(soundProfile, this.onTheFlySoundDatabase, new SoundPlayer.LoadResourceCallback(this.LoadOnTheFlySoundResourceCallback));
        }
    }
Esempio n. 4
0
 public static Int32 GetSoundIndex(String soundName, SoundProfileType type)
 {
     if (type != SoundProfileType.MovieAudio)
     {
         SoundLib.Log("No implementation");
         return(-1);
     }
     if (SoundMetaData.MovieAudioStringIndex.ContainsKey(soundName))
     {
         return(SoundMetaData.MovieAudioStringIndex[soundName]);
     }
     SoundLib.Log("Movie audio, Name: " + soundName + " not found!");
     return(-1);
 }
Esempio n. 5
0
    protected void PlaySoundEffect(Int32 soundIndex, Single soundVolume = 1f, Single panning = 0f, Single pitch = 1f, SoundProfileType type = SoundProfileType.SoundEffect)
    {
        SoundProfile soundProfile = this.gameSoundDatabase.Read(soundIndex);

        if (soundProfile == null)
        {
            soundProfile = this.sceneSoundDatabase.Read(soundIndex);
        }
        if (soundProfile == null)
        {
            soundProfile = this.onTheFlySoundDatabase.Read(soundIndex);
        }
        if (soundProfile != null)
        {
            soundProfile.SoundVolume = soundVolume * this.playerVolume;
            soundProfile.Panning     = panning;
            soundProfile.Pitch       = pitch;
            this.activeSoundEffect   = soundProfile;
            this.PlaySoundEffect(soundProfile);
        }
        else
        {
            SoundLib.Log(String.Empty + soundIndex + " is not exist");
            soundProfile             = SoundMetaData.GetSoundProfile(soundIndex, type);
            soundProfile.SoundVolume = soundVolume * this.playerVolume;
            soundProfile.Panning     = panning;
            soundProfile.Pitch       = pitch;
            if (soundProfile == null)
            {
                SoundLib.LogError("soundIndex: " + soundIndex + " is not exist");
                return;
            }
            this.activeSoundEffect = soundProfile;
            if (this.onTheFlySoundDatabase.ReadAll().Count >= 20)
            {
                SoundLib.Log("Unload on the fly sound database.");
                base.UnloadResource(this.onTheFlySoundDatabase);
            }
            base.LoadResource(soundProfile, this.onTheFlySoundDatabase, new SoundPlayer.LoadResourceCallback(this.LoadOnTheFlySoundResourceCallback));
        }
    }