Beispiel #1
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);
    }