示例#1
0
    public ByteArray GetProtoBytes(string file)
    {
        if (!_protoBytes.ContainsKey(file))
        {
            if (LGameConfig.GetInstance().isDebug)
            {
                LArchiveBinFile cArc        = new LArchiveBinFile();
                string          strFullPath = LGameConfig.GetInstance().GetLoadUrl(LGameConfig.DATA_CATAGORY_LUA + "/Game/Proto/" + file + ".bytes");

                if (!cArc.Open(strFullPath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                {
                    return(null);
                }

                if (!cArc.IsValid())
                {
                    return(null);
                }
                int    nContentLength = (int)cArc.GetStream().Length;
                byte[] aContents      = new byte[nContentLength];
                cArc.ReadBuffer(ref aContents, nContentLength);
                cArc.Close();
                _protoBytes.Add(file, new ByteArray(aContents));
            }
            else
            {
                TextAsset asset = LLoadBundle.GetInstance().LoadAsset <TextAsset>("@lua.ab", "@Lua/Game/Proto/" + file + ".bytes");
                _protoBytes.Add(file, new ByteArray(asset.bytes));
            }
        }

        return(_protoBytes[file]);
    }
示例#2
0
文件: Game.cs 项目: memsyi/uLui
    protected byte[] loadFileWithSuffix(string strFile)
    {
        if (string.IsNullOrEmpty(strFile))
        {
            return(null);
        }

        strFile.Replace(".", "/");
        strFile += LGameConfig.FILE_AFFIX_LUA;

        string strLuaPath  = LGameConfig.DATA_CATAGORY_LUA + Path.DirectorySeparatorChar + strFile;
        string strFullPath = LGameConfig.GetInstance().GetLoadUrl(strLuaPath);
        // Read from file.
        LArchiveBinFile cArc = new LArchiveBinFile();

        if (!cArc.Open(strFullPath, FileMode.Open, FileAccess.Read))
        {
            return(null);
        }

        if (!cArc.IsValid())
        {
            return(null);
        }

        int nContentLength = (int)cArc.GetStream().Length;

        byte[] aContents = new byte[nContentLength];
        cArc.ReadBuffer(ref aContents, nContentLength);
        cArc.Close();

        return(aContents);
    }
示例#3
0
文件: Game.cs 项目: Ribosome2/uLui
    protected byte[] loadFileWithSuffix(string strFile)
    {
        if (string.IsNullOrEmpty(strFile))
        {
            return null;
        }

        strFile.Replace(".", "/");
        strFile += LGameConfig.FILE_AFFIX_LUA;

        string strLuaPath = LGameConfig.DATA_CATAGORY_LUA + Path.DirectorySeparatorChar + strFile;
        string strFullPath = LGameConfig.GetInstance().GetLoadUrl(strLuaPath);
        // Read from file.
        LArchiveBinFile cArc = new LArchiveBinFile();
        if (!cArc.Open(strFullPath, FileMode.Open, FileAccess.Read))
        {
            return null;
        }

        if (!cArc.IsValid())
        {
            return null;
        }

        int nContentLength = (int)cArc.GetStream().Length;
        byte[] aContents = new byte[nContentLength];
        cArc.ReadBuffer(ref aContents, nContentLength);
        cArc.Close();

        return aContents;
    }