Beispiel #1
0
    private void PlayRecordFileComplete(IGCloudVoice.GCloudVoiceCompleteCode code, string filepath)
    {
        //LOG_STRING("OnPlayRecordFilComplete c# callback");

        int retCode = 0;

        if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_PLAYFILE_DONE)
        {
            //LOG_STRING("OnPlayRecordFilComplete succ, filepath:" + filepath);
        }
        else
        {
            retCode = (int)code;
            //LOG_STRING(string.Format("OnPlayRecordFilComplete error code: {0}, filepath: {1}", code, filepath));
        }

        //call lua
        IntPtr L = LuaScriptMgr.Instance.GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "Voice_OnPlayRecordFileComplete");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                LuaDLL.lua_pushinteger(L, retCode);
                LuaDLL.lua_pushstring(L, filepath);
                if (LuaDLL.lua_pcall(L, 2, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #2
0
    public void CallLuaOnWeatherEventFunc2(int type, int EntityId, Vector3 CurrentPosition, Vector3 CurrentOrientation,
                                           int MoveType, Vector3 MoveDirection, float MoveSpeed, int TimeInterval, Vector3 DstPosition, bool IsDestPosition)
    {
        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "ChangeCurrentWeather2");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                Push(L, type);
                Push(L, EntityId);
                Push(L, CurrentPosition);
                Push(L, CurrentOrientation);
                Push(L, MoveType);
                Push(L, MoveDirection);
                Push(L, MoveSpeed);
                Push(L, TimeInterval);
                Push(L, DstPosition);
                Push(L, IsDestPosition);
                if (LuaDLL.lua_pcall(L, 10, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #3
0
    private void OnApplyMessageKeyComplete(IGCloudVoice.GCloudVoiceCompleteCode code)
    {
        //LOG_STRING("OnApplyMessageKeyComplete c# callback");
        int retCode = 0;

        if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_MESSAGE_KEY_APPLIED_SUCC)
        {
            _bIsGetAuthKey = true;
            //LOG_STRING("OnApplyMessageKeyComplete succ11");
        }
        else
        {
            retCode = (int)code;
        }

        //call lua
        IntPtr L = LuaScriptMgr.Instance.GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "Voice_OnApplyMessageKeyComplete");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                LuaDLL.lua_pushinteger(L, retCode);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #4
0
    public string GetDebugLineInfo(int stack)
    {
        string info = string.Empty;
        IntPtr L    = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "GetDebugLineInfo");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                Push(L, stack);
                if (LuaDLL.lua_pcall(L, 1, 1, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
                else
                {
                    info = LuaDLL.lua_tostring(L, -1);
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
        return(info);
    }
Beispiel #5
0
    public int PrintRegistryTable()
    {
        var size = 0;
        var L    = GetL();

        if (L != IntPtr.Zero)
        {
            var oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "__PrintTable");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                LuaDLL.lua_pushvalue(L, LuaIndexes.LUA_REGISTRYINDEX);
                if (LuaDLL.lua_pcall(L, 1, 1, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
                else
                {
                    size = (int)LuaDLL.lua_tonumber(L, -1);
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
        return(size);
    }
Beispiel #6
0
    public void GetDesignWidthAndHeight(ref int width, ref int height)
    {
        width  = 0;
        height = 0;

        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "GetDesignWidthAndHeight");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                if (LuaDLL.lua_pcall(L, 0, 2, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
                else
                {
                    height = (int)LuaDLL.lua_tonumber(L, -1);
                    width  = (int)LuaDLL.lua_tonumber(L, -2);
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #7
0
        public bool OnCollidingHuge(int collider_id)
        {
            bool   result = false;
            IntPtr L      = LuaScriptMgr.Instance.GetL();

            if (L != IntPtr.Zero)
            {
                //LuaDLL.lua_stackdump(L);
                var oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, _LuaObjectRef);
                LuaDLL.lua_getfield(L, -1, "OnCollidingHuge");
                LuaDLL.lua_pushvalue(L, -2);
                LuaDLL.lua_pushinteger(L, collider_id);

                if (LuaScriptMgr.Instance.GetLuaState().PCall(2, 1)) // obj, ret
                {
                    result = LuaDLL.lua_toboolean(L, -1);            // obj, ret
                }
                else
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
                LuaDLL.lua_settop(L, oldTop);
            }
            return(result);
        }
Beispiel #8
0
    public string GetResPath(string key)
    {
        string val = string.Empty;
        IntPtr L   = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "GetResPath");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                LuaDLL.lua_pushstring(L, key);
                if (LuaDLL.lua_pcall(L, 1, 1, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
                else
                {
                    val = LuaDLL.lua_tostring(L, -1);
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
        return(val);
    }
Beispiel #9
0
        private void OnDownloadRecordFileComplete(bool success, string filePath, string fileId, AudioFormat audioFormat)
        {
            FileIdDownloadingSet.Remove(fileId);

            int code = success ? 0 : 1;
            //call lua
            IntPtr L = LuaScriptMgr.Instance.GetL();

            if (L != IntPtr.Zero)
            {
                int oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_getglobal(L, "Voice_OnDownloadRecordFileComplete");
                if (!LuaDLL.lua_isnil(L, -1))
                {
                    LuaDLL.lua_pushinteger(L, code);
                    LuaDLL.lua_pushstring(L, filePath);
                    LuaDLL.lua_pushstring(L, fileId);
                    if (LuaDLL.lua_pcall(L, 3, 0, 0) != 0)
                    {
                        HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                    }
                }
                LuaDLL.lua_settop(L, oldTop);
            }
        }
Beispiel #10
0
        public bool OnCollideWithOther(int colliderId, CollideEntityType collideEntityType)
        {
            bool   result = false;
            IntPtr L      = LuaScriptMgr.Instance.GetL();

            if (L != IntPtr.Zero)
            {
                var oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, _LuaObjectRef); // obj
                LuaDLL.lua_getfield(L, -1, "OnCollideWithOther");                   // obj, OnCollideWithOther
                LuaDLL.lua_pushvalue(L, -2);                                        // obj, OnCollideWithOther, obj
                LuaDLL.lua_pushinteger(L, colliderId);                              // obj, OnCollideWithOther, obj, collider_id
                LuaDLL.lua_pushinteger(L, (int)collideEntityType);
                if (LuaScriptMgr.Instance.GetLuaState().PCall(3, 1))                // obj, ret
                {
                    result = LuaDLL.lua_toboolean(L, -1);                           // obj, ret
                }
                else
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }

                LuaDLL.lua_settop(L, oldTop);
            }

            return(result);
        }
Beispiel #11
0
        public void SyncHostDashInfo(Vector3 curPos, Vector3 curDir, Vector3 destPos)
        {
            IntPtr L = LuaScriptMgr.Instance.GetL();

            if (L != IntPtr.Zero)
            {
                int oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_getglobal(L, "SendProtocol_SkillMoveTurn");
                if (!LuaDLL.lua_isnil(L, -1))
                {
                    LuaScriptMgr.Push(L, curPos.x);
                    LuaScriptMgr.Push(L, curPos.z);

                    LuaScriptMgr.Push(L, curDir.x);
                    LuaScriptMgr.Push(L, curDir.z);

                    LuaScriptMgr.Push(L, destPos.x);
                    LuaScriptMgr.Push(L, destPos.z);

                    if (LuaDLL.lua_pcall(L, 6, 0, 0) != 0)
                    {
                        HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                    }
                }
                LuaDLL.lua_settop(L, oldTop);
            }
        }
Beispiel #12
0
    private void ClearProtocols()
    {
        LatencyMillisecond = 0;

        // 清理之前,一些关键协议需要处理,不可忽略
        var count = FetchProtocols();

        for (int i = 0; i < count; i++)
        {
            var p = PopupProtocol();
            if (p != null)
            {
                IntPtr L = LuaScriptMgr.Instance.GetL();
                if (L != IntPtr.Zero)
                {
                    int oldTop = LuaDLL.lua_gettop(L);
                    LuaDLL.lua_getglobal(L, "ClearProtocol");
                    if (!LuaDLL.lua_isnil(L, -1))
                    {
                        LuaDLL.lua_pushinteger(L, p.Type);
                        if (p.Buffer != null)
                        {
                            LuaDLL.lua_pushlstring(L, p.Buffer, p.Buffer.Length);
                        }
                        else
                        {
                            LuaDLL.lua_pushstring(L, String.Empty);
                        }
                        LuaDLL.lua_pushboolean(L, false);
                        LuaDLL.lua_pushboolean(L, false);

                        if (LuaDLL.lua_pcall(L, 4, 0, 0) != 0)
                        {
                            HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                        }
                    }
                    LuaDLL.lua_settop(L, oldTop);
                }
            }
        }

        _UnprocessedPrtcList.Clear();
        lock (_CsSession)
        {
            _NewPrtcList.Clear();
        }

        IsSendingPaused = false;
        _ToSendPrtcList.Clear();
    }
Beispiel #13
0
    public void CallLuaBeginSleeping()
    {
        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "BeginSleeping");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                if (LuaDLL.lua_pcall(L, 0, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #14
0
    public void CallLuaOnWeatherEventFunc(int weatherType)
    {
        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "ChangeCurrentWeather");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                Push(L, weatherType);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #15
0
    public void CallLuaOnConnectionEventFunc(int errorCode)
    {
        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "OnConnectionEvent");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                Push(L, errorCode);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #16
0
    //private int _LuaObjectRef = -2;

    public void CallNotifyClickFunc(string objName)
    {
        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "NotifyClick");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                Push(L, objName);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #17
0
    public void OnPhotoCameraFileResult(string strFile)
    {
        IntPtr L = LuaScriptMgr.Instance.GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "OnPhotoCameraFileResult");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                LuaScriptMgr.Push(L, strFile);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #18
0
    public void CallOnDoubleInputKeyCode(int keycode)
    {
        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "OnDoubleInputKeyCode");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                Push(L, keycode);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #19
0
    public void CallLuaOnTwoFingersDragFunc(float delta)
    {
        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "OnTwoFingersDrag");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                Push(L, delta);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #20
0
        public void OnClick()
        {
            IntPtr L = LuaScriptMgr.Instance.GetL();

            if (L != IntPtr.Zero)
            {
                //LuaDLL.lua_stackdump(L);
                var oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, _LuaObjectRef); // obj
                LuaDLL.lua_getfield(L, -1, "OnClick");                              // obj, OnClick
                LuaDLL.lua_pushvalue(L, -2);                                        // obj, OnClick, obj
                if (!LuaScriptMgr.Instance.GetLuaState().PCall(1, 0))               // obj
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
                LuaDLL.lua_settop(L, oldTop);
                //LuaDLL.lua_stackdump(L);
            }
        }
Beispiel #21
0
    private static int LoadSceneBlocks(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(float), typeof(float), typeof(LuaFunction)))
        {
            var posx = (float)LuaScriptMgr.GetNumber(L, 1);
            var posz = (float)LuaScriptMgr.GetNumber(L, 2);
            LuaDLL.lua_pushvalue(L, 3);
            int    callbackRef = LuaDLL.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
            Action callback    = () =>
            {
                if (LuaScriptMgr.Instance.GetLuaState() == null || callbackRef == 0)
                {
                    return;
                }

                var oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, callbackRef);
                LuaDLL.luaL_unref(L, LuaIndexes.LUA_REGISTRYINDEX, callbackRef);
                if (LuaDLL.lua_isnil(L, -1))
                {
                    LuaDLL.lua_settop(L, oldTop);
                    return;
                }
                if (!LuaScriptMgr.Instance.GetLuaState().PCall(0, 0))
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
                LuaDLL.lua_settop(L, oldTop);
            };
            ScenesManager.Instance.LoadObjectsAtPos(posx, posz, callback);

            return(CheckReturnNum(L, count, nRet));
        }
        else
        {
            LogParamError("OnWorldLoadedBlocks", count);
            return(CheckReturnNum(L, count, nRet));
        }
    }
Beispiel #22
0
    private void DoSendPing()
    {
        IntPtr L = LuaScriptMgr.Instance.GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "SendProtocol_Ping");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                var ms = (DateTime.UtcNow - Main.DateTimeBegin).TotalMilliseconds /*+ EntryPoint._ServerTimeGap*/;
                LuaScriptMgr.Push(L, ms);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #23
0
        private void OnApplyMessageKeyComplete(int code)
        {
            //call lua
            IntPtr L = LuaScriptMgr.Instance.GetL();

            if (L != IntPtr.Zero)
            {
                int oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_getglobal(L, "Voice_OnApplyMessageKeyComplete");
                if (!LuaDLL.lua_isnil(L, -1))
                {
                    LuaDLL.lua_pushinteger(L, code);
                    if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                    {
                        HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                    }
                }
                LuaDLL.lua_settop(L, oldTop);
            }
        }
Beispiel #24
0
    public void CallLuaOnClickGroundFunc(Vector3 pos)
    {
        IntPtr L = GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "OnClickGround");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                Push(L, pos);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
        CCamCtrlMan.Instance.GetGameCamCtrl().StopRecoverCamera();
    }
Beispiel #25
0
    private void ProcessProtocol(CS2CPrtcData p, bool isSimple)
    {
        if (p != null && p.Type > 0)
        {
#if false
            // test 1
            BytesDecodeTest(p);
            // test 2
            TestBytes(p, false, false);
#endif

            var isSpecial = _ProcessBeginTicks > 0 && p.TimeStamp < _ProcessBeginTicks;

            IntPtr L = LuaScriptMgr.Instance.GetL();
            if (L != IntPtr.Zero)
            {
                int oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_getglobal(L, "ProcessProtocol");
                if (!LuaDLL.lua_isnil(L, -1))
                {
                    LuaDLL.lua_pushinteger(L, p.Type);
                    if (p.Buffer != null)
                    {
                        LuaDLL.lua_pushlstring(L, p.Buffer, p.Buffer.Length);
                    }
                    else
                    {
                        LuaDLL.lua_pushstring(L, String.Empty);
                    }
                    LuaDLL.lua_pushboolean(L, isSpecial);
                    LuaDLL.lua_pushboolean(L, isSimple);

                    if (LuaDLL.lua_pcall(L, 4, 0, 0) != 0)
                    {
                        HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                    }
                }
                LuaDLL.lua_settop(L, oldTop);
            }
        }
    }
Beispiel #26
0
    public void Tick(float dt)
    {
#if UseLuaTick
        IntPtr L = GetL();
        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "TickGame");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                LuaDLL.lua_pushnumber(L, dt);
                if (LuaDLL.lua_pcall(L, 1, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1), LuaStatic.GetTraceBackInfo(L));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
#endif
        TickUnref();
    }
Beispiel #27
0
        private void PlayRecordFileComplete(int code, string errMsg, string filepath)
        {
            //call lua
            IntPtr L = LuaScriptMgr.Instance.GetL();

            if (L != IntPtr.Zero)
            {
                int oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_getglobal(L, "Voice_OnPlayRecordFileComplete");
                if (!LuaDLL.lua_isnil(L, -1))
                {
                    LuaDLL.lua_pushinteger(L, code);
                    LuaDLL.lua_pushstring(L, filepath);
                    if (LuaDLL.lua_pcall(L, 2, 0, 0) != 0)
                    {
                        HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                    }
                }
                LuaDLL.lua_settop(L, oldTop);
            }
        }
Beispiel #28
0
        public void SyncHostDashCollideInfo(int colliderId, bool restartDash)
        {
            IntPtr L = LuaScriptMgr.Instance.GetL();

            if (L != IntPtr.Zero)
            {
                int oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_getglobal(L, "SendProtocol_EntityCollide");
                if (!LuaDLL.lua_isnil(L, -1))
                {
                    LuaScriptMgr.Push(L, colliderId);
                    int moveType = restartDash ? 1 : 0;
                    LuaScriptMgr.Push(L, moveType);

                    if (!LuaScriptMgr.Instance.GetLuaState().PCall(2, 0)) // obj, ret
                    {
                        HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                    }
                }
                LuaDLL.lua_settop(L, oldTop);
            }
        }
Beispiel #29
0
    private void OnDownloadRecordFileComplete(IGCloudVoice.GCloudVoiceCompleteCode code, string filepath, string fileid)
    {
        //LOG_STRING("OnDownloadRecordFileComplete c# callback");

        int retCode = 0;

        if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_DOWNLOAD_RECORD_DONE)
        {
            //LOG_STRING("OnDownloadRecordFileComplete succ, filepath:" + filepath + " fileid:" + fileid);
        }
        else
        {
            retCode = (int)code;
            //LOG_STRING(string.Format("OnDownloadRecordFileComplete error code: {0}, filepath: {1}, fileid: {2}", code, filepath, fileid));
        }

        FileIdDownloadingSet.Remove(fileid);

        //call lua
        IntPtr L = LuaScriptMgr.Instance.GetL();

        if (L != IntPtr.Zero)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_getglobal(L, "Voice_OnDownloadRecordFileComplete");
            if (!LuaDLL.lua_isnil(L, -1))
            {
                LuaDLL.lua_pushinteger(L, retCode);
                LuaDLL.lua_pushstring(L, filepath);
                LuaDLL.lua_pushstring(L, fileid);
                if (LuaDLL.lua_pcall(L, 3, 0, 0) != 0)
                {
                    HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
            }
            LuaDLL.lua_settop(L, oldTop);
        }
    }
Beispiel #30
0
    public static int Translation_DoStopRecording(IntPtr L, int callbackRef)
    {
        int ret = 0;

#if USING_GCLOUDVOICE && UNITY_EDITOR
        Action <int> callback = (code) =>
        {
            if (LuaScriptMgr.Instance.GetLuaState() == null)
            {
                return;
            }

            var oldTop = LuaDLL.lua_gettop(L);
            LuaDLL.lua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, callbackRef); // cb
            LuaDLL.luaL_unref(L, LuaIndexes.LUA_REGISTRYINDEX, callbackRef);
            if (LuaDLL.lua_isnil(L, -1))
            {
                LuaDLL.lua_settop(L, oldTop);
                return;
            }

            LuaDLL.lua_pushvalue(L, -1);    //-> cb, cb
            LuaScriptMgr.Push(L, code);

            if (!LuaScriptMgr.Instance.GetLuaState().PCall(1, 0)) //-> cb, [err]
            {
                HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
            }
            LuaDLL.lua_settop(L, oldTop);
        };

        var translationVoice = VoiceManager.Instance.TranslationVoice;
        ret = translationVoice.StopRecording(callback);
#elif USING_LGVC
#endif
        return(ret);
    }