示例#1
0
 void OnDisable()
 {
     if (luaObject != null && L != null)
     {
         LuaController.RemoveEventListener(luaObject);
     }
 }
示例#2
0
        public void Dispose()
        {
            if (scriptIsReady)
            {
                if (true || !is_OnDisable)
                {
                    is_OnDisable = true;
                    LuaController.RemoveEventListener(luaObject);
                }
            }
            started       = false;
            scriptIsReady = false;

            if (l_OnDestroy != null && L != null)
            {
                l_OnDestroy(luaObject);
            }

            l_Start              = null;
            l_OnDestroy          = null;
            l_Update             = null;
            l_onEvent            = null;
            l_OnDisable          = null;
            l_OnEnable           = null;
            l_OnApplicationPause = null;

            if (L != null && luaObject != null)
            {
                luaObject.Dispose();
            }
            luaObject = null;
        }
示例#3
0
 void OnEnable()
 {
     if (luaObject != null)
     {
         LuaController.RegisterEventListener(luaObject);
     }
 }
示例#4
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (showDetail)
     {
         LuaController.DispatchEvent("OnClickItemIcon", null, HeroInfo);
     }
 }
示例#5
0
        void luaStart()
        {
            if (!started || luaObject == null)
            {
                return;
            }

            needCallLuaStart = false;

            if (l_Start != null)
            {
                LuaFunction func = luaObject.Get <LuaFunction>("Start");
                if (args != null)
                {
                    //l_Start(luaObject, args);
                    LuaController.Sync(func, luaObject, args);
                }
                else
                {
                    LuaController.Sync(func, luaObject);
                    // l_Start(luaObject);
                }
                func = null;
            }
            else
            {
                LuaRegisterEventAndCallAfterStart();
            }
        }
示例#6
0
        void LuaNPCScript(GameObject obj)
        {
            if (Time.time - time > interDeltime)
            {
                time = Time.time;
                MapPlayer  mapPlayer  = GetComponent <MapPlayer>();
                MapMonster mapMonster = GetComponent <MapMonster>();
                if (mapPlayer != null && mapPlayer.enabled)
                {
                    mapPlayer.UpdateDirection((obj.transform.position - transform.position).normalized, true);
                }
                else if (mapMonster != null && mapMonster.enabled)
                {
                    mapMonster.UpdateDirection((obj.transform.position - transform.position).normalized);
                }

                string fileName = (script == null) ? "guide/" + LuaTextName + ".lua" : script.name;
                if (luaThreadEval == null)
                {
                    luaThreadEval = LuaController.GetLuaValue <LuaThreadEval>("ThreadEvalWithGameObject");
                }
                if (luaThreadEval != null)
                {
                    luaThreadEval(fileName, fileName, this, values);
                }
                else
                {
                    LuaController.DoFile(fileName, values);
                }
            }
        }
示例#7
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (showDetail)
     {
         int[] msg = { pos, 1 };
         LuaController.DispatchEvent("OnClickItemIcon", EquipInfo, msg);
     }
 }
示例#8
0
 public void OnInteractableClick(GameObject interactable, System.Action callback)
 {
     if (self_player != null)
     {
         Vector3 pos = self_player.Interact(interactable, callback);
         LuaController.DispatchEvent("NAV_PLAYER_MOVE", pos.x, pos.y, pos.z);
     }
 }
示例#9
0
 void OnDestroy()
 {
     Dispose(false);
     if (instance == this)
     {
         instance = null;
     }
 }
示例#10
0
 public void OnGroundClick(BaseEventData data)
 {
     if (self_player != null)
     {
         PointerEventData pData = (PointerEventData)data;
         Vector3          pos   = pData.pointerCurrentRaycast.worldPosition;
         pos = self_player.MoveTo(pos);
         LuaController.DispatchEvent("NAV_PLAYER_MOVE", pos.x, pos.y, pos.z);
     }
 }
示例#11
0
        void OnDestroy()
        {
            if (instance == this)
            {
                instance = null;
            }

            Dispose(false);
            //Statistics.SendData();
        }
示例#12
0
        public void LuaRegisterEventAndCallAfterStart()
        {
            is_OnDisable = false;
            LuaController.RegisterEventListener(luaObject);
            scriptIsReady = true;

            foreach (CallInfo info in _callAfterStart)
            {
                Call(info.eventName, info.param);
            }
            _callAfterStart.Clear();
        }
示例#13
0
        void Start()
        {
            if (script != null)
            {
                LuaController.DoStringInThread(script.text, script.name, gameObject);
            }

            if (!string.IsNullOrEmpty(scriptFileName))
            {
                LuaController.DoStringInThread(FileUtils.LoadBytesFromFile(scriptFileName), scriptFileName, gameObject);
            }
        }
示例#14
0
 void OnDisable()
 {
     if (scriptIsReady && luaObject != null && L != null && !is_OnDisable)
     {
         if (l_OnDisable != null)
         {
             l_OnDisable(luaObject);
         }
         is_OnDisable = true;
         LuaController.RemoveEventListener(luaObject);
     }
 }
示例#15
0
 void OnEnable()
 {
     if (scriptIsReady && luaObject != null)
     {
         if (l_OnEnable != null)
         {
             l_OnEnable(luaObject);
         }
         is_OnDisable = false;
         LuaController.RegisterEventListener(luaObject);
     }
 }
示例#16
0
        public static IEnumerator UnloadThread()
        {
            Debug.LogFormat("ResourcesManager.UnloadUnusedAssets");
            var op = AssetManager.UnloadAll(false);

            while (op != null && !op.isDone)
            {
                yield return(null);
            }
            LuaController.Collect();
            System.GC.Collect();
            Debug.LogFormat("ResourcesManager.UnloadUnusedAssets completed");
        }
示例#17
0
 void luaAwake()
 {
     if (l_Awake != null)
     {
         if (args != null)
         {
             l_Awake(luaObject, args);
         }
         else
         {
             l_Awake(luaObject);
         }
     }
     LuaController.RegisterEventListener(luaObject);
 }
示例#18
0
        public static IEnumerator LoadPersistentScene()
        {
            if (!loading)
            {
                loading = true;
                if (LuaController.GetLuaState() == null)
                {
                    yield return(SceneManager.LoadSceneAsync(PRESISTENT_SCENE_BUILD_INDEX, LoadSceneMode.Single));
                }
            }

            while (LuaController.GetLuaState() == null)
            {
                yield return(null);
            }
        }
示例#19
0
        public virtual void Interact(GameObject obj)
        {
            if (Time.realtimeSinceStartup - last_interact_time < interact_protect_time)
            {
                return;
            }
            last_interact_time = Time.realtimeSinceStartup;

            if (script != null)
            {
                if (Character)
                {
                    values [0] = Character.gameObject.transform.localPosition.x.ToString();
                    values [1] = Character.gameObject.transform.localPosition.y.ToString();
                    values [2] = Character.gameObject.transform.localPosition.z.ToString();
                }
                values [3] = Playerid;
                LuaController.DoString(script.bytes, values);
            }
        }
示例#20
0
文件: ItemIcon.cs 项目: ZengHuiAn/sgk
        public void OnPointerClick(PointerEventData eventData)
        {
            if (showDetail)
            {
                int[] msg = { pos, Count };

                if (onClick != null)
                {
                    onClick();
                }
                else
                {
                    LuaController.DispatchEvent("OnClickItemIcon", ItemInfo, msg);
                }

                if (_onClick != null)
                {
                    _onClick.Invoke();
                }
            }
        }
示例#21
0
        void Awake()
        {
            var p = Application.backgroundLoadingPriority;

            Application.backgroundLoadingPriority = ThreadPriority.High;

            if (instance != null)
            {
                DestroyImmediate(gameObject);
                return;
            }

            instance = this;
            DontDestroyOnLoad(this.gameObject);

            L = new LuaEnv();
            L.AddLoader(FileUtils.Load);

            LuaBehaviour.CleanStatlessFile();

            L.Global.Set <string, XLua.LuaDLL.lua_CSFunction>("WARNING_LOG", CustomSettings.PrintWarning);
            L.Global.Set <string, XLua.LuaDLL.lua_CSFunction>("ERROR_LOG", CustomSettings.PrintError);
            L.Global.Set <string, XLua.LuaDLL.lua_CSFunction>("BATTLE_LOG", CustomSettings.BATTLE_LOG);
            L.Global.Set <string, XLua.LuaDLL.lua_CSFunction> ("loadstring", CustomSettings.LoadString);

            IService[] services = gameObject.GetComponents <IService>();
            for (int i = 0; i < services.Length; i++)
            {
                services[i].Register(L);
            }
            //L.DoString("require('LuaDebug')('localhost',7003)");
            L.DoString("require 'utils.init'");

            _RegisterEventListener     = L.Global.Get <System.Action <object> >("RegisterEventListener");
            _RemoveEventListener       = L.Global.Get <System.Action <object> >("RemoveEventListener");
            _DispatchEvent             = L.Global.Get <DispatchEventDelegate>("DispatchEvent");
            _StartLuaCoroutineDelegate = L.Global.Get <StartLuaCoroutineDelegate>("StartCoroutine");
            _Sync = L.Global.Get <SyncDelegate>("Sync");
        }
示例#22
0
        public virtual void Interact(GameObject obj)
        {
            if (Time.realtimeSinceStartup - last_interact_time < interact_protect_time)
            {
                return;
            }

            last_interact_time = Time.realtimeSinceStartup;
            MapPlayer  mapPlayer  = GetComponent <MapPlayer>();
            MapMonster mapMonster = GetComponent <MapMonster>();

            if (mapPlayer != null && mapPlayer.enabled)
            {
                mapPlayer.UpdateDirection((obj.transform.position - transform.position).normalized, true);
            }
            else if (mapMonster != null && mapMonster.enabled)
            {
                mapMonster.UpdateDirection((obj.transform.position - transform.position).normalized);
            }
            else
            {
            }

            string fileName = (script == null) ? "guide/" + LuaTextName + ".lua" : script.name;

            if (luaThreadEval == null)
            {
                luaThreadEval = LuaController.GetLuaValue <LuaThreadEval>("ThreadEvalWithGameObject");
            }
            if (luaThreadEval != null)
            {
                luaThreadEval(fileName, fileName, this, values);
            }
            else
            {
                LuaController.DoFile(fileName, values);
            }
        }
示例#23
0
        void Awake()
        {
            if (instance != null)
            {
                DestroyImmediate(gameObject);
                return;
            }

            instance = this;
            DontDestroyOnLoad(this.gameObject);

            L = new LuaEnv();
            L.AddLoader(FileUtils.Load);

            //L.Global.Set<string, XLua.LuaDLL.lua_CSFunction>("WARNING_LOG", CustomSettings.PrintWarning);
            //L.Global.Set<string, XLua.LuaDLL.lua_CSFunction>("ERROR_LOG", CustomSettings.PrintError);
            //L.Global.Set<string, XLua.LuaDLL.lua_CSFunction>("loadstring", CustomSettings.LoadString);

            IService[] services = gameObject.GetComponents <IService>();
            for (int i = 0; i < services.Length; i++)
            {
                services[i].Register(L);
            }
            L.DoString("require 'main'");


            MainAction = L.Global.Get <System.Action>("main");
            if (MainAction != null)
            {
                MainAction();
            }
            //_RegisterEventListener = L.Global.Get<System.Action<object>>("RegisterEventListener");
            //_RemoveEventListener = L.Global.Get<System.Action<object>>("RemoveEventListener");
            //_DispatchEvent = L.Global.Get<DispatchEventDelegate>("DispatchEvent");
            //_StartLuaCoroutineDelegate = L.Global.Get<StartLuaCoroutineDelegate>("StartCoroutine");
        }
示例#24
0
 public void OnClick(GameObject obj)
 {
     LuaController.DoString(script.bytes, gameObject, obj);
 }