Esempio n. 1
0
        private IEnumerator Do()
        {
DO:
            if (_count > 0)
            {
                cur++;
            }
            yield return(new WaitForSeconds(_interval));

            if (timer != null && !timer.dispose)
            {
                if (doSomething != null)
                {
                    doSomething(param);
                }
                else if (luaDoSth != null)
                {
                    LuaManager.CallFunc_VX(luaDoSth, param, 0);
                }

                if (_count == -1)
                {
                    goto DO;
                }
                else
                {
                    if (cur < _count)
                    {
                        goto DO;
                    }
                }
            }

            Timer.DisposeTimer(this);
        }
Esempio n. 2
0
        public static void AddScriptListener(int rMessageType, int rFilter, string scriptClassName, string scriptMethodName, bool rImmediate, bool staticBinding = true)
        {
#if JSSCRIPT
#elif LUASCRIPT
            LuaManager.Require(scriptClassName);
            LuaFunction func = LuaManager.GetFunction(scriptMethodName);
            if (func == null)
            {
                Debugger.LogError("register script listener func is null->" + scriptClassName + "^" + scriptMethodName);
                return;
            }
#endif

            MessageDispatcher.AddListener(rMessageType, rFilter, (message) =>
            {
#if JSSCRIPT
                JsRepresentClass jsRepresent = JsRepresentClassManager.Instance.AllocJsRepresentClass(JSClassName, staticBinding);

                if (message != null)
                {
                    jsRepresent.CallFunctionByFunName(JSMethodName, message.Data);
                }
#elif LUASCRIPT
                LuaManager.CallFunc_VX(func, message.Data);
#endif
            }, rImmediate);
        }
Esempio n. 3
0
 internal static void UICreateCall(int index, UIFrame ui)
 {
     if (createUICall != null)
     {
         LuaManager.CallFunc_VX(createUICall, index, ui);
     }
 }
Esempio n. 4
0
        private static UIFrame GetUI(string name, int index)
        {
            UIFrame ui = null;

            if (!indexToUI.ContainsKey(index))
            {
                List <string> atlases;
                uiInfo.TryGetValue(name, out atlases);

                List <string> textures;
                string        texName = name + "_IMG";
                uiInfo.TryGetValue(texName, out textures);

                if (atlases != null && textures != null)
                {
                    ui = new UIFrame(index, name, atlases, textures);
                    uiInfo.Remove(name);
                    uiInfo.Remove(texName);
                    allUI.Add(name, ui);
                    indexToUI.Add(index, ui);
                    if (initUICall != null)
                    {
                        LuaManager.CallFunc_VX(initUICall, index, ui);
                    }
                }
            }
            else
            {
                ui = allUI[name];
            }

            return(ui);
        }
Esempio n. 5
0
        private void RunEvtFunc(Evt e, params object[] param)
        {
            LuaFunction func = funcArr[(int)e];

            if (func == null)
            {
                return;
            }

            LuaManager.CallFunc_VX(func, param);
        }
Esempio n. 6
0
        private void ShowUICallback()
        {
#if LUASCRIPT
            if (scriptShowUICall != null)
            {
                LuaInterface.LuaFunction func = scriptShowUICall;
                scriptShowUICall = null;
                LuaManager.CallFunc_VX(func, scriptCallParam);
                scriptCallParam = -1;
            }
#endif
        }
Esempio n. 7
0
            public void TweenCallFunc(float factor, bool isFinished)
            {
                if (func != null)
                {
                    LuaManager.CallFunc_VX(func, funcParam, factor, isFinished);
                }

                if (isFinished)
                {
                    func      = null;
                    funcParam = -1;
                    Dispose(this);
                }
            }
Esempio n. 8
0
        private void OnAdditiveSceneLoaded(string name)
        {
#if LUASCRIPT
            if (luaAdditiveLoadOverFunc == null)
            {
                luaAdditiveLoadOverFunc = LuaManager.GetFunction("SceneManager.ListenAdditiveLoadOver");
            }

            if (luaAdditiveLoadOverFunc != null)
            {
                LuaManager.CallFunc_VX(luaAdditiveLoadOverFunc, name);
            }
#endif
        }
Esempio n. 9
0
        public static void AddDispose(Timer td, bool cb = false)
        {
            if (td == null)
            {
                return;
            }
            if (td.dispose)
            {
                return;
            }
            if (td.td == null)
            {
                return;
            }

            if (cb)
            {
                if (td.td.doSomething != null)
                {
                    td.td.doSomething(td.td.param);
                }
                else if (td.td.luaDoSth != null)
                {
                    LuaManager.CallFunc_VX(td.td.luaDoSth, td.td.param, 0);
                }
            }

            td.SetDispose();
            if (disposeQueue.Contains(td.td))
            {
                return;
            }

            if (td.td.luaDoSth != null)
            {
                LuaManager.CallFunc_VX(td.td.luaDoSth, td.td.param, 1);
            }

            td.td.doSomething = null;
            td.td.param       = null;
            td.td.luaDoSth    = null;
            td.td.StopAllCoroutines();
            td.td.gameObject.SetActive(false);
            td.td.timer = null;
            disposeQueue.Enqueue(td.td);
            td.td = null;
        }
Esempio n. 10
0
        private void OnSceneWasLoaded()
        {
            if (!alive)
            {
                return;
            }
            if (loadStatus == LoadSceneStatus.END)
            {
                {
                    loadStatus   = LoadSceneStatus.NONE;
                    sceneLoading = false;

                    LuaContext.RefreshDelegateMap();

#if LUASCRIPT
                    if (luaLoadOverFunc == null)
                    {
                        luaLoadOverFunc = LuaManager.GetFunction("SceneManager.ListenLoadOver");
                    }

                    if (luaLoadOverFunc != null)
                    {
                        LuaManager.CallFunc_VX(luaLoadOverFunc, next);
                    }
#endif
                }
            }
            else if (loadStatus == LoadSceneStatus.BEGIN)
            {
                if (!sceneLoading)
                {
                    sceneLoading = true;

                    if (next != null)
                    {
                        Load();
                    }
                }
            }

            ClearSceneAsset();

            Resources.UnloadUnusedAssets();
            System.GC.Collect();
        }
Esempio n. 11
0
        private void BeginUpdate(List <int> updateList, List <long> totalList)
        {
            canUpdate = true;

            totalSize = 0;
            for (int i = 0, count = totalList.Count; i < count; i++)
            {
                totalSize += totalList[i];
            }

            Debugger.LogError("download version->" + totalSize + "^" + updateList.Count + "^" + totalList.Count);
            curSize = 0;
            if (updateList.Count > 0)
            {
                if (totalSize > 0)
                {
                    totalNum       = updateList.Count;
                    needUpdateList = updateList;

                    canUpdate = false;
                    LuaInterface.LuaFunction func = LuaManager.GetFunction("OnResourceNeedUpdate");
                    if (func != null)
                    {
                        LuaManager.CallFunc_VX(func, totalNum, totalSize);
                    }
                    else
                    {
                        Debug.LogError("script function 'OnResourceNeedUpdate' is null");
                    }
                }
#if UNITY_EDITOR
                else
                {
                    Debugger.LogError("update files is invalid");
                }
#endif
            }
        }
Esempio n. 12
0
        private static IEnumerator _HttpGetSendBackString(string url, string ob, string className, string functionName)
        {
            WWW www = new WWW(url + "?" + ob);

            yield return(www);

            if (www.error != null)
            {
                Debugger.LogError("http get send error->" + www.error);
            }
            else
            {
                if (www.bytes != null)
                {
                    string data = System.Text.Encoding.UTF8.GetString(www.bytes);

                    if (!string.IsNullOrEmpty(data))
                    {
#if JSSCRIPT
                        JsRepresentClass jsRepresentClass =
                            JsRepresentClassManager.Instance.AllocJsRepresentClass(className, true);
                        jsRepresentClass.CallFunctionByFunName(functionName, data);
#elif LUASCRIPT
                        LuaManager.Require(className);
                        LuaInterface.LuaFunction func = LuaManager.GetFunction(functionName);
                        LuaManager.CallFunc_VX(func, data);
#endif
                    }
                }
                else
                {
                    Debugger.LogError("http get response data is null");
                }
            }

            www.Dispose();
        }
Esempio n. 13
0
        private void DownloadVersionFile(string url, byte[] data, System.Object obj)
        {
            if (data == null)
            {
                if (Config.Detail_Debug_Log())
                {
                    Debug.LogError("download version data failed");
                }

                LuaInterface.LuaFunction func = LuaManager.GetFunction("OnDownloadVersionDataFailed");
                if (func != null)
                {
                    LuaManager.CallFunc_VX(func);
                }
                else
                {
                    Debug.LogError("script function 'OnDownloadVersionDataFailed' is null");
                }

                return;
            }

            if (Config.Detail_Debug_Log())
            {
                Debug.Log("download version");
            }

            GameUtils.BytesMD5Value(data, (md5Str) =>
            {
                if (Config.Detail_Debug_Log())
                {
                    Debug.Log("download version 1->" + md5Str + "^" + vfc.Md5);
                }
                if (md5Str != vfc.Md5.ToLower())
                {
                    Debugger.LogError("versionInfo file is invalid->" + md5Str + "^" + vfc.Md5);
                    return;
                }

                versionInfoData = new byte[data.Length];
                System.Array.Copy(data, versionInfoData, data.Length);
                ResLoader.RemoveImpurity(data, (arr) =>
                {
                    GameUtils.MemoryStreamClear();
                    GameUtils.ms.Write(data, 0, data.Length);
                    GameUtils.ms.Position = 0;

                    versionInfo = VersionInfo.Deserialize(GameUtils.ms);

                    if (Config.Detail_Debug_Log())
                    {
                        Debugger.Log("download version 2->" + versionInfo.Files.Count);
                    }

                    versionFileData            = new VersionFileData();
                    versionFileData.fileLocate = new List <byte>();

                    nameToRelation.Clear();

                    VersionInfoToData(versionInfo, (byte)FileLocate.None);

                    totalNum = 0;

                    StartCoroutine(BeginCheckUpdateFiles());
                });
            });
        }
Esempio n. 14
0
        private void CheckVersion(string url, byte[] data, System.Object obj)
        {
            if (data == null)
            {
                if (Config.Detail_Debug_Log())
                {
                    Debug.LogError("download check version data failed");
                }

                LuaInterface.LuaFunction func = LuaManager.GetFunction("OnDownloadCheckVersionDataFailed");
                if (func != null)
                {
                    LuaManager.CallFunc_VX(func);
                }
                else
                {
                    Debug.LogError("script function 'OnDownloadCheckVersionDataFailed' is null");
                }

                return;
            }

            GameUtils.MemoryStreamClear();
            GameUtils.ms.Write(data, 0, data.Length);
            GameUtils.ms.Position = 0;

            vfc           = VersionForCheck.Deserialize(GameUtils.ms);
            updateVersion = false;
            if (Config.Detail_Debug_Log())
            {
                Debugger.Log("versionInfo->" + (versionInfo == null) + "^" + vfc.Version);
            }
            if (versionInfo != null)
            {
                Debugger.Log("vi->" + versionInfo.Version);
            }
            else if (streamingAssetVersionInfo != null)
            {
                versionInfo = streamingAssetVersionInfo;

                versionFileData            = new VersionFileData();
                versionFileData.fileLocate = new List <byte>();

                nameToRelation.Clear();

                VersionInfoToData(versionInfo, (byte)FileLocate.StreamingAsset);
            }

            if (versionInfo == null || vfc.Version != versionInfo.Version)
            {
                Debugger.LogError("version not match, need update.");
                updateVersion = true;
                GameUtils.StringBuilderClear();
                GameUtils.stringBuilder.Append(remoteAssetPath);
                GameUtils.stringBuilder.Append(versionInfoFileName);
                GameUtils.stringBuilder.Append(GameUtils.GetSuffixOfURL());
                StartCoroutine(ResLoader.BeginDownload(GameUtils.stringBuilder.ToString(), DownloadVersionFile, null, updatePBar));
            }
            else
            {
                canUpdate = true;
                Debugger.Log("update nothing");
            }
        }