/**
     * Load an lua file.
     *
     * @param string strFile - The file name without extension.
     * @return bool - true if success, otherwise false.
     */
    public bool DoFile(string strFile)
    {
        if (string.IsNullOrEmpty(strFile))
        {
            return(false);
        }

        // Try to do file.
        try
        {
            // The lua file return the table itself.
            object cChunk = Game.GetLuaSvr().luaState.doFile(strFile);
            if ((null == cChunk) || !(cChunk is LuaTable))
            {
                return(false);
            }

            // Remember lua table.
            m_cLuaTableOpt = new LLuaTable((LuaTable)cChunk);
            return(true);
        }
        catch (System.Exception e)
        {
            Debug.LogError(LUtil.FormatException(e));
        }

        return(false);
    }
    public bool CreateClassInstance(string strClassName)
    {
        if (string.IsNullOrEmpty(strClassName))
        {
            return(false);
        }

        // Try to get global lua class.
        try
        {
            // Get class first.
            LuaTable cClsTable = LuaManager.Instance.GetLuaTable(strClassName);
            if (null == cClsTable)
            {
                return(false);
            }

            // Get "new" method of the lua class to create instance.
            LuaFunction cNew = (LuaFunction)cClsTable["New"];
            if (null == cNew)
            {
                return(false);
            }

            // We choose no default init parameter for constructor.
            cNew.BeginPCall();
            cNew.PCall();
            object cInsChunk = (object)cNew.CheckVariant();
            cNew.EndPCall();

            if (null == cInsChunk)
            {
                return(false);
            }

            // If we create instance ok, use it as table.
            m_cLuaTableOpt = new LLuaTable((LuaTable)cInsChunk);
            return(true);
        }
        catch (System.Exception e)
        {
            Debug.LogError(e);
        }

        return(false);
    }
    /**
     * Create a lua class instance for monobehavior instead of do a file.
     *
     * @param string strFile - The lua class name.
     * @return bool - true if success, otherwise false.
     */
    public bool CreateClassInstance(string strClassName)
    {
        if (string.IsNullOrEmpty(strClassName))
        {
            return(false);
        }

        // Try to get global lua class.
        try
        {
            // Get class first.
            LuaTable cClsTable = (LuaTable)Game.GetLuaSvr().luaState[strClassName];
            if (null == cClsTable)
            {
                return(false);
            }

            // Get "new" method of the lua class to create instance.
            LuaFunction cNew = (LuaFunction)cClsTable["new"];
            if (null == cNew)
            {
                return(false);
            }

            // We choose no default init parameter for constructor.
            object cInsChunk = cNew.call();
            if (null == cInsChunk)
            {
                return(false);
            }

            // If we create instance ok, use it as table.
            m_cLuaTableOpt = new LLuaTable((LuaTable)cInsChunk);
            return(true);
        }
        catch (System.Exception e)
        {
            Debug.LogError(LUtil.FormatException(e));
        }

        return(false);
    }
    /**
     * Load an lua file.
     *
     * @param string strFile - The file name without extension.
     * @return bool - true if success, otherwise false.
     */
    public bool DoFile(string strFile)
    {
        if (string.IsNullOrEmpty(strFile))
        {
            return false;
        }

        // Try to do file.
        try
        {
            // The lua file return the table itself.
            object cChunk = Game.GetLuaSvr().luaState.doFile(strFile);
            if ((null == cChunk) || !(cChunk is LuaTable))
            {
                return false;
            }

            // Remember lua table.
            m_cLuaTableOpt = new LLuaTable((LuaTable)cChunk);
            return true;
        }
        catch (System.Exception e)
        {
            Debug.LogError(LUtil.FormatException(e));
        }

        return false;
    }
    /**
     * Create a lua class instance for monobehavior instead of do a file.
     *
     * @param string strFile - The lua class name.
     * @return bool - true if success, otherwise false.
     */
    public bool CreateClassInstance(string strClassName)
    {
        if (string.IsNullOrEmpty(strClassName))
        {
            return false;
        }

        // Try to get global lua class.
        try
        {
            // Get class first.
            LuaTable cClsTable = (LuaTable)Game.GetLuaSvr().luaState[strClassName];
            if (null == cClsTable)
            {
                return false;
            }

            // Get "new" method of the lua class to create instance.
            LuaFunction cNew = (LuaFunction)cClsTable["new"];
            if (null == cNew)
            {
                return false;
            }

            // We choose no default init parameter for constructor.
            object cInsChunk = cNew.call();
            if (null == cInsChunk)
            {
                return false;
            }

            // If we create instance ok, use it as table.
            m_cLuaTableOpt = new LLuaTable((LuaTable)cInsChunk);
            return true;
        }
        catch (System.Exception e)
        {
            Debug.LogError(LUtil.FormatException(e));
        }

        return false;
    }