Esempio n. 1
0
    public void Destroy()
    {
        SafeUnRef(ref enumMetaRef);
        SafeUnRef(ref typeMetaRef);
        SafeUnRef(ref delegateMetaRef);
        SafeUnRef(ref iterMetaRef);
        SafeUnRef(ref arrayMetaRef);

        SafeRelease(ref packRaycastHit);
        SafeRelease(ref packTouch);

        LuaDLL.clear_luastate();

        LuaDLL.lua_gc(_lua.L, LuaGCOptions.LUA_GCCOLLECT, 0);

        foreach (KeyValuePair <string, LuaBase> kv in _dict)
        {
            kv.Value.Dispose();
        }

        _dict.Clear();
        _fileList.Clear();

        _lua.Close();
        _lua.Dispose();
        _lua = null;

        ClearInstance();            //clear instance
        HobaDebuger.Log("Lua module destroy");
    }
Esempio n. 2
0
    private static int CameraLookAtNpc(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject)))
        {
            GameObject npc = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (npc == null)
            {
                HobaDebuger.Log("The npc object is null.");
                return(CheckReturnNum(L, count, nRet));
            }

            GameObject hang_point = npc.FindChildRecursively("Bip001 Spine1");
            if (hang_point == null)
            {
                HobaDebuger.Log("The hang point object is null.");
                return(CheckReturnNum(L, count, nRet));
            }

            Transform trans_target = hang_point.transform;
            Transform trans_camera = GameObject.Find("MainCameraRoot").transform;
            Vector3   p            = new Vector3(npc.transform.forward.x, 0, npc.transform.forward.z);
            trans_camera.position = trans_target.position + p * 3;
            trans_camera.LookAt(trans_target);
        }
        else
        {
            LogParamError("CameraLookAtNpc", count);
        }

        return(CheckReturnNum(L, count, nRet));
    }
Esempio n. 3
0
        protected AnimationState GetAnimationStateByName(string animationName)
        {
            if (null == _AnimationUnitComp)
            {
                return(null);
            }
            if (null != _AnimationComp[animationName])
            {
                return(_AnimationComp[animationName]);
            }
            if (null == _AnimationInfo)
            {
                return(null);
            }

            string path = GetFullAssetPath(animationName);

            if (string.IsNullOrEmpty(path))
            {
                //HobaDebuger.Log("cant find animationPath and transform name  is "+ this.transform.name +" animationName is "+ animationName);
                return(null);
            }
            AnimationClip clip = CAssetBundleManager.SyncLoadAssetFromBundle <AnimationClip>(path, "animations", true);

            if (null == clip)
            {
                HobaDebuger.Log("cant Sync Load clip Resource and transform name  is " + this.transform.name + " animationName is " + animationName);
                return(null);
            }

            _AnimationComp.AddClip(clip, animationName);
            return(_AnimationComp[animationName]);
        }
Esempio n. 4
0
        private void SendMessageLoop()
        {
            try
            {
                while (true)
                {
                    byte[] socketSyncBytes = null;
                    _CachedSendMessageQueue.TryDequeue(out socketSyncBytes);

                    if (socketSyncBytes != null && _ServiceSocket != null)
                    {
                        int len     = socketSyncBytes.Length;
                        int sendLen = _ServiceSocket.Send(socketSyncBytes, len);
                        if (len != sendLen)
                        {
                            HobaDebuger.Log("SendMessageLoop Failed: len != sendLen ");
                        }
                    }
                    else
                    {
                        Thread.Sleep(DO_MESSAGE_INTERVAL);
                    }
                }
            }
            catch (ThreadAbortException e)
            {
                HobaDebuger.LogFormat("SendMessageLoop Failed bcz {0}", e.ToString());
            }
        }
Esempio n. 5
0
    public static void DumpStack(IntPtr L)
    {
        int top = LuaDLL.lua_gettop(L);

        for (int i = 1; i <= top; i++)
        {
            LuaTypes t = LuaDLL.lua_type(L, i);

            switch (t)
            {
            case LuaTypes.LUA_TSTRING:
                HobaDebuger.LogFormat("<String>: {0}", LuaDLL.lua_tostring(L, i));
                break;

            case LuaTypes.LUA_TBOOLEAN:
                HobaDebuger.LogFormat("<Boolean>: {0}", LuaDLL.lua_toboolean(L, i).ToString());
                break;

            case LuaTypes.LUA_TNUMBER:
                HobaDebuger.LogFormat("<Number>: {0}", LuaDLL.lua_tonumber(L, i).ToString());
                break;

            case LuaTypes.LUA_TTABLE:
                HobaDebuger.Log("<Table>: ");
                break;

            default:
                HobaDebuger.LogFormat("{0}: {1}", t.GetType().ToString(), LuaDLL.lua_tostring(L, i));
                break;
            }
        }
    }
Esempio n. 6
0
 public override void OnPointerClick(PointerEventData eventData)
 {
     HobaDebuger.Log("OnPointerClick " + eventData.pointerEnter.name);
     if (onClick != null)
     {
         onClick(gameObject);
     }
 }
Esempio n. 7
0
 public override void OnUpdateSelected(BaseEventData eventData)
 {
     HobaDebuger.Log("OnUpdateSelected ");
     if (onUpdateSelect != null)
     {
         onUpdateSelect(gameObject);
     }
 }
Esempio n. 8
0
 public new virtual void OnScroll(PointerEventData eventData)
 {
     HobaDebuger.Log("OnScroll ");
     if (onScroll != null)
     {
         onScroll(gameObject);
     }
 }
Esempio n. 9
0
 public new virtual void OnDeselect(BaseEventData eventData)
 {
     HobaDebuger.Log("OnDeselect ");
     if (onDeselect != null)
     {
         onDeselect(gameObject);
     }
 }
Esempio n. 10
0
    object[] CallFunc(LuaTable luaObject, string funcName, params object[] args)
    {
        object[] results = null;
        if (luaObject == null)
        {
            return(results);
        }

        LuaFunction lua_func = luaObject.RawGetFunc(funcName);

        if (lua_func != null)
        {
            // lua_func.Call(_LuaPanelObject, args);
            if (args.Length == 0)
            {
                results = lua_func.Call(luaObject);
            }
            else if (args.Length == 1)
            {
                results = lua_func.Call(luaObject, args[0]);
            }
            else if (args.Length == 2)
            {
                results = lua_func.Call(luaObject, args[0], args[1]);
            }
            else if (args.Length == 3)
            {
                results = lua_func.Call(luaObject, args[0], args[1], args[2]);
            }
            else if (args.Length == 4)
            {
                results = lua_func.Call(luaObject, args[0], args[1], args[2], args[3]);
            }
            else if (args.Length == 5)
            {
                results = lua_func.Call(luaObject, args[0], args[1], args[2], args[3], args[4]);
            }
            else if (args.Length == 6)
            {
                results = lua_func.Call(luaObject, args[0], args[1], args[2], args[3], args[4], args[5]);
            }
            else
            {
                HobaDebuger.Log("there are too many args.please write a new lua call.");
            }
        }
        else
        {
            HobaDebuger.Log("the function " + funcName + " you want to call can not be found.");
        }
        if (results != null && results.Length > 0)
        {
            HobaDebuger.Log(results[0]);
        }
        return(results);
    }
Esempio n. 11
0
    public void ReloadAll()
    {
        foreach (string str in _fileList)
        {
            _lua.DoFile(str, null);
        }

#if UNITY_EDITOR
        HobaDebuger.Log("Reload lua files over");
#endif
    }
Esempio n. 12
0
        //播放一个半身动画
        public void PlayPartialSkillAnimation(string aniname)
        {
            if (_AnimationComponent != null)
            {
                var aniState = GetAnimationStateByName(aniname);
                if (null == aniState)
                {
                    return;
                }

                if (_CurPartialSkillAniName != "")
                {
                    _AnimationComponent.Stop(_CurPartialSkillAniName);
                    var curState = _AnimationComponent[_CurPartialSkillAniName];
                    curState.layer   = 0;
                    curState.weight  = 1f;
                    curState.enabled = false;
                    curState.RemoveMixingTransform(_WaistTrans);
                    _CurPartialSkillAniName = "";

                    // 记录layer 1正在播的动画
                    _CurPlayingAnimation[1] = "";
                }

                var newState = GetAnimationStateByName(aniname);
                if (newState != null && _WaistTrans != null)
                {
                    newState.layer   = 1;
                    newState.weight  = 1f;
                    newState.enabled = false;
                    newState.AddMixingTransform(_WaistTrans);
                    _CurPartialSkillAniName = aniname;

                    // 记录layer 1正在播的动画
                    _CurPlayingAnimation[1] = aniname;
                }
                else
                {
                    HobaDebuger.Log("error occur, aniname not exits or bip not exist! aniname = " + aniname);
                    return;
                }

                //开播
                _AnimationComponent.Play(aniname);
            }
        }
Esempio n. 13
0
        public bool ConnectAsync(SocketAsyncEventArgs e)
        {
            if (_socket == null)
            {
                return(true);
            }
            try
            {
                return(_socket.ConnectAsync(e));
            }
            catch (Exception ex)
            {
                HobaDebuger.Log(HobaText.Format("Socket.ConnectAsync Exception: {0}", ex.Message));
            }

            return(true);
        }
Esempio n. 14
0
    public static int QuitGame(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        HobaDebuger.Log("Manually Quited by Dounble Tapping the ESC Key!");

#if UNITY_EDITOR
        if (UnityEditor.EditorApplication.isPlaying)
        {
            UnityEditor.EditorApplication.isPlaying = false;
        }
#else
        EntryPoint.ExitGame();
#endif

        return(CheckReturnNum(L, count, nRet));
    }
Esempio n. 15
0
 //为指定的SocketAsyncEventArgs分配缓存
 public bool SetBuffer(SocketAsyncEventArgs saea)
 {
     if (_freeIndexPool.Count > 0)
     {
         saea.SetBuffer(_bufferBlock, _freeIndexPool.Pop(), _buffsize_for_each_block);
     }
     else
     {
         //如果当前可分配内存已用尽
         if ((_capability - _buffsize_for_each_block) < _currentIndex)
         {
             HobaDebuger.Log("SetBuffer no enough buffer.");
             return(false);
         }
         saea.SetBuffer(_bufferBlock, _currentIndex, _buffsize_for_each_block);
         _currentIndex += _buffsize_for_each_block;
     }
     return(true);
 }
Esempio n. 16
0
    /// <summary>
    /// 创建置灰材质球
    /// </summary>
    /// <returns></returns>
    private static Material GetGrayMat()
    {
        if (GrayMat != null)
        {
            return(GrayMat);
        }
        Shader shader = Shader.Find("UI/Gray");

        if (shader == null)
        {
            HobaDebuger.Log("UIGray cannt  find ui.gray ");
            return(null);
        }
        Material mat = new Material(shader);

        GrayMat = mat;

        return(GrayMat);
    }
Esempio n. 17
0
    public bool Init(string strNavMeshPath)
    {
        _IsInited = false;

#if SERVER_USE
        var fullName = Path.Combine(Template.Path.BasePath, string.Format("Maps/{0}", strNavMeshPath));
            fullName =  fullName.Trim();
        if (!File.Exists(fullName))
        {
            throw new Exception($"{fullName} not exist");
        }
        var navmesh_data = File.ReadAllBytes(fullName);
#else
        var fullName = Path.Combine(EntryPoint.Instance.ResPath, HobaText.Format("Maps/{0}", strNavMeshPath));
        var navmesh_data = Util.ReadFile(fullName);
        if (navmesh_data == null)
        {
            HobaDebuger.Log(HobaText.Format("{0} not exist", fullName));
            return false;
        }
#endif

        Release();

        if (navmesh_data.Length == 0)
            return false;

        _NavMeshName = strNavMeshPath.Trim();
        Common.SCounters.Instance.Increase(EnumCountType.LoadNavMeshFromMemory);
        _NavMesh = LuaDLL.NM_LoadNavMeshFromMemory(navmesh_data, navmesh_data.Length);
        if (_NavMesh == IntPtr.Zero)
            return false;

        Common.SCounters.Instance.Increase(EnumCountType.CreateNavQuery);
        _NavQuery = LuaDLL.NM_CreateNavQuery(_NavMesh, MAX_NODES);
        if (_NavQuery == IntPtr.Zero)
            return false;

        _IsInited = true;

        return true;
    }
Esempio n. 18
0
    public void SetData(Vector3 dest, float time, LuaFunction cbRef, bool canPierce, bool goOnAfterKill, bool onlyCollideWithSkillTarget = false, bool canChangeDir = false)
    {
        if (time <= 0)
        {
            HobaDebuger.Log("Move time can not be 0 !!!!");
            return;
        }

        var offset = dest - _Owner.position;

        offset.y = 0;
        _Speed   = offset.magnitude / time;

        if (canChangeDir)
        {
            _Direction   = _Owner.forward;
            _LerpDestDir = _Direction;
            var maxDis = _Speed * time;
            var dis    = Util.GetMaxValidDistance(_Owner.position, _Direction, maxDis);
            _Destination = _Owner.position + _Direction * dis;
        }
        else
        {
            _Destination = dest;
            _Direction   = offset.normalized;
            _LerpDestDir = Vector3.zero;
        }

        _FinishedTime               = Time.time + time;
        OnFinishCallbackRef         = cbRef;
        _CanPierce                  = canPierce;
        _DashContinue               = goOnAfterKill;
        _OnlyCollideWithSkillTarget = onlyCollideWithSkillTarget;
        _CanChangeDir               = canChangeDir;

        if (null == _ObjectComponent)
        {
            _ObjectComponent = _Owner.GetComponent <ObjectBehaviour>();
        }

        LastSyncTimestamp = 0;
    }
Esempio n. 19
0
 public void OnConnectedCompleted(object sender, SocketAsyncEventArgs e)
 {
     if (e.SocketError != SocketError.Success)
     {
         var cea = _ConnectionEventArgsPool.GetObject();
         cea.Set(EnumConnectionEventType.connect_failed, null, null, 0);
         _ConEventArgsQueue.Enqueue(cea);
     }
     else
     {
         if (e.LastOperation == SocketAsyncOperation.Connect)
         {
             ProcessConnect(e);
         }
         else
         {
             HobaDebuger.Log(HobaText.Format("Connect_Completed Error: {0}", e.LastOperation));
         }
     }
 }
Esempio n. 20
0
 public void Close()
 {
     try
     {
         if (_socket != null)
         {
             if (_socket.Connected)
             {
                 _socket.Shutdown(SocketShutdown.Both);
             }
             _socket.Close();
             HobaDebuger.Log(HobaText.Format("Socket closed successfully"));
             //_socket.Dispose();
         }
     }
     catch (Exception ex)
     {
         HobaDebuger.Log(HobaText.Format("ExSocket close error: {0}", ex.Message));
     }
 }
Esempio n. 21
0
 public void OnReceiveCompleted(object sender, SocketAsyncEventArgs e)
 {
     try
     {
         if (e.LastOperation == SocketAsyncOperation.Receive)
         {
             ProcessReceive(e);
         }
         else if (e.LastOperation == SocketAsyncOperation.Send)
         {
         }
         else
         {
             HobaDebuger.Log(HobaText.Format("LastOperation is not send or receive: {0}", e.LastOperation));
         }
     }
     catch (Exception ex)
     {
         HobaDebuger.Log(HobaText.Format("OnReceiveCompleted Failed : {0}", ex.Message));
     }
 }
Esempio n. 22
0
    public void OnEnterScene(GameObject sceneRoot)
    {
        _SceneRoot = sceneRoot;
        if (null == sceneRoot)
        {
            HobaDebuger.Log("scene prefab seems  instantiate  failed . ");
            return;
        }

        _ConfigData = sceneRoot.GetComponent <SceneConfig>();
        if (null == _ConfigData)
        {
            HobaDebuger.Log(" Is not a scene prefab.");
            return;
        }

        ScenesRegionManager.Instance.Init(_ConfigData._LightRegionName);
        DynamicEffectManager.Instance.Init(_ConfigData);
        _TerrainsManager.Init(_ConfigData._LightmapConfig._TerrainLightmapInfos);
        _BlocksManager.Init(_ConfigData);
        _ColliderManager.Init(_ConfigData);
    }
Esempio n. 23
0
    private void UpdateLightmaps()
    {
        if (null == _PlayerLightmapBundleAsset)
        {
            return;
        }

        var changed = _IsLightmapsUpdated;

        //判断是否发生改变  //没有变化, 无需设置
        if (!changed)
        {
            return;
        }

        var it = _LightmapIdx2RefCountDic.GetEnumerator();

        while (it.MoveNext())
        {
            var kv = it.Current;
            if (0 == kv.Value)
            {
                _SceneLightmapDatas[kv.Key].lightmapColor = Texture2D.whiteTexture;
                _SceneLightmapDatas[kv.Key].lightmapDir   = Texture2D.whiteTexture;
            }
            else if (kv.Value > 0)
            {
                _SceneLightmapDatas[kv.Key].lightmapColor = _PlayerLightmapBundleAsset._LightmapFar[kv.Key];
                _SceneLightmapDatas[kv.Key].lightmapDir   = _PlayerLightmapBundleAsset._LightmapNear[kv.Key];
            }
            else
            {
                HobaDebuger.Log("引用计数错误,此值不应该小于0");
            }
        }
        it.Dispose();
        LightmapSettings.lightmaps = _SceneLightmapDatas;
    }
Esempio n. 24
0
        private bool TryMakeMessages()
        {
            bool res = false;

            do
            {
                try
                {
                    List <byte[]> msgList = null;

                    if (!MessageProcessUtil.TryReadMessage(_DataToken, _SAEA4Recv.Buffer, _SAEA4Recv.BytesTransferred, out msgList))
                    {
                        break;
                    }

                    if (msgList != null)
                    {
                        var v = msgList.GetEnumerator();
                        while (v.MoveNext())
                        {
                            var cea = _ConnectionEventArgsPool.GetObject();
                            cea.Set(EnumConnectionEventType.recv, _ServiceSocket, v.Current, 0);
                            _ConEventArgsQueue.Enqueue(cea);
                        }
                        v.Dispose();

                        msgList.Clear();
                        res = true;
                    }
                }
                catch (Exception ex)
                {
                    HobaDebuger.Log(HobaText.Format("TryReceiveMessage: {0}", ex.Message));
                }
            } while (false);

            return(res);
        }
Esempio n. 25
0
    void OnApplicationQuit()
    {
        _IsQuiting = true;

        //CTimerList.ShowDiagnostics();
        //EntityVisualEffect.EffectObjectPool.ShowDiagnostics();
        //MaterialPool.Instance.ShowDiagnostics();
        //FileImage.ShowDiagnostics();
        if (_IsCurlInited)
        {
            Curl.GlobalCleanup();
            _IsCurlInited = false;
        }

        CGameSession.Instance().Close();

        if (_IsInited)
        {
            LuaScriptMgr.Instance.CallLuaFunction("ReleaseGame");
            LuaScriptMgr.Instance.Destroy();
            NavMeshManager.Instance.Release();
            LuaDLL.HOBA_Release();
            _IsInited = false;
        }

        _TimerList.Clear();
        _LateTimerList.Clear();

        CLogicObjectMan <ObjectBehaviour> .Instance.Cleanup();

        CLogicObjectMan <EntityEffectComponent> .Instance.Cleanup();

        ResCacheMan.Instance.Cleanup();
        CFxCacheMan.Instance.Cleanup();

        HobaDebuger.Log("Application Quit!");
    }
Esempio n. 26
0
    public void Init()
    {
        if (EntryPoint.Instance.GameCustomConfigParams.UseVoice)
        {
            IsEnabled = InitVoice();
        }
        else
        {
            IsEnabled = false;
        }

        VoiceDir = EntryPoint.Instance.VoiceDir;

        TempVoiceFile = Path.Combine(VoiceDir, "tmp.wav");
        //TempVoiceFile = Path.Combine(VoiceDir, "tmp.mp3");
        TempVoiceLength = 0;

        if (!Directory.Exists(VoiceDir))
        {
            Directory.CreateDirectory(VoiceDir);
        }

        HobaDebuger.Log(HobaText.Format("VoiceManager Init IsEnabled: {0}, VoiceDir: {1}", IsEnabled, VoiceDir));
    }
Esempio n. 27
0
    /// 根据角色位置,预加载周围的分块后回调
    public void Preload(float posx, float posz, Action callback)
    {
        if (null == _Config)
        {
            HobaDebuger.Log("Scene Config Init Failed,Please Make Sure Scene Prefab Loaded Success ! ");
            return;
        }

        _CallBack = callback;
        var preLoadBlockList = new List <SceneConfig.CPositionSetting>();

        _PreLoadBlockCounter = 0;

        int blockCount = _Config._BlockPositionList.Count;

        for (int i = 0; i < blockCount; ++i)
        {
            var currentBlock = _Config._BlockPositionList[i];

            if (_SceneQuality < currentBlock._SceneQuality)
            {
                continue;
            }

            float fDistance = Util.DistanceH(currentBlock._BlockPosition, new Vector3(posx, 0, posz));
            if (fDistance <= currentBlock._ShowDistance)
            {
                preLoadBlockList.Add(currentBlock);
            }
        }

        int nBlockCount = preLoadBlockList.Count;

        _PreLoadBlockCounter = nBlockCount;

        if (nBlockCount == 0)
        {
            AddToSpecialObjectList(_Config.gameObject);
        }
        else
        {
            for (var index = 0; index < nBlockCount; index++)
            {
                var currentPos = preLoadBlockList[index];
                if (!_LoadedPoints.Contains(currentPos._BlockName))
                {
                    for (int i = 0; i < currentPos._LightIndexArray.Length; i++)
                    {
                        int val;
                        if (_LightmapIdx2RefCountDic.TryGetValue(currentPos._LightIndexArray[i], out val))
                        {
                            _LightmapIdx2RefCountDic[currentPos._LightIndexArray[i]] = val + 1;
                            _IsLightmapsUpdated = true;
                        }
                        else
                        {
                            HobaDebuger.LogFormat("光照贴图索引不正确,最大索引{0},当前索引为{1},资源{2}", _LightmapIdx2RefCountDic.Count - 1, currentPos._LightIndexArray[i], currentPos._BlockName);
                            continue;
                        }
                    }
                    _LoadedPoints.Add(currentPos._BlockName);
                    LoadBlockWithCounter(currentPos._BlockName, currentPos._EffectiveType);
                }
                else
                {
                    --_PreLoadBlockCounter;
                    HobaDebuger.LogErrorFormat("{0} 重复名字的Block! {1}", index, currentPos._BlockName);
                }
            }
        }

        ///计数加载,加载完成之后进行回调
        if (0 == _PreLoadBlockCounter && _CallBack != null)
        {
            _CallBack();
            _CallBack = null;
        }
    }
Esempio n. 28
0
    private void LoadAssetWithPlayerLight(SceneConfig.LightmapsConfig lightmapConf)
    {
        if (string.IsNullOrEmpty(lightmapConf._LightmapAssetName))
        {
            HobaDebuger.Log("this scenes 's lightmap asset name is null ,please check resources");
            return;
        }

        var loadedSceneId = _CurSceneGuid;
        Action <UnityEngine.Object> callback = (asset) =>
        {
            if (loadedSceneId != _CurSceneGuid)
            {
                HobaDebuger.LogWarning("the asset being loaded is not belong to this scene ");
                return;
            }
            LightMapAsset lightmapAsset = asset as LightMapAsset;

            if (null == lightmapAsset)
            {
                HobaDebuger.LogWarning("Lightmap asset loaded failed  ! ");
                return;
            }
            _PlayerLightmapBundleAsset = lightmapAsset;

            #region 预加载的物件光照信息补全

            List <int> tempList = new List <int>();
            for (int i = 0; i < lightmapConf._MeshLightmapInfos.Length; i++)
            {
                if (null != lightmapConf._MeshLightmapInfos[i]._Renderer)
                {
                    if (!tempList.Contains(lightmapConf._MeshLightmapInfos[i]._LightmapIndex))
                    {
                        tempList.Add(lightmapConf._MeshLightmapInfos[i]._LightmapIndex);
                    }
                    lightmapConf._MeshLightmapInfos[i]._Renderer.lightmapIndex       = lightmapConf._MeshLightmapInfos[i]._LightmapIndex;
                    lightmapConf._MeshLightmapInfos[i]._Renderer.lightmapScaleOffset = lightmapConf._MeshLightmapInfos[i]._LightmapScaleOffset;
                }
            }
            for (int i = 0; i < lightmapConf._TerrainLightmapInfos.Length; i++)
            {
                if (null != lightmapConf._TerrainLightmapInfos[i]._Terrain)
                {
                    if (!tempList.Contains(lightmapConf._TerrainLightmapInfos[i]._LightmapIndex))
                    {
                        tempList.Add(lightmapConf._TerrainLightmapInfos[i]._LightmapIndex);
                    }

                    lightmapConf._TerrainLightmapInfos[i]._Terrain.lightmapIndex       = lightmapConf._TerrainLightmapInfos[i]._LightmapIndex;
                    lightmapConf._TerrainLightmapInfos[i]._Terrain.lightmapScaleOffset = lightmapConf._TerrainLightmapInfos[i]._LightmapScaleOffset;
                }
            }

            for (int i = 0; i < tempList.Count; i++)
            {
                int v = _LightmapIdx2RefCountDic[tempList[i]];
                if (0 == v)
                {
                    _IsLightmapsUpdated = true;
                }
                _LightmapIdx2RefCountDic[tempList[i]] = v + 1;
            }
            UpdateLightmaps();
            #endregion 预加载的物件光照信息补全
            // if (EntryPoint.Instance._UsingStaticBatching)
            //   CUnityHelper.StaticBatching(gameObject);
        };

        CAssetBundleManager.AsyncLoadResource(lightmapConf._LightmapAssetName, callback, false, "scenes");
    }
Esempio n. 29
0
        public void Connect(string ipStr, int port)
        {
            _CachedSendMessageQueue.Clear();
            _ConEventArgsQueue.Clear();

            _RemoteEndPoint = new IPEndPoint(IPAddress.Parse(ipStr), port);
            if (_ServiceSocket != null)
            {
                _ServiceSocket.Close();
                _ServiceSocket = null;
            }
            _ServiceSocket = new ExSocket(_RemoteEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            if (_SAEA4Connect != null)
            {
                _SAEA4Connect.Dispose();
                _SAEA4Connect = null;
            }
            _SAEA4Connect = new SocketAsyncEventArgs {
                RemoteEndPoint = _RemoteEndPoint
            };
            _SAEA4Connect.Completed += OnConnectedCompleted;

            try
            {
                if (!_ServiceSocket.ConnectAsync(_SAEA4Connect))
                {
                    ProcessConnect(_SAEA4Connect);
                }

                if (_ConnectTimer != null)
                {
                    _ConnectTimer.Close();
                }

                _ConnectTimer           = new System.Timers.Timer(CONNECT_TIME_OUT);
                _ConnectTimer.AutoReset = false;
                _ConnectTimer.Enabled   = true;
                _ConnectTimer.Elapsed  += new System.Timers.ElapsedEventHandler((object source, System.Timers.ElapsedEventArgs e) =>
                {
                    if (_ServiceSocket != null && !_ServiceSocket.Connected)
                    {
                        _ServiceSocket.Close();
                        _ServiceSocket = null;
                        var cea        = _ConnectionEventArgsPool.GetObject();
                        cea.Set(EnumConnectionEventType.connect_failed, null, null, 0);
                        _ConEventArgsQueue.Enqueue(cea);
                    }
                });
            }
            catch (Exception ex)
            {
                HobaDebuger.Log(HobaText.Format("Connect Failed: {0}", ex.Message));
            }

            if (_SyncSendMessageThread != null)
            {
                _SyncSendMessageThread.Abort();
                _SyncSendMessageThread = null;
            }

            _SyncSendMessageThread = new Thread(SendMessageLoop);
            _SyncSendMessageThread.Start();
        }