Beispiel #1
0
    /* public static E_GameResType GetResType(int type)
     * {
     *   E_GameResType res_type = E_GameResType.MUSIC_SOUND;
     *   if (instance == null) return res_type;
     *   instance._sound_type.TryGetValue(type, out res_type);
     *   return res_type;
     * }*/


    #endregion

    #region Play

    /// <summary>
    /// TODO 零时增加了一个接口,为了零时
    /// </summary>
    public AudioUnit Play(int id, int sound_max = 100, float fade_in = 0f, float fade_out = 0f)
    {
        if (id == -1)
        {
            return(null);
        }
        SoundCnf info = _find_sound_by_id(id);

        if (info == null || info.name == INVALID_SOUND)
        {
            return(null);
        }
        Debug.Log(info.name);
        // TODO 是有问题的,多个重复的声音的情况下,得到的会是同一个
        if (sound_max == 1 && _contains(id) >= 0)
        {
            int index = _contains(id);
            return(_list[index]);
        }
        else if (sound_max == 100) //不做如何处理
        {
        }
        else // 计算最大数量
        {
            int count = _contains_count(id);
            if (count > sound_max) //TODO 吊柜的逻辑哦
            {
                return(null);
            }
        }
        return(_internal_play(info, fade_in, fade_out));
    }
Beispiel #2
0
    public AudioUnit Play(string sound_name)
    {
        SoundCnf info = _find_sound_by_name(sound_name);

        if (info == null || info.name == INVALID_SOUND)
        {
            return(null);
        }

        return(_internal_play(info, 0f, 0f));
    }
Beispiel #3
0
    public AudioUnit _internal_play(SoundCnf info, float fade_in, float fade_out)
    {
        I_PoolObjectAbility object_ability = _pool_factory.Pop();
        AudioUnit           unit           = object_ability as AudioUnit;

        if (unit != null)
        {
            _list.Add(unit);
            unit.Play(info, SoundVolume, fade_in, fade_out);
        }
        else
        {
            LogManager.Error("_internal_play Error");
        }

        return(unit);
    }
Beispiel #4
0
    public void PlayBgm(int id, bool is_scene = false, float fade_in = 1.5f, float fade_out = 1.5f)
    {
        if (id == -1)
        {
            return;
        }
        if (id == _prev_bgm)
        {
            return;
        }
        SoundCnf sound_cnf = _find_sound_by_id(id);

        if (sound_cnf == null)
        {
            return;
        }
        _bgm_unit.Play(sound_cnf, BgmVolume, fade_in, fade_out);
        if (is_scene)
        {
            _prev_bgm = id;
        }
    }