예제 #1
0
        private void onReceiveSocket()
        {
            while (true)
            {
                if (!_clientSocket.Connected)
                {
                    break;
                }

                try {
                    int receiveLength = _clientSocket.Receive(_result);

                    if (receiveLength > 0)
                    {
                        ByteBuffer buffer  = new ByteBuffer(_result);
                        int        command = buffer.ReadInt();
                        byte[]     data    = buffer.ReadBytes();
                        DebugManager.Log("服务器指令:" + command);

                        OnReceiveMessage(command, data);
                    }
                } catch (Exception e) {
                    DebugManager.Log(e.Message);
                }
            }
        }
예제 #2
0
파일: LuaLoader.cs 프로젝트: yhjsspz/root
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private byte[] GetLuaBytes(string fileName)
        {
            DebugManager.Log("GetLuaBytes:" + fileName);
            byte[] buffer = null;

            fileName = fileName.ToLower();

            if (!fileName.EndsWith(".lua"))
            {
                fileName += ".lua";
            }

            fileName = fileName.Replace(".lua", ".bytes");

            string assetName = fileName;

            int pos = fileName.LastIndexOf('/');

            if (pos > 0)
            {
                fileName  = fileName.Substring(0, pos) + ".bytes";
                assetName = assetName.Substring(pos + 1);
            }

            AssetBundle zipFile = null;
            TextAsset   luaCode = null;

            if (zipMap.ContainsKey(fileName) == true)
            {
                zipFile = zipMap[fileName];
            }

            if (zipFile == null)
            {
                string[] rootArr = new string[] { "tolua.bytes", "luaroot.bytes" };

                for (int i = 0; i < rootArr.Length; i++)
                {
                    zipFile = zipMap[rootArr[i]];
                    luaCode = zipFile.LoadAsset <TextAsset>(assetName);

                    if (luaCode != null)
                    {
                        break;
                    }
                }
            }
            else
            {
                luaCode = zipFile.LoadAsset <TextAsset>(assetName);
            }

            if (luaCode != null)
            {
                buffer = luaCode.bytes;
                Resources.UnloadAsset(luaCode);
            }

            return(buffer);
        }
예제 #3
0
파일: BaseScene.cs 프로젝트: yhjsspz/root
        private void InitLayer(Transform transform)
        {
            foreach (Transform view in transform)
            {
                DebugManager.Log("InitLayer:" + view.name);
                if (view.name.Equals("TipLayer"))
                {
                    TipLayer = view;
                }
                else if (view.name.Equals("GuideLayer"))
                {
                    GuideLayer = view;
                }
                else if (view.name.Equals("WindowLayer"))
                {
                    WindowLayer = view;
                }
                else if (view.name.Equals("SysLayer"))
                {
                    SysLayer = view;
                }

                if (view.childCount > 0)
                {
                    InitLayer(view);
                }
            }
        }
예제 #4
0
        public void DisposeViewCache(string viewId)
        {
            DebugManager.Log("DisposeViewCache:" + viewId);

            if ("LoadingWindow".Equals(viewId))
            {
                return;
            }

            List <string> unDisposeList = new List <string>();

            foreach (string id in _dependDic.Keys)
            {
                if (id != viewId)
                {
                    foreach (string path in _dependDic[id])
                    {
                        unDisposeList.Add(path);
                    }
                }
            }

            foreach (string path in _dependDic[viewId].Except(unDisposeList))
            {
                if (_bundleDic.ContainsKey(path))
                {
                    AssetBundle ab = _bundleDic[path];
                    _bundleDic.Remove(path);
                    DebugManager.Log("释放资源:" + path);
                    ab.Unload(true);
                }
            }
            _dependDic.Remove(viewId);
        }
예제 #5
0
 /// <summary>
 /// 异步加载预制体
 /// </summary>
 /// <param name="viewId"></param>
 /// <param name="path"></param>
 /// <param name="callback"></param>
 public void LoadPrefabAsync(string viewId, string[] pathList, Action <List <AssetBundle> > callback)
 {
     StartCoroutine(LoadListAsyncCoroutine(viewId, pathList, delegate(List <AssetBundle> assetBundle) {
         DebugManager.Log("-------------------load list end:");
         callback(assetBundle);
     }));
 }
예제 #6
0
        /// <summary>
        /// 解压安装包资源
        /// </summary>
        public void Compress()
        {
            //if (Application.platform == RuntimePlatform.WindowsEditor)
            //{
            //    _Txt_msg.text = "编辑模式不拷贝文件,不更新,直接进入程序初始化";
            //    DebugManager.Log(_Txt_msg.text);
            //    InitApp();
            //    return;
            //}

            _Txt_msg.text = "开始解压安装包资源";
            DebugManager.Log(_Txt_msg.text);

            FileInfo fi = new FileInfo(FileUtil.Instance.GetWritePath("file.t"));

            DebugManager.Log("是否初始化:" + fi.Exists);
            DebugManager.Log("file:" + fi.FullName);
            //判断文件是否存在
            if (!fi.Exists)
            {
                DebugManager.Log("================read file.t====================");
                DebugManager.Log(FileUtil.Instance.GetResPath("file.t"));
                WWW www = new WWW(FileUtil.Instance.GetResPath("file.t"));
                while (!www.isDone)
                {
                }

                string[] files = www.text.Split(new string[] { "\r\n" }, StringSplitOptions.None);

                www.Dispose();

                List <string> list = new List <string>(files);
                list.Add("file.t");
                string[] newFiles = list.ToArray();

                _copyNum    = newFiles.Length;
                _copyNumCur = 0;

                CopyStreamingFileToPersistentDataPath(newFiles, delegate() {
                    //资源解压完成

                    StartCoroutine(StartUpdate());
                });
            }
            else
            {
                //TODO 检查更新
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    StartCoroutine(StartUpdate());
                    //InitApp();
                }
                else
                {
                    StartCoroutine(StartUpdate());
                }
            }
        }
예제 #7
0
 private void ShowAbList()
 {
     DebugManager.Log("-----------------showAbList---------------");
     foreach (string key in _bundleDic.Keys)
     {
         DebugManager.Log(key);
     }
     DebugManager.Log("-----------------showAbList   end---------------");
 }
예제 #8
0
파일: SdkManager.cs 프로젝트: yhjsspz/root
        /// <summary>
        ///
        /// </summary>
        public void CallSdk(int num, LuaFunction updateCallback)
        {
            callback = updateCallback;
            AndroidJavaClass  jc = new AndroidJavaClass("com.test.UnityPlayerActivity");
            AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("sdkManager");

            DebugManager.Log("调用sdk:" + jo.ToString());
            string r = jo.Call <string>("androidTest", "GameManager", num.ToString(), "BeCallFunc");

            DebugManager.Log("sdk回返回:" + r);
        }
예제 #9
0
        private void AddCache(string viewId, string path, AssetBundle assetBundle)
        {
            DebugManager.Log("----------load prefab success:" + path + "," + (assetBundle == null));

            if (!_dependDic.ContainsKey(viewId))
            {
                _dependDic.Add(viewId, new List <string>());
            }

            _dependDic[viewId].Add(path);
            _bundleDic.Add(path, assetBundle);
        }
예제 #10
0
        /// <summary>
        ///
        /// </summary>
        void Start()
        {
            if (this._table != null)
            {
                DebugManager.Log(_baseView.Id + " Start");
                LuaFunction fun = this._table.GetLuaFunction("OnStart");

                if (fun != null)
                {
                    fun.Call(this._table);
                }
            }
        }
예제 #11
0
        /// <summary>
        /// 安卓端复制文件
        /// </summary>
        /// <param name="fileName">文件路径</param>
        /// <returns></returns>
        IEnumerator CopyFile_Android(string path, string fileName, Action completeAction)
        {
            string sourcePath = path + fileName;
            string toPath     = FileUtil.Instance.GetWritePath(fileName);

            DebugManager.Log("Start CopyFile ======>" + sourcePath + " to:" + toPath);

            WWW w = new WWW(sourcePath);

            yield return(w);

            if (w.error == null)
            {
                FileInfo      fi         = new FileInfo(toPath);
                DirectoryInfo dictionary = fi.Directory;

                if (!dictionary.Exists)
                {
                    DebugManager.Log("create dir:" + dictionary.Name);
                    dictionary.Create();
                }


                //判断文件是否存在
                if (!fi.Exists)
                {
                    FileStream fs = fi.Create();

                    fs.Write(w.bytes, 0, w.bytes.Length);

                    fs.Flush();

                    fs.Close();

                    fs.Dispose();

                    DebugManager.Log("----- CopyFile Success! ======> " + fi.FullName);
                }
            }
            else
            {
                DebugManager.Log("Error : ======> " + w.error);
            }
            _copyNumCur++;
            DebugManager.Log("+++++++++++++++++++++++progress:" + _copyNumCur + "/" + _copyNum);
            if (_copyNumCur == _copyNum)
            {
                completeAction();
            }
            w.Dispose();
        }
예제 #12
0
        /// <summary>
        /// 初始化游戏
        /// </summary>
        public void InitApp()
        {
            _Txt_msg.text = "开始初始化游戏,准备进入游戏";
            DebugManager.Log(_Txt_msg.text);

            SceneManagerEx.Instance.Init();
            ResourceManager.Instance.Init();
            LuaManager.Instance.Init();
            NetworkManager.Instance.Init();
            TimerManager.Instance.Init();
            SdkManager.Instance.Init();

            LuaManager.Instance.Startup();


            //NetworkManager.Instance.ConnectServer("127.0.0.1", 8088);
            //NetworkManager.Instance.SendMessage(10011, "");
        }
예제 #13
0
파일: FileUtil.cs 프로젝트: yhjsspz/root
        /// <summary>
        /// 从一个目录将其内容复制到另一目录
        /// </summary>
        /// <param name="directorySource">源目录</param>
        /// <param name="directoryTarget">目标目录</param>
        public void CopyFolderTo(string directorySource, string directoryTarget)
        {
            if (directorySource.StartsWith("/"))
            {
                directorySource = directorySource.Substring(1);
            }
            //检查是否存在目的目录
            if (!Directory.Exists(directorySource))
            {
#if UNITY_ANDROID
#elif UNITY_IPHONE
#else
                DebugManager.Log("==========================创建源目录:");
                Directory.CreateDirectory(directorySource);
#endif
            }
            if (!Directory.Exists(directoryTarget))
            {
                Directory.CreateDirectory(directoryTarget);
            }

            DebugManager.Log("CopyFolderSource:" + directorySource);
            DebugManager.Log("CopyFolderTo:" + directoryTarget);

            //先来复制文件
            DirectoryInfo directoryInfo = new DirectoryInfo(directorySource);
            FileInfo[]    files         = directoryInfo.GetFiles();
            //复制所有文件
            foreach (FileInfo file in files)
            {
                string toPath = directoryTarget;
                if (!Directory.Exists(toPath))
                {
                    Directory.CreateDirectory(toPath);
                }
                file.CopyTo(Path.Combine(toPath, file.Name), true);
            }
            //最后复制目录
            DirectoryInfo[] directoryInfoArray = directoryInfo.GetDirectories();
            foreach (DirectoryInfo dir in directoryInfoArray)
            {
                CopyFolderTo(Path.Combine(directorySource, dir.Name), Path.Combine(directoryTarget, dir.Name));
            }
        }
예제 #14
0
        public void CopyFiles(string sourcePath, string[] files, Action completeAction)
        {
            if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)                    //如果是Android平台
            {
                foreach (string path in files)
                {
                    StartCoroutine(CopyFile_Android(sourcePath, path.Split('|')[0], completeAction));
                }
            }
            else if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)          //如果是Windows平台
            {
                sourcePath = sourcePath.Replace("file://", "");
                foreach (string path in files)
                {
                    string _path = path.Split('|')[0];
                    if (path.Equals(""))
                    {
                        continue;
                    }
                    try
                    {
                        DebugManager.Log("Start CopyFile ======>" + sourcePath + _path + " to:" + FileUtil.Instance.GetWritePath(_path));

                        string toPath = FileUtil.Instance.GetWritePath(_path);
                        string toDir  = toPath.Substring(0, toPath.LastIndexOf("/"));

                        if (!Directory.Exists(toDir))
                        {
                            Directory.CreateDirectory(toDir);
                        }

                        File.Copy(sourcePath + _path, FileUtil.Instance.GetWritePath(_path), true);
                    }
                    catch (Exception e)
                    {
                        DebugManager.LogError("Copy file Error:" + path);
                        DebugManager.LogError(e.Message);
                    }
                    DebugManager.Log("CopyFile Success! ======> " + FileUtil.Instance.GetWritePath(_path));
                }
                completeAction();
            }
        }
예제 #15
0
        public Transform AddChild(Transform parent, Transform go, string preStr = null)
        {
            DebugManager.Log("AddChild:" + go.name + "," + preStr);
            if (preStr != null)
            {
                go.name = preStr + "_" + go.name;
                FormatChildName(go, preStr);
            }

            go.transform.parent = parent.transform;

            initView(go);

            LuaComponent luaComponent = _uiRoot.GetComponent <LuaComponent>();

            luaComponent.UpdateControlBind();

            return(go);
        }
예제 #16
0
        /// <summary>
        /// 检测md5并更新文件
        /// </summary>
        IEnumerator CheckAndUpdateFile()
        {
            //从服务器下载file.t, 检测文件是否存在和有没改变过,如果有变化则从服务器重新下载该文件并覆盖
            string cdnUrl = "file://F:/LocalSvn/TestCdnServer/";

            WWW www = new WWW(FileUtil.Instance.GetWritePath("file.t"));

            yield return(www);

            DebugManager.Log("打开file.t:" + FileUtil.Instance.GetWritePath("file.t"));
            DebugManager.Log("打开file.t:" + www.text);
            string[] files = www.text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            //TODO 检验md5
            DebugManager.Log("检测md5并更新文件:" + www.text);
            CopyFiles(cdnUrl, files, delegate() {
                InitApp();
            });

            www.Dispose();
        }
예제 #17
0
        /// <summary>
        ///
        /// </summary>
        void OnDestroy()
        {
            if (this._table != null)
            {
                DebugManager.Log(_baseView.Id + " Destroy");
                LuaFunction fun = this._table.GetLuaFunction("Destroy");

                if (fun != null)
                {
                    fun.Call(this._table);
                }

                this._table.Dispose();
                this._table = null;
            }

            if (this._baseView != null)
            {
                this._baseView.Dispose();
                this._baseView = null;
            }
        }
예제 #18
0
        public void TestLua()
        {
            //this._lua.DoFile("test.lua");
            this._lua.DoString(@"
                local cla = {1,2,3,4,5}
                function F1()

                 print(333333333333333333333)


                end

            ");

            //LuaFunction lf = this._lua.GetFunction("Main1");
            //lf.Call();

            DebugManager.Log("//////cla////////" + (this._lua.GetTable("cla") == null).ToString());
            //Debug.Log("//////////////" + (this._lua.GetTable("s1") == null).ToString());

            //return this._lua.GetTable("LoginScene");
        }
예제 #19
0
        /// <summary>
        /// 检查游戏更新
        /// </summary>
        IEnumerator StartUpdate()
        {
            _Txt_msg.text = "解压安装包资源完成, 开始检查游戏更新";
            DebugManager.Log(_Txt_msg.text);

            string cdnUrl = "file://F:/LocalSvn/TestCdnServer/";

            WWW www = new WWW(cdnUrl + "version.t");

            yield return(www);

            DebugManager.Log("server version:" + www.text);

            string serverVersion = www.text;

            www.Dispose();

            www = new WWW(FileUtil.Instance.GetWritePath("version.t"));

            yield return(www);

            if (serverVersion.Equals(www.text))
            {
                //版本一致,进入下一步
                _Txt_msg.text = "更新版本完成";
                DebugManager.Log(_Txt_msg.text);
                InitApp();
            }
            else
            {
                _Txt_msg.text = "检测到新版本,准备更新";
                DebugManager.Log(_Txt_msg.text);
                CopyFiles(cdnUrl, new string[] { "file.t" }, delegate() {
                    StartCoroutine(CheckAndUpdateFile());
                });
            }
            www.Dispose();
        }
예제 #20
0
        /// <summary>
        ///
        /// </summary>
        public void New(LuaTable table, BaseView baseView)
        {
            this._table    = table;
            this._baseView = baseView;

            if (this._baseView != null)
            {
                this._baseView.LuaBehaviour = this;
            }

            if (this._table != null)
            {
                DebugManager.Log(_baseView.Id + " Awake");
                LuaFunction fun = this._table.GetLuaFunction("OnAwake");

                if (fun != null)
                {
                    fun.Call(this._table, baseView);
                }
            }

            this.UpdateControlBind();
        }
예제 #21
0
        IEnumerator DoRegisterPB(LuaFunction processCallback, LuaFunction completeCallback)
        {
            string configFilePath = "";
            string pbDir          = "";

            if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
            {
                pbDir = FileUtil.Instance.GetWritePath("protobuf/");
            }
            else
            {
                pbDir = FileUtil.Instance.GetAssetsPath("GameApp/Protobuf/").Replace("file://", "");
            }

            configFilePath = pbDir + "proto.config";

            Debugger.Log(configFilePath);

            string configFileStr = "";

            if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
            {
                WWW www = new WWW(configFilePath);

                yield return(www);

                if (www.isDone)
                {
                    configFileStr = www.text;

                    yield return(0);
                }
                else
                {
                    DebugManager.LogError("DoRegisterPB Error:读取文件错误!" + configFilePath);
                }

                www.Dispose();
            }
            else
            {
                if (File.Exists(configFilePath) == true)
                {
                    try
                    {
                        configFileStr = File.ReadAllText(configFilePath);
                    }
                    catch (Exception e)
                    {
                        DebugManager.LogError("DoRegisterPB Error:读取配置文件错误!" + e.Message);

                        yield break;
                    }
                }
                else
                {
                    DebugManager.LogError("DoRegisterPB Error:读取文件错误!" + configFilePath);
                }
            }

            DebugManager.Log("configFileStr:" + configFileStr);

            string[] pClassCommandList = configFileStr.Split(',');

            string fpath = pbDir + "message.pb";

            DebugManager.Log("读取注册PB文件:" + fpath);

            if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
            {
                WWW www = new WWW(fpath);

                yield return(www);

                if (www.isDone)
                {
                    ByteBuffer data = new ByteBuffer(www.bytes);

                    processCallback.Call(data);
                    data.Close();

                    yield return(0);
                }
                else
                {
                    DebugManager.LogError("DoRegisterPB Error:读取文件错误!" + fpath);
                }

                www.Dispose();
            }
            else
            {
                try
                {
                    ByteBuffer data = new ByteBuffer(File.ReadAllBytes(fpath));
                    processCallback.Call(data);
                    data.Close();
                }
                catch (Exception e)
                {
                    DebugManager.LogError("DoRegisterPB Error:读取文件错误!" + fpath + "\n error:\n" + e.Message);
                }
            }

            completeCallback.Call(pClassCommandList);
            completeCallback.Dispose();

            processCallback.Dispose();
        }
예제 #22
0
파일: SdkManager.cs 프로젝트: yhjsspz/root
 //设置一个回掉方法
 private void BeCallFunc(string content)
 {
     DebugManager.Log("sdk回回调:" + content);
     callback.Call(content);
 }
예제 #23
0
        /// <summary>
        /// 加载场景
        /// </summary>
        /// <param name="loadingWindowClass"></param>
        /// <returns></returns>
        private IEnumerator LoadingScene(LuaTable loadingWindowClass)
        {
            int showProgress = 80;

            while (showProgress < 100)
            {
                if (showProgress < 30)
                {
                    showProgress++;

                    if (_progressCallback != null)
                    {
                        _progressCallback(showProgress);
                        loadingWindowClass.Call("OnProgress", loadingWindowClass, showProgress);
                        yield return(new WaitForEndOfFrame()); //等待一帧
                    }
                }
                else if (showProgress < 90)
                {
                    yield return(new WaitUntil(delegate()
                    {
                        return _preloadIsEnd;
                    }));

                    showProgress++;

                    if (_progressCallback != null)
                    {
                        _progressCallback(showProgress);
                        loadingWindowClass.Call("OnProgress", loadingWindowClass, showProgress);
                        yield return(new WaitForEndOfFrame()); //等待一帧
                    }
                }
                else
                {
                    yield return(new WaitUntil(delegate()
                    {
                        return _prog.progress >= 0.9f;
                    }));

                    showProgress++;
                    if (_progressCallback != null)
                    {
                        _progressCallback(showProgress);
                        loadingWindowClass.Call("OnProgress", loadingWindowClass, showProgress);
                        yield return(new WaitForEndOfFrame()); //等待一帧
                    }
                }
            }

            //-----------------------------预加载资源加载完成,进入场景------------------------------
            _prog.allowSceneActivation = true;  //如果加载完成,可以进入场景

            Scene scene = SceneManager.GetSceneByName(_id);

            yield return(new WaitUntil(delegate() {
                return scene.isLoaded;
            }));

            DebugManager.Log("enter scene:" + scene.name);

            GameObject[] objs = scene.GetRootGameObjects();

            foreach (GameObject go in objs)
            {
                DebugManager.Log("go.name:" + go.name);
                if (go.name.Equals("Canvas"))
                {
                    _loadBaseScene = new BaseScene(_id, _preloadList, _completeCallback, _progressCallback, _isCache, go.transform);
                    LuaComponent luaComponent = go.AddComponent <LuaComponent>();

                    luaComponent.New(_luaSceneClass, _loadBaseScene);

                    _completeCallback(_loadBaseScene);

                    this.CurrScene = _loadBaseScene;

                    _loadBaseScene = null;
                    _id            = null;
                    break;
                }
            }
        }
예제 #24
0
파일: AppEditor.cs 프로젝트: yhjsspz/root
        static void Build(BuildTarget buildTarget)
        {
            string U3D_CODE_ROOT = Environment.GetEnvironmentVariable("U3D_CODE_ROOT");
            string outputPath    = Replace((U3D_CODE_ROOT + "/StreamingAssets/src"));
            string tempPath      = Replace((U3D_CODE_ROOT + "/luaroot"));

            FileTool.CopyLuaFolderTo(Replace(U3D_CODE_ROOT + "/GameApp/Lua"), tempPath);
            FileTool.CopyLuaFolderTo(Replace(U3D_CODE_ROOT + "/Extends/Plugins/ToLua/Lua"), tempPath + "/tolua");

            AssetDatabase.Refresh();
            try
            {
                //检查是否存在目的目录
                if (Directory.Exists(outputPath))
                {
                    FileTool.DeleteAll(outputPath);

                    AssetDatabase.Refresh();
                }
                Directory.CreateDirectory(outputPath);
            }
            catch (Exception e)
            {
                DebugManager.Log(e.Message);
            }

            //FileTool.CopyFolderTo(U3D_CODE_ROOT + "/GameApp/Lua", U3D_CODE_ROOT + "/StreamingAssets/src/lua");
            //FileTool.CopyFolderTo(U3D_CODE_ROOT + "/GameApp/Lua", U3D_CODE_ROOT + "/StreamingAssets/src/lua");
            FileTool.CopyFolderTo(U3D_CODE_ROOT + "/GameApp/Protobuf", U3D_CODE_ROOT + "/StreamingAssets/src/protobuf");

            PackLuaDir(tempPath);

            //根据BuildSetting里面所激活的平台进行打包
            BuildPipeline.BuildAssetBundles(outputPath, 0, buildTarget);

            AssetDatabase.Refresh();
            //FileTool.DeleteAll(tempPath);

            //生成file文件
            string filePaht = U3D_CODE_ROOT + "/StreamingAssets/file.t";

            if (File.Exists(filePaht))
            {
                File.Delete(filePaht);
            }

            StreamWriter streamWriter = File.CreateText(filePaht);

            writeFile(U3D_CODE_ROOT + "\\StreamingAssets", streamWriter, Replace(U3D_CODE_ROOT + "/StreamingAssets/"));


            streamWriter.Close();

            //复制json文件
            FileTool.CopyLuaFolderTo(tempPath + "/config/battleSkill", outputPath + "/gameapp/lua/battleskill");

            //复制pb文件


            Debug.Log("生成lua完成");
        }
예제 #25
0
        /// <summary>
        ///
        /// </summary>
        private void InitLuaBundle()
        {
            if (this._loader.beZip == false)
            {
                return;
            }


            string[] files = null;

            if (Application.platform == RuntimePlatform.Android)
            {
                WWW www = new WWW(FileUtil.Instance.GetResPath("file.t"));
                while (!www.isDone)
                {
                }

                files = www.text.Split(new string[] { "\r\n" }, StringSplitOptions.None);

                www.Dispose();
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                WWW www = new WWW(FileUtil.Instance.GetResPath("file.t"));
                while (!www.isDone)
                {
                }

                DebugManager.Log("file.t content:" + www.text);

                files = www.text.Split(new string[] { "\r\n" }, StringSplitOptions.None);

                DebugManager.Log("files content:" + www.text);
                www.Dispose();
            }
            else
            {
                files = File.ReadAllLines(FileUtil.Instance.GetResPath("file.t"));
            }

            DebugManager.Log("file.t Length:" + files.Length);

            for (int i = 0; i < files.Length; i++)
            {
                string[] keyValue = files[i].Split('|');
                string   fileName = keyValue[0];

                DebugManager.Log("for file======>:" + fileName);
                if (Path.GetExtension(fileName) == ".bytes")
                {
                    string bundleName = "";

                    if (fileName.StartsWith("src/tolua/") == true)
                    {
                        bundleName = fileName.Replace("src/tolua/", string.Empty);
                    }
                    else if (fileName.StartsWith("src/gameapp/lua/") == true)
                    {
                        bundleName = fileName.Replace("src/gameapp/lua/", string.Empty);
                    }
                    else if (fileName.StartsWith("src/") == true)
                    {
                        bundleName = fileName.Replace("src/", string.Empty);
                    }
                    //DebugManager.Log("InitLuaBundle:"+ bundleName);
                    string abPath = FileUtil.Instance.GetWritePath(fileName);
                    this._loader.AddBundle(abPath, bundleName);
                }
            }
        }