Пример #1
0
        private async Task InitInternalEntry()
        {
            try
            {
                string final_path = InternalLuaEntryPath;
                LuaRequireToPath(ref final_path);
                TextAsset ta = await Assets.LoadAsync <TextAsset>(final_path);

                object[]      obj_result = mLuaVM.DoString(ta.bytes, final_path);
                LuaTable      table      = (LuaTable)obj_result[0];
                List <string> init_list  = table.Cast <List <string> >();

                List <Task> list_task = new List <Task>();
                foreach (var item in init_list)
                {
                    list_task.Add(require_init_file(item));
                }
                await Task.WhenAll(list_task);

                Assets.Release(ta);
            }
            catch (XException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Пример #2
0
    private void OnPerformStart(object arg)
    {
        LuaTable table       = arg as LuaTable;
        var      performRoot = table.Cast <LuaTable>();

        _battleFSM.Context.SetVariable("PerformRoot", performRoot);
        _battleFSM.SwitchToState((int)SessionState.PerformState);
    }
Пример #3
0
    public void Register(LuaTable tb)
    {
        CL_ILuaUIComponent luaUIComp = tb.Cast <CL_ILuaUIComponent>();

        if (null != luaUIComp && !m_comps.ContainsKey(luaUIComp.unique_id))
        {
            m_comps.Add(luaUIComp.unique_id, luaUIComp);
        }
    }
Пример #4
0
    public void Unregister(LuaTable tb)
    {
        CL_ILuaUIComponent luaUIComp = tb.Cast <CL_ILuaUIComponent>();

        if (null != luaUIComp)
        {
            m_comps.Remove(luaUIComp.unique_id);
        }
    }
Пример #5
0
        static private void LoadLuaFiles()
        {
            LuaTable files = Call <LuaTable>("main_getLuaFiles");

            foreach (var luaFile in files.Cast <List <string> >())
            {
                //HSUtils.Log(luaFile);
                luaEnv.DoString(LoadLua(LuaManager.LUA_ROOT_MENU + luaFile.Replace(".lua", "")), luaFile);
            }
            files.Dispose();
            files = null;
        }
Пример #6
0
    public List <T> LoadLuaConfigFromString <T>(string _str)
    {
        LuaTable _luaTable = LoadLuaConfigFromStr(_str);

        if (_luaTable != null)
        {
            var _list = _luaTable.Cast <List <T> >();

            return(_list);
        }
        else
        {
            return(null);
        }
    }
Пример #7
0
    public List <T> LoadLuaConfigFromFile <T>(string _filePath)
    {
        LuaTable _luaTable = LoadLuaConfig(_filePath);

        if (_luaTable != null)
        {
            var _list = _luaTable.Cast <List <T> >();

            return(_list);
        }
        else
        {
            return(null);
        }
    }
Пример #8
0
    public Dictionary <TKey, TValue> LoadLuaConfigFromString <TKey, TValue>(string _str)
    {
        LuaTable _luaTable = LoadLuaConfigFromStr(_str);

        if (_luaTable != null)
        {
            var _dic = _luaTable.Cast <Dictionary <TKey, TValue> >();

            return(_dic);
        }
        else
        {
            return(null);
        }
    }
Пример #9
0
    /// <summary>
    /// 文件中读取,绝对路径
    /// </summary>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TValue"></typeparam>
    /// <param name="_filePath"></param>
    /// <returns></returns>
    public Dictionary <TKey, TValue> LoadLuaConfigFromFile <TKey, TValue>(string _filePath)
    {
        LuaTable _luaTable = LoadLuaConfig(_filePath);

        if (_luaTable != null)
        {
            var _dic = _luaTable.Cast <Dictionary <TKey, TValue> >();

            return(_dic);
        }
        else
        {
            return(null);
        }
    }
Пример #10
0
        public override void ConstructFromXML(XML xml)
        {
            base.ConstructFromXML(xml);

            Lua = LuaUIHelper.ConnectLua(this);

            callback = Lua.Cast <ILuaComponent>();
            if (callback != null)
            {
                callback.Init();
            }
            else
            {
                Debug.LogWarningFormat("Can't cast LuaTable to ILuaComponent");
            }
        }
Пример #11
0
    /// <summary>
    /// require会去搜索路径下找
    /// 会在里面进行拼接.默认setting/xxx.lua
    /// </summary>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TValue"></typeparam>
    /// <param name="_lua"></param>
    /// <returns></returns>
    public Dictionary <TKey, TValue> LoadLuaConfigFromLua <TKey, TValue>(string _lua)
    {
        // 简化
        _lua = string.Format("{0}{1}", __LUACONFIGPATH, _lua);

        LuaTable _luaTable = m_require(_lua);

        if (_luaTable != null)
        {
            var _dic = _luaTable.Cast <Dictionary <TKey, TValue> >();

            return(_dic);
        }
        else
        {
            return(null);
        }
    }
Пример #12
0
        public static LuaTable ConnectLua(GComponent gcom)
        {
            LuaTable    _peerTable     = null;
            LuaFunction extendFunction = gcom.data as LuaFunction;

            if (extendFunction != null)
            {
                gcom.data = null;

                object[] obj = extendFunction.Call(gcom);
                _peerTable = obj[0] as LuaTable;
                _peerTable.Set("csuserdata", gcom);
            }
            ILuaComponent c = _peerTable.Cast <ILuaComponent>();

            c.Init();
            return(_peerTable);
        }
Пример #13
0
 public void SetLuaTalbe(LuaTable peerTable)
 {
     _peerTable = peerTable;
     callback   = peerTable.Cast <ILuaWindow>();
 }
Пример #14
0
 /// <summary>
 /// 发送添加回复请求。
 /// </summary>
 /// <param name="list">回复列表。</param>
 public void SendApproveRequestForLua(LuaTable t)
 {
     SendApproveRequest(t.Cast <List <MsgData_cFriendApproveVO> >());
 }
Пример #15
0
 /// <summary>
 /// 发送推荐好友请求。
 /// </summary>
 public void SendAddRecommendRequestForLua(LuaTable t)
 {
     SendAddRecommendRequest(t.Cast <List <long> >());
 }
Пример #16
0
        public void SetPathForLua(LuaTable tb)
        {
            List <Vector2> path = tb.Cast <List <Vector2> >();

            SetPath(path);
        }
Пример #17
0
 public void SetLuaTalbe(LuaTable peerTable)
 {
     mPeerTable = peerTable;
     mPeerTable = peerTable;
     callback   = mPeerTable.Cast <IState>();
 }
Пример #18
0
 public void SetLuaTalbe(LuaTable peerTable)
 {
     mPeerTable = peerTable;
     callback   = peerTable.Cast <ILuaTaskBase>();
 }
Пример #19
0
 public void SetLuaTalbe(LuaTable peerTable)
 {
     mLuaTable = peerTable;
     callback  = mLuaTable.Cast <ILuaSceneBase>();
 }
Пример #20
0
 public void SetLuaTalbe(LuaTable t)
 {
     mLuatable = t;
     callBack  = mLuatable.Cast <ILuaWindow>();
 }
Пример #21
0
        /// <summary>
        /// 发送一键出售请求。(给Lua调用)
        /// </summary>
        /// <param name="bag">背包类型。</param>
        /// <param name="pos">格子索引列表</param>
        public void SendFastSellRequestForLua(int bag, LuaTable tb)
        {
            List <int> pos = tb.Cast <List <int> >();

            SendFastSellRequest(bag, pos);
        }