Example #1
0
    static int Create(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 4);
            EffectRenderObj obj  = (EffectRenderObj)ToLua.CheckObject(L, 1, typeof(EffectRenderObj));
            string          arg0 = ToLua.CheckString(L, 2);
            string          arg1 = ToLua.CheckString(L, 3);
            EffectRenderObj.LoadComCallBack arg2 = null;
            LuaTypes funcType4 = LuaDLL.lua_type(L, 4);

            if (funcType4 != LuaTypes.LUA_TFUNCTION)
            {
                arg2 = (EffectRenderObj.LoadComCallBack)ToLua.CheckObject(L, 4, typeof(EffectRenderObj.LoadComCallBack));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 4);
                arg2 = DelegateFactory.CreateDelegate(typeof(EffectRenderObj.LoadComCallBack), func) as EffectRenderObj.LoadComCallBack;
            }

            bool o = obj.Create(ref arg0, ref arg1, arg2);
            LuaDLL.lua_pushboolean(L, o);
            LuaDLL.lua_pushstring(L, arg0);
            LuaDLL.lua_pushstring(L, arg1);
            return(3);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #2
0
    /// <summary>
    /// 创建渲染对象
    /// </summary>
    /// <param name="strObjFileName">渲染对象描述文件</param>
    /// <returns></returns>
    public EffectRenderObj CreateRenderObj(ref string effectName, ref string url, bool bCached = false)
    {
        EffectRenderObj effect = null;

        if (bCached)
        {
            if (!effectPool.downDestoryEffectsList.ContainsKey(effectName))
            {
                // 加入缓存列表,特效不清理
                effectPool.downDestoryEffectsList.Add(effectName, false);
            }
        }
        //从池里拿...
        effect = effectPool.GetObject(effectName) as EffectRenderObj;
        if (effect != null)
        {
            m_EffectRenderObj[effect.GetID()] = effect;
            if (!m_EffectRenderObjList.Contains(effect))
            {
                m_EffectRenderObjList.Add(effect);
            }
            reStartEffect(effect);
        }
        else
        {
            effect = new EffectRenderObj(m_uRenderObjIDSeed);
            effect.Create(ref effectName, ref url, loadComCallBack);
            m_EffectRenderObj[m_uRenderObjIDSeed] = effect;
            if (!m_EffectRenderObjList.Contains(effect))
            {
                m_EffectRenderObjList.Add(effect);
            }
            m_uRenderObjIDSeed++;
        }
        return(effect);
    }