Beispiel #1
0
    public override void init(ComponentOwner owner)
    {
        base.init(owner);
        // 通知子类设置自己的音效类型
        setSoundOwner();
        // 如果音效还未加载,则加载所有音效,此处只是注册
        if (mAudioTypeMap.Count == 0)
        {
            int dataCount = mDataBase.getDataCount(DATA_TYPE.DT_GAME_SOUND);
            for (int i = 0; i < dataCount; ++i)
            {
                DataGameSound soundData = mDataBase.queryData(DATA_TYPE.DT_GAME_SOUND, i) as DataGameSound;
                string        soundName = BinaryUtility.bytesToString(soundData.mSoundFileName);
                mAudioTypeMap.Add(soundName, soundData.mSoundType);
                mSoundDefineMap.Add((SOUND_DEFINE)(soundData.mSoundID), soundName);
                mAudioManager.createAudio(soundName, false);
            }
        }

        // 清空所有类型正在播放的音效
        for (int i = 0; i < mMaxChannel; ++i)
        {
            mCurPlayList.Add(i, "");
        }
    }
 public bool mUseVolumeCoe = true;                   // 是否启用数据表格中的音量系数
 public CommandWindowPlayAudio()
 {
     if (mVolumeCoe == null)
     {
         mVolumeCoe = new Dictionary <SOUND_DEFINE, float>();
         int dataCount = mDataBase.getDataCount(DATA_TYPE.DT_GAME_SOUND);
         for (int i = 0; i < dataCount; ++i)
         {
             DataGameSound gameSound = mDataBase.queryData(DATA_TYPE.DT_GAME_SOUND, i) as DataGameSound;
             if (!mVolumeCoe.ContainsKey((SOUND_DEFINE)gameSound.mSoundID))
             {
                 mVolumeCoe.Add((SOUND_DEFINE)gameSound.mSoundID, gameSound.mVolumeCoe);
             }
         }
     }
 }
Beispiel #3
0
    public override void init()
    {
        int dataCount = mDataBase.getDataCount(DATA_TYPE.DT_GAME_SOUND);

        for (int i = 0; i < dataCount; ++i)
        {
            DataGameSound soundData = mDataBase.queryData(DATA_TYPE.DT_GAME_SOUND, i) as DataGameSound;
            string        soundName = BinaryUtility.bytesToString(soundData.mSoundFileName);
            string        audioName = StringUtility.getFileNameNoSuffix(soundName, true);
            SOUND_DEFINE  soundID   = (SOUND_DEFINE)(soundData.mSoundID);
            mSoundDefineMap.Add(soundID, audioName);
            if (!mVolumeScale.ContainsKey(soundID))
            {
                mVolumeScale.Add(soundID, soundData.mVolumeScale);
            }
            registeAudio(soundName);
        }
    }
Beispiel #4
0
    public override void init()
    {
        // 从SQlite数据库中查询音效信息
        bool findInSQLite = false;

        if (mSQLiteSound != null)
        {
            List <SoundData> soundDataList;
            mSQLiteSound.queryAll(out soundDataList);
            int dataCount = soundDataList.Count;
            for (int i = 0; i < dataCount; ++i)
            {
                SoundData    soundData = soundDataList[i];
                string       audioName = getFileNameNoSuffix(soundData.mFileName, true);
                SOUND_DEFINE soundID   = (SOUND_DEFINE)(soundData.mID);
                mSoundDefineMap.Add(soundID, audioName);
                if (!mVolumeScale.ContainsKey(soundID))
                {
                    mVolumeScale.Add(soundID, soundData.mVolumeScale);
                }
                registeAudio(soundData.mFileName);
            }
            findInSQLite = dataCount > 0;
        }
        // 数据库中查不到,则从自定义的数据表格中查询
        if (!findInSQLite)
        {
            int dataCount = mDataBase.getDataCount(DATA_TYPE.DT_GAME_SOUND);
            for (int i = 0; i < dataCount; ++i)
            {
                DataGameSound soundData = mDataBase.queryData(DATA_TYPE.DT_GAME_SOUND, i) as DataGameSound;
                string        soundName = bytesToString(soundData.mSoundFileName);
                string        audioName = getFileNameNoSuffix(soundName, true);
                SOUND_DEFINE  soundID   = (SOUND_DEFINE)(soundData.mSoundID);
                mSoundDefineMap.Add(soundID, audioName);
                if (!mVolumeScale.ContainsKey(soundID))
                {
                    mVolumeScale.Add(soundID, soundData.mVolumeScale);
                }
                registeAudio(soundName);
            }
        }
    }
Beispiel #5
0
 public override void init(ComponentOwner owner)
 {
     base.init(owner);
     // 通知子类设置自己的音效类型
     setSoundOwner();
     // 如果音效还未加载,则加载所有音效,此处只是注册
     if (mSoundDefineMap.Count == 0)
     {
         int dataCount = mDataBase.getDataCount(DATA_TYPE.DT_GAME_SOUND);
         for (int i = 0; i < dataCount; ++i)
         {
             DataGameSound soundData = mDataBase.queryData(DATA_TYPE.DT_GAME_SOUND, i) as DataGameSound;
             string        soundName = BinaryUtility.bytesToString(soundData.mSoundFileName);
             string        audioName = StringUtility.getFileNameNoSuffix(soundName, true);
             mSoundDefineMap.Add((SOUND_DEFINE)(soundData.mSoundID), audioName);
             mAudioManager.createAudio(soundName, false);
         }
     }
 }