Esempio n. 1
0
 public MusicData(string name, string rname, float v, bool unload)
 {
     Id           = (int)FTUID.StringGetHashCode(name);
     resourceName = rname;
     volume       = v;
     isunload     = unload;
 }
Esempio n. 2
0
    //分配一个游戏对象
    public bool AllocObject(string keyName, out T obj)
    {
        obj = default(T);
        List <T> objList;
        uint     key = FTUID.StringGetHashCode(keyName);

        try
        {
            if (!objectBuffer.TryGetValue(key, out objList))
            {
                return(false);
            }
            if (objList.Count == 0)
            {
                return(false);
            }
            obj = objList[0];
            objList.RemoveAt(0);
            return(true);
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.ToString());
        }
        return(false);
    }
 public SoundEffectData(string name, string rname, float v, bool language, AudioSource player)
 {
     Id           = (int)FTUID.StringGetHashCode(name);
     resourceName = rname;
     volume       = v;
     playerSource = player;
     isLanguage   = language;
 }
Esempio n. 4
0
 public MusicGroup(params string[] musicname)
 {
     for (int i = 0; i < musicname.Length; i++)
     {
         int       id        = (int)FTUID.StringGetHashCode(musicname[i]);
         MusicData musciData = MusicPlayer.FindMusic(id);
         musicList.Add(musciData);
     }
 }
    static SoundEffectData FindSoundEffect(string name)
    {
        SoundEffectData ret;

        if (!soundEffectList.TryGetValue((int)FTUID.StringGetHashCode(name), out ret))
        {
            return(null);
        }
        return(ret);
    }
Esempio n. 6
0
    static public void Loading(string name)
    {
        int id = (int)FTUID.StringGetHashCode(name);

        if (currentMusicData != null && currentMusicData.Id == id)
        {
            return;
        }
        currentMusicData = FindMusic(id);
        if (currentMusicData == null)
        {
            return;
        }
        if (musicPlayer == null)
        {
            return;
        }
        if (musicPlayer.audioSource == null)
        {
            return;
        }
        AudioClip sound = null;

        if (currentMusicData.sound != null)
        {
            sound = currentMusicData.sound;
        }
        else
        {
            sound = UniGameResources.currentUniGameResources.LoadResource_AudioClip(currentMusicData.resourceName);
        }
        if (sound == null)
        {
            return;
        }
        musicPlayer.audioSource.Stop();
        if (musicPlayer.audioSource.clip != null)
        {
            //如果被标记为不卸载则不卸载了
            if (!musicPlayer.IsCurrentAudioUnLoad)
            {
                UniGameResources.ReleaseOneAssets(musicPlayer.audioSource.clip);
            }
            musicPlayer.audioSource.clip = null;
        }
        musicPlayer.audioSource.clip   = sound;
        musicPlayer.audioSource.volume = 0.0f;
        musicPlayer.audioSource.Play();
        musicPlayer.audioSource.Stop();
        //标记这个资源是否不卸载
        musicPlayer.IsCurrentAudioUnLoad = currentMusicData.isunload;
        currentMusicData = null;
    }
Esempio n. 7
0
    //托管一个游戏对象
    public void TrusteeshipObject(string keyName, T obj)
    {
        List <T> objList;
        uint     key = FTUID.StringGetHashCode(keyName);

        try
        {
            if (!objectBuffer.TryGetValue(key, out objList))
            {
                objList = new List <T>(128);
                objectBuffer.Add(key, objList);
            }
            objList.Add(obj);
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.ToString());
        }
    }
Esempio n. 8
0
    public List <T> GetObjectBuffer(string keyName)
    {
        List <T> objList;
        uint     key = FTUID.StringGetHashCode(keyName);

        try
        {
            if (!objectBuffer.TryGetValue(key, out objList))
            {
                return(null);
            }
            return(objList);
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.ToString());
        }
        return(null);
    }
Esempio n. 9
0
    static public void Play(string name, bool immediatelyPlay)
    {
        int id = (int)FTUID.StringGetHashCode(name);

        Play(id, immediatelyPlay);
    }