Exemplo n.º 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]);
    }
Exemplo n.º 2
0
Arquivo: Game.cs Projeto: 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);
    }
Exemplo n.º 3
0
    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;
    }