Ejemplo n.º 1
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());
            }
        }
Ejemplo n.º 2
0
    private void BuildShaderList(GameObject shaderListObj)
    {
        _ShaderMap.Clear();

        if (shaderListObj != null)
        {
            ShaderList compShaderList = shaderListObj.GetComponent <ShaderList>();
            if (compShaderList != null && compShaderList.Shaders != null)
            {
                try
                {
                    int nCount = compShaderList.Shaders.Length;
                    HobaDebuger.LogFormat("ShaderManager.Init, Shaders Count: {0}", nCount);
                    for (int i = 0; i < nCount; ++i)
                    {
                        Shader shader = compShaderList.Shaders[i];
                        if (shader != null && !_ShaderMap.ContainsKey(shader.name))
                        {
                            _ShaderMap.Add(shader.name, shader);
                            //HobaDebuger.LogFormat("ShaderManager.Init, Load Shader: {0}", shader.name);
                        }
                        else
                        {
                            HobaDebuger.LogWarning(HobaText.Format("ShaderManager.Init, Shader {0} is missing!", i));
                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    HobaDebuger.LogError(ae.Message);
                }
            }
        }
    }
Ejemplo n.º 3
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;
            }
        }
    }
Ejemplo n.º 4
0
    private void BuildShaderList(GameObject shaderListObj)
    {
        //ShaderManager.Instance._ShaderMap.Clear();

        if (shaderListObj != null)
        {
            ShaderList compShaderList = shaderListObj.GetComponent <ShaderList>();
            if (compShaderList != null && compShaderList.Shaders != null)
            {
                try
                {
                    int nCount = compShaderList.Shaders.Length;
                    HobaDebuger.LogFormat("ShaderManager.Init, Shaders Count: {0}", nCount);
                    for (int i = 0; i < nCount; ++i)
                    {
                        Shader shader = compShaderList.Shaders[i];
                        if (shader == null)
                        {
                            Debug.LogErrorFormat("ShaderManager.Init, Shader {0} is missing!", i);
                            AssetBundleCheck.Instance._ErrorString += string.Format("ShaderManager.Init, Shader {0} is missing!", i);
                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    HobaDebuger.LogError(ae.Message);
                }
            }
        }
    }
Ejemplo n.º 5
0
        public void OnConnectFailed(ConnectionEventArgs e)
        {
#if UNITY_EDITOR || UNITY_STANDALONE
            HobaDebuger.LogFormat(HobaText.Format("{0} ConnectFailed.", _IP));
#endif
            if (OnGatewayEvent != null)
            {
                OnGatewayEvent(EVENT.CONNECT_FAILED);
            }
        }
Ejemplo n.º 6
0
    public static void UnloadBundle(string bundleName)
    {
        LoadedAssetBundle lab;

        if (_LoadedAssetBundles.TryGetValue(bundleName, out lab))
        {
            lab.Bundle.Unload(false);
            _LoadedAssetBundles.Remove(bundleName);
            HobaDebuger.LogFormat("Unload unuesd bundles: {0}", bundleName);
        }
    }
Ejemplo n.º 7
0
        public void OnConnected(ConnectionEventArgs e)
        {
            //_serviceSocket = e.Exsocket;
#if UNITY_EDITOR || UNITY_STANDALONE
            HobaDebuger.LogFormat(HobaText.Format("{0} Connected.", _IP));
#endif
            if (OnGatewayEvent != null)
            {
                OnGatewayEvent(EVENT.CONNECTED);
            }
        }
Ejemplo n.º 8
0
        public static int print(IntPtr L)
        {
            if (HobaDebuger.GameLogLevel < LogLevel.Log)
            {
                return(0);
            }

            // For each argument we'll 'tostring' it
            int    n = LuaDLL.lua_gettop(L);
            string s = String.Empty;

            LuaDLL.lua_getglobal(L, "tostring");

            for (int i = 1; i <= n; i++)
            {
                LuaDLL.lua_pushvalue(L, -1);                  /* function to be called */
                LuaDLL.lua_pushvalue(L, i);                   /* value to print */
                LuaDLL.lua_call(L, 1, 1);

                string ret = LuaDLL.lua_tostring(L, -1);
                if (ret == null)
                {
                    HobaDebuger.LogError("!!!! lua print return null*");
                }
                else
                {
                    s += ret;
                }

                if (i < n)
                {
                    s += "\t";
                }

                LuaDLL.lua_pop(L, 1);                  /* pop result */
            }

#if !SERVER_USE
            if (!EntryPoint.Instance.IsInited)
            {
                LuaDLL.HOBA_LogString(HobaText.Format("print LUA: {0}", s));
            }
#endif
            HobaDebuger.LogFormat("LUA: {0}", s);

            return(0);
        }
Ejemplo n.º 9
0
    /// 销毁分块
    private void DestroyInstGo(ref SceneConfig.CPositionSetting currentPos)
    {
        if (!_LoadedPoints.Contains(currentPos._BlockName))
        {
            return;
        }
        var _cacheGo = FindRegObj(currentPos._BlockName);

        if (null == _cacheGo)
        {
            return;
        }

        _LoadedObjectDic.Remove(currentPos._BlockName);
        RemoveFromSpecialObjectList(_cacheGo);
        ScenesAnimationManager.Instance.RemoveAnimationObj(currentPos._BlockName);
        _ObjectCacheDic.Remove(currentPos._BlockName);
        GameObject.Destroy(_cacheGo);
        _LoadedPoints.Remove(currentPos._BlockName);

        for (int i = 0; i < currentPos._LightIndexArray.Length; i++)
        {
            int v;
            if (_LightmapIdx2RefCountDic.TryGetValue(currentPos._LightIndexArray[i], out v))
            {
                if (v > 0)
                {
                    _LightmapIdx2RefCountDic[currentPos._LightIndexArray[i]] = v - 1;
                    _IsLightmapsUpdated = true;
                }
                else
                {
                    HobaDebuger.LogFormat("尝试销毁一张不存在的贴图,分块名称为 {0}", currentPos._BlockName);
                }
            }
            else
            {
                HobaDebuger.LogFormat("索引不正确,名称为 {0}", currentPos._BlockName);
                continue;
            }
        }
    }
Ejemplo n.º 10
0
    /// 加载分块
    private void LoadInstGo(ref SceneConfig.CPositionSetting currentPos, Vector3 position)
    {
        int filterRegionIndex = ScenesRegionManager.Instance.CurBlockReigionID;
        var isContains        = IsContainsKey(currentPos._RegionArray, filterRegionIndex);

        if (!isContains)
        {
            return;
        }

        /// 同名文件不重复加载
        if (_LoadedPoints.Contains(currentPos._BlockName))
        {
            GameObject cacheGo;
            if (_ObjectCacheDic.TryGetValue(currentPos._BlockName, out cacheGo))
            {
                cacheGo.transform.transform.localPosition = currentPos._BlockPosition;
                AddToSpecialObjectList(cacheGo);
            }
        }
        else
        {
            for (int i = 0; i < currentPos._LightIndexArray.Length; i++)
            {
                int val = 0;
                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);
            LoadBlockFromBundle(currentPos._BlockName, currentPos._EffectiveType);
        }
    }
Ejemplo n.º 11
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;
        }
    }
Ejemplo n.º 12
0
    private void LoadVersionData()
    {
        if (Instance == null)
        {
            throw new Exception("Failed to Initialize");
        }

        byte[] abVersionContent;
        if (CAssetBundleManager.IsUpdateFileExist("abversion.txt"))         //使用更新目录下的abversion.txt
        {
            string dirAssetBundles = CAssetBundleManager.UpdateAssetBundleURL;
            abVersionContent = Util.ReadFile(dirAssetBundles + "abversion.txt");

            HobaDebuger.LogFormat("Use abversion.txt from Update Dir: {0}", dirAssetBundles);
        }
        else
        {
            string dirAssetBundles = CAssetBundleManager.GameResBasePath;
            abVersionContent = Util.ReadFile(dirAssetBundles + "abversion.txt");

            HobaDebuger.LogFormat("Use abversion.txt from Base Dir: {0}", dirAssetBundles);
        }

        if (null != abVersionContent)
        {
            StreamReader sr      = new StreamReader(new MemoryStream(abVersionContent));
            string       strLine = sr.ReadLine();
            if (strLine != null)
            {
                _ABVersion = strLine;
            }
            sr.Close();
        }
        else
        {
            _ABVersion = "0";  //所有文件夹下都没有对应的版本信息。默认为0
        }
        //HobaDebuger.LogFormat("Use abversion.txt ReadLine: {0}", _ABVersion);

        byte[] clientVersionContent;
        if (CAssetBundleManager.IsUpdateFileExist("clientversion.txt"))         //使用更新目录下的clientversion.txt
        {
            string dirAssetBundles = CAssetBundleManager.UpdateAssetBundleURL;
            clientVersionContent = Util.ReadFile(dirAssetBundles + "clientversion.txt");

            HobaDebuger.LogFormat("Use clientversion.txt from Update Dir: {0}", dirAssetBundles);
        }
        else
        {
            string dirAssetBundles = CAssetBundleManager.GameResBasePath;
            clientVersionContent = Util.ReadFile(dirAssetBundles + "clientversion.txt");

            HobaDebuger.LogFormat("Use clientversion.txt from Base Dir: {0}", dirAssetBundles);
        }

        if (null != clientVersionContent)
        {
            StreamReader sr      = new StreamReader(new MemoryStream(clientVersionContent));
            string       strLine = sr.ReadLine();
            if (strLine != null)
            {
                _ClientVersion = strLine;
            }
            sr.Close();
        }
        else
        {
            _ClientVersion = "0";  //所有文件夹下都没有对应的版本信息。默认为0
        }
        //HobaDebuger.LogFormat("Use clientversion.txt ReadLine: {0}", _ClientVersion);
    }