Example #1
0
    /// <summary>
    /// Logs the debug.
    /// </summary>
    /// <param name="tag">Tag.</param>
    /// <param name="format">Format.</param>
    /// <param name="args">Arguments.</param>
    public static void DebugLog(string tag, string format, params object[] args)
    {
        if (!_debugMode)
        {
            return;
        }

        if (string.IsNullOrEmpty(format))
        {
            return;
        }

        Console.WriteLine("[BuglyAgent] <Debug> - {0} : {1}", tag, HobaText.Format(format, args));
    }
Example #2
0
    public static T[] GetArrayNumber <T>(IntPtr L, int stackPos)
    {
        LuaTypes luatype = LuaDLL.lua_type(L, stackPos);

        if (luatype == LuaTypes.LUA_TTABLE)
        {
            int      index = 1;
            T        ret   = default(T);
            List <T> list  = new List <T>();
            LuaDLL.lua_pushvalue(L, stackPos);

            while (true)
            {
                LuaDLL.lua_rawgeti(L, -1, index);
                luatype = LuaDLL.lua_type(L, -1);

                if (luatype == LuaTypes.LUA_TNIL)
                {
                    LuaDLL.lua_pop(L, 1);
                    break;
                }
                else if (luatype != LuaTypes.LUA_TNUMBER)
                {
                    LuaDLL.lua_pop(L, 1);
                    break;
                }

                ret = (T)Convert.ChangeType(LuaDLL.lua_tonumber(L, -1), typeof(T));
                list.Add(ret);
                LuaDLL.lua_pop(L, 1);
                ++index;
            }

            LuaDLL.lua_pop(L, 1);
            return(list.ToArray());
        }
        else if (luatype == LuaTypes.LUA_TUSERDATA)
        {
            T[] ret = GetNetObject <T[]>(L, stackPos);

            if (ret != null)
            {
                return((T[])ret);
            }
        }

        LuaDLL.luaL_error(L, HobaText.Format("invalid arguments to method: {0}, pos {1}", GetErrorFunc(1), stackPos));
        return(null);
    }
Example #3
0
    public static void Test()
    {
        var COUNT = 1024;
        var SCALE = 1;

        var str1 = "Hello";
        var str2 = " ";
        var str3 = "TERA";

        //long startMem, endMem, costMem;
        long startTime, endTime, costTime;

        // test1
        //startMem = Profiler.GetMonoHeapSize();
        startTime = DateTime.Now.Ticks;
        for (var i = 0; i < COUNT; i++)
        {
            var res = str1 + str2 + i;
        }
        endTime = DateTime.Now.Ticks;
        //endMem = Profiler.GetMonoHeapSize();
        costTime = (endTime - startTime) * SCALE;
        //costMem = endMem - startMem;
        UnityEngine.Debug.Log("Method 1 costs " + costTime);   // 10001

        //startMem = Profiler.GetMonoHeapSize();
        startTime = DateTime.Now.Ticks;
        for (var i = 0; i < COUNT; i++)
        {
            var res = string.Format("{0}{1}{2}", str1, str2, i);
        }
        endTime = DateTime.Now.Ticks;
        //endMem = Profiler.GetMonoHeapSize();
        costTime = (endTime - startTime) * SCALE;
        //costMem = endMem - startMem;
        UnityEngine.Debug.Log("Method 2 costs " + costTime);   // 20002

        //startMem = GC.GetTotalMemory(true);
        startTime = DateTime.Now.Ticks;
        for (var i = 0; i < COUNT; i++)
        {
            var res = HobaText.Format("{0}{1}{2}", str1, str2, i);
        }
        endTime = DateTime.Now.Ticks;
        //endMem = GC.GetTotalMemory(true);
        costTime = (endTime - startTime) * SCALE;
        //costMem = endMem - startMem;
        UnityEngine.Debug.Log("Method 3 costs " + costTime);  // 10000
    }
Example #4
0
    //如果本地文件不存在,设置为初始版本, 如果当前版本 < 初始版本,则写新版本, ret是否新写入baseVersion
    public bool SetFirstVersion(ELEMENT_VER ver, bool bForceWrite)
    {
        m_baseVer = ver;

        if (bForceWrite || !FileOperate.IsFileExist(strGameOldVerFile))
        {
            if (!FileOperate.MakeDir(strGameOldVerFile))
            {
                LogString(HobaText.Format("[SetFirstVersion] MakeDir {0} Failed!", strGameOldVerFile));
            }
            UpdateRetCode ret = SetLocalVersion(ver);
            if (ret != UpdateRetCode.success)
            {
                LogString(HobaText.Format("[SetFirstVersion] SetLocalVersion {0} Failed!", strGameOldVerFile));
            }
            else
            {
                return(true);
            }
        }
        else
        {
            ELEMENT_VER localVersion;
            if (GetLocalVersion(out localVersion) && localVersion < m_baseVer)
            {
                LogString(HobaText.Format("[SetFirstVersion] Local Version File Exist {0}! Write New Version From: {1} To {2}", strGameOldVerFile, localVersion.ToString(), ver.ToString()));

                if (!FileOperate.MakeDir(strGameOldVerFile))
                {
                    LogString(HobaText.Format("[SetFirstVersion] MakeDir {0} Failed2!", strGameOldVerFile));
                }
                UpdateRetCode ret = SetLocalVersion(ver);
                if (ret != UpdateRetCode.success)
                {
                    LogString(HobaText.Format("[SetFirstVersion] SetLocalVersion {0} Failed2!", strGameOldVerFile));
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                LogString(HobaText.Format("[SetFirstVersion] Local Version File Exist {0}!", strGameOldVerFile));
            }
        }

        return(false);
    }
Example #5
0
    public static Int64 GetUrlFileSizeEx(string url, string hostname, int timeout)
    {
        long size = -1;

        Easy easy = new Easy();

        Easy.SetCurrentEasy(easy);
        Slist headers = new Slist();

        headers.Append(HobaText.Format("Host: {0}", hostname));

        easy.SetOpt(CURLoption.CURLOPT_URL, url);
        easy.SetOpt(CURLoption.CURLOPT_HEADER, 1L);
        easy.SetOpt(CURLoption.CURLOPT_NOBODY, 1L);
        easy.SetOpt(CURLoption.CURLOPT_HTTPHEADER, headers);
        //easy.SetOpt(CURLoption.CURLOPT_IPRESOLVE, (long)CURLipResolve.CURL_IPRESOLVE_V4);
        easy.SetOpt(CURLoption.CURLOPT_CONNECTTIMEOUT, timeout / 1000);

        easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, 0L);
        easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYHOST, 0L);

        int    error = 0;
        double downloadFileLength = 0.0f;

        if (easy.Perform() == CURLcode.CURLE_OK)
        {
            CURLcode code = easy.GetInfo(CURLINFO.CURLINFO_RESPONSE_CODE, ref error);

            if (code == CURLcode.CURLE_OK && error == 200)
            {
                easy.GetInfo(CURLINFO.CURLINFO_CONTENT_LENGTH_DOWNLOAD, ref downloadFileLength);
            }

            if (downloadFileLength >= 0.0f)
            {
                size = (int)downloadFileLength;
            }
        }
        else
        {
            size = -1;
        }

        headers.FreeAll();
        Easy.SetCurrentEasy(null);
        easy.Cleanup();

        return(size);
    }
Example #6
0
 public static bool CanGetPixel(Texture2D tex)
 {
     try
     {
         tex.GetPixel(0, 0);
     }
     catch (UnityException e)
     {
         if (e.Message.StartsWith(HobaText.Format("Texture '{0}' is not readable", tex.name)))
         {
             return(false);
         }
     }
     return(true);
 }
Example #7
0
    public static bool[] GetArrayBool(IntPtr L, int stackPos)
    {
        LuaTypes luatype = LuaDLL.lua_type(L, stackPos);

        if (luatype == LuaTypes.LUA_TTABLE)
        {
            int         index = 1;
            List <bool> list  = new List <bool>();
            LuaDLL.lua_pushvalue(L, stackPos);

            while (true)
            {
                LuaDLL.lua_rawgeti(L, -1, index);
                luatype = LuaDLL.lua_type(L, -1);

                if (luatype == LuaTypes.LUA_TNIL)
                {
                    LuaDLL.lua_pop(L, 1);
                    break;
                }
                else if (luatype != LuaTypes.LUA_TBOOLEAN)
                {
                    LuaDLL.lua_pop(L, 1);
                    break;
                }

                bool ret = LuaDLL.lua_toboolean(L, -1);
                list.Add(ret);
                LuaDLL.lua_pop(L, 1);
                ++index;
            }

            LuaDLL.lua_pop(L, 1);
            return(list.ToArray());
        }
        else if (luatype == LuaTypes.LUA_TUSERDATA)
        {
            bool[] ret = GetNetObject <bool[]>(L, stackPos);

            if (ret != null)
            {
                return((bool[])ret);
            }
        }

        LuaDLL.luaL_error(L, HobaText.Format("invalid arguments to method: {0}, pos {1}", GetErrorFunc(1), stackPos));
        return(null);
    }
Example #8
0
    public string GetUserLanguagePostfix(bool bAssetBundle)
    {
        string code = GetUserLanguageCode();

        if (code == "CN")
        {
            return("");
        }

        if (bAssetBundle)                       //assetbundle只认小写
        {
            return(HobaText.Format("_{0}", code.ToLower()));
        }

        return(HobaText.Format("_{0}", code));
    }
Example #9
0
    public bool UploadPicture(string strFile, string playerGuid, UploadPictureCallback callback)
    {
        string url = _ServerConfigParams.GetCustomPicUploadUrl();

        byte[] content = File.ReadAllBytes(strFile);
        if (content.Length == 0 || content.Length > 10 * 1024 * 1024)
        {
            return(false);
        }

        string realUrl = HobaText.Format(url, playerGuid);

        StartCoroutine(UploadPictureToUrl(strFile, content, realUrl, callback));

        return(true);
    }
Example #10
0
    public static string[] GetArrayString(IntPtr L, int stackPos)
    {
        LuaTypes luatype = LuaDLL.lua_type(L, stackPos);

        if (luatype == LuaTypes.LUA_TTABLE)
        {
            int           index  = 1;
            string        retVal = null;
            List <string> list   = new List <string>();
            LuaDLL.lua_pushvalue(L, stackPos);

            while (true)
            {
                LuaDLL.lua_rawgeti(L, -1, index);
                luatype = LuaDLL.lua_type(L, -1);

                if (luatype == LuaTypes.LUA_TNIL)
                {
                    LuaDLL.lua_pop(L, 1);
                    break;
                }
                else
                {
                    retVal = GetLuaString(L, -1);
                }

                list.Add(retVal);
                LuaDLL.lua_pop(L, 1);
                ++index;
            }

            LuaDLL.lua_pop(L, 1);
            return(list.ToArray());
        }
        else if (luatype == LuaTypes.LUA_TUSERDATA)
        {
            string[] ret = GetNetObject <string[]>(L, stackPos);

            if (ret != null)
            {
                return((string[])ret);
            }
        }

        LuaDLL.luaL_error(L, HobaText.Format("invalid arguments to method: {0}, pos {1}", GetErrorFunc(1), stackPos));
        return(null);
    }
Example #11
0
    public void Tick(float delta)
    {
        if (!IsDebugInfoDisplay || FPSLabel == null)
        {
            return;
        }

        if (_LastFPSTime == 0)
        {
            _LastFPSTime   = Time.unscaledTime;
            _CurFrameCount = Time.frameCount;
            FPSLabel.text  = string.Empty;
            _FPS           = 0;
        }
        else
        {
            float curTime = Time.unscaledTime;

            if (curTime - _LastFPSTime >= 1.0f)
            {
                int nFrameCount = Time.frameCount;

                if (FPSLabel.enabled)
                {
                    float fps = nFrameCount - _CurFrameCount;
                    float dt  = curTime - _LastFPSTime;
                    _FPS           = (dt == 0 ? 0 : fps / dt);
                    FPSLabel.text  = HobaText.Format("{0:.00}", _FPS);
                    _CurFrameCount = nFrameCount;

                    if (fps < 20)
                    {
                        FPSLabel.color = Color.red;
                    }
                    else if (fps < 25)
                    {
                        FPSLabel.color = Color.yellow;
                    }
                    else
                    {
                        FPSLabel.color = Color.green;
                    }
                }
                _LastFPSTime = curTime;
            }
        }
    }
Example #12
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);
        }
Example #13
0
 public static bool CanGetPixel32(Texture2D tex, int level, out string error)
 {
     error = "";
     try
     {
         tex.GetPixels32(level);
     }
     catch (UnityException e)
     {
         if (e.Message.StartsWith(HobaText.Format("Texture '{0}' is not readable", tex.name)))
         {
             error = e.Message;
             return(false);
         }
     }
     return(true);
 }
Example #14
0
    private static void ParseTranslateValue_Any(string fileName, string[] ignoreFields, string strLine, List <STranslateValue> translateValues)
    {
        translateValues.Clear();

        string shortFileName = System.IO.Path.GetFileNameWithoutExtension(fileName);

        int nStart = 0;
        int nEnd   = 0;

        do
        {
            nStart = IndexOfString(strLine, nStart);
            if (nStart < 0 || nStart + 1 == strLine.Length)
            {
                break;
            }

            nEnd = IndexOfString(strLine, nStart + 1);
            if (nEnd < 0)
            {
                break;
            }

            {
                if (IsIgnored(strLine, ignoreFields))
                {
                    nStart = nEnd + 1;
                    continue;
                }

                ++nStart;
                string val  = strLine.Substring(nStart, nEnd - nStart);
                string desc = HobaText.Format("{0}^{1}", shortFileName, val);

                if (!string.IsNullOrEmpty(val))
                {
                    translateValues.Add(new STranslateValue()
                    {
                        _desc = desc, _val = val
                    });
                }
            }

            nStart = nEnd + 1;
        } while (nStart < strLine.Length);
    }
Example #15
0
    public byte[] LoadFromAssetsPath(string name)
    {
        byte[] bytes = null;
        string path  = HobaText.Format(@"{0}/{1}", _DocPath, name);

        if (File.Exists(path))
        {
            bytes = Util.ReadFile(path);
        }

        if (bytes == null)
        {
            path  = HobaText.Format(@"{0}/{1}", _ResPath, name);
            bytes = Util.ReadFile(path);
        }
        return(bytes);
    }
Example #16
0
    //删除所有更新文件,返回到基础版本
    public bool CleanAllUpdatesReturnToBase(ELEMENT_VER baseVer)
    {
        this.ReleasePackages();     //释放pck环境

        LuaDLL.HOBA_DeleteFilesInDirectory(this.strLibDir);

        bool ret1 = LuaDLL.HOBA_HasFilesInDirectory(this.strLibDir);

        if (ret1)
        {
            this.LogString(HobaText.Format("[CleanAllUpdatesReturnToBase] Cannot Delete Files in {0}", this.strLibDir));
        }

        this.SetFirstVersion(baseVer, true);

        return(true);
    }
Example #17
0
 private static void WriteLogImp(string message)
 {
     lock (_LogFileLock)
     {
         try
         {
             using (StreamWriter sw = File.AppendText(_FilePath))
             {
                 sw.WriteLine(HobaText.Format("{0:G}: {1}", System.DateTime.Now, message));
                 sw.Close();
             }
         }
         catch (Exception e)
         {
         }
     }
 }
Example #18
0
    public void SetFileDownloadInfo(long finishedSize, long totalSize, float fKBS)
    {
        this.finishedSize = finishedSize;
        this.totalSize    = totalSize;
        this.fKBSpeed     = fKBS;

        SetTextSize();

        float value = totalSize > 0 ? (float)finishedSize / (float)totalSize : 0;

        pSlderProgress.value = value;
        pTextProgress.text   = HobaText.Format("{0:0} %", value * 98);
        if (!Frame_Progress.activeSelf)
        {
            Frame_Progress.SetActive(true);
        }
    }
Example #19
0
    private static AssetBundle SyncLoadAssetBundleInUpdate(string assetBundleName)
    {
        if (assetBundleName.Length == 0)
        {
            Debug.LogWarning("can not load bundle with empty name");
            return(null);
        }
        // Already loaded.
        LoadedAssetBundle bundle = null;

        if (_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle) && bundle != null)
        {
            return(bundle.Bundle);
        }

        //判断更新目录下的assetbundle是否存在
        string url;

        if (IsUpdateFileExist(assetBundleName))
        {
            url = HobaText.Format("{0}{1}", _UpdateAssetBundleURL, assetBundleName);
        }
        else
        {
            return(null);
        }

        string key = assetBundleName;
        var    loadedAssetBundle = AssetBundle.LoadFromFile(url);

        if (loadedAssetBundle == null)
        {
            var errMsg = HobaText.Format("failed to load AssetBundle {0}", key);
            if (!_DownloadingErrors.ContainsKey(key))
            {
                _DownloadingErrors.Add(key, errMsg);
            }
            HobaDebuger.LogWarning(errMsg);
            return(null);
        }

        var lab = new LoadedAssetBundle(loadedAssetBundle, key);

        _LoadedAssetBundles.Add(key, lab);
        return(loadedAssetBundle);
    }
Example #20
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);
        }
Example #21
0
    public bool LoadBank(string inBankFileName, bool localized = false)
    {
        if (_DicBankLoad.ContainsKey(inBankFileName.ToLower()))
        {
            return(true);
        }

        /*
         * string bankPath;
         *
         * if (!localized)
         *  bankPath = HobaText.Format("{0}/{1}/{2}/{3}", EntryPoint.Instance.ResPath, AkInitializer.GetBasePath(), AkBasePathGetter.GetPlatformName(), in_bankFileName);
         * else
         *  bankPath = HobaText.Format("{0}/{1}/{2}/{3}/{4}", EntryPoint.Instance.ResPath, AkInitializer.GetBasePath(), AkBasePathGetter.GetPlatformName(), AkInitializer.GetCurrentLanguage(), in_bankFileName);
         *
         * SBankEntry entry = new SBankEntry();
         * if (DoLoadBankFromImage(bankPath, entry))
         * {
         *  string name = localized ? HobaText.Format("{0}/{1}", AkInitializer.GetCurrentLanguage(), in_bankFileName.ToLower()) : in_bankFileName.ToLower();
         *  entry.gameObject = new GameObject(name);
         *  entry.gameObject.transform.parent = WwiseSoundMan.Instance.BanksLoaded.transform;
         *  _DicBankLoad.Add(in_bankFileName.ToLower(), entry);
         *  return true;
         * }
         *
         * HobaDebuger.LogWarningFormat("LoadBank Failed: {0}", bankPath);
         * return false;
         */


        CBankEntry entry = new CBankEntry();
        string     name  = localized ? HobaText.Format("{0}/{1}", AkInitializer.GetCurrentLanguage(), inBankFileName) : inBankFileName;
        AKRESULT   ret   = AkSoundEngine.LoadBank(name, AkSoundEngine.AK_DEFAULT_POOL_ID, out entry.BankID);

        if (ret == AKRESULT.AK_Success)
        {
            entry.GameObject = new GameObject(name);
            entry.GameObject.transform.parent = WwiseSoundMan.Instance.BanksLoaded.transform;
            _DicBankLoad.Add(inBankFileName.ToLower(), entry);
            return(true);
        }

        HobaDebuger.LogWarningFormat("LoadBank Failed: {0}", name);
        return(false);
    }
Example #22
0
 /// <summary>
 /// 加载给定路径的文件
 /// </summary>
 /// <param name="filePath">欲加载的文件路径</param>
 /// <returns>加载成功时返回打开的文件流;失败时返回 NULL </returns>
 public static Stream LoadFileRaw(String filePath)
 {
     try
     {
         string fullpath = HobaText.Format("{0}/{1}", EntryPoint.Instance.ResPath, filePath);
         //UnityEngine.Debug.Log("LoadFileRaw " + fullpath);
         FileStream fs = new FileStream(fullpath, FileMode.Open);
         return(fs as Stream);
     }
     catch (IOException)
     {
         return(null);
     }
     catch (System.IO.IsolatedStorage.IsolatedStorageException)
     {
         return(null);
     }
 }
Example #23
0
    public override void Resume()
    {
        if (_IsInited)
        {
            if (Util.GetNetworkStatus() == NetworkReachability.NotReachable)
            {
                return;
            }

            KakaoUtil.Resume((resultCode) =>
            {
                if (resultCode == KGResultCode.Success)
                {
                    LogResult(_KakaoPrefix, "Resume Success", resultCode.ToString());
                }
                else
                {
                    if (resultCode == KGResultCode.AuthFailure || resultCode == KGResultCode.IdpAuthFailure)
                    {
                        LogResult(_KakaoPrefix, "Resume Auth Failed, Do LogoutDirectly", resultCode.ToString());
                        _ResumeCount = 0;
                        LogoutDirectly();
                    }
                    else
                    {
                        LogResult(_KakaoPrefix, string.Format("Resume Failed, CurCount:{0}", _ResumeCount.ToString()), resultCode.ToString());
                        //OSUtility.ShowAlertView("Resume Failed", HobaText.Format("result code:{0}, do logout:{1}", resultCode.ToString(), _ResumeCount >= MAX_RESUME_TIME));
                        if (_ResumeCount < MAX_RESUME_TIME)
                        {
                            this.Resume();
                            _ResumeCount++;
                        }
                        else
                        {
                            LogResult(_KakaoPrefix, HobaText.Format("Resume Retry Over MaxTime:{0}, Do LogoutDirectly", MAX_RESUME_TIME), resultCode.ToString());
                            _ResumeCount = 0;
                            LogoutDirectly();
                        }
                    }
                }
                // PlatformControl.OnPlatformResume(isSuccess);
            });
        }
    }
Example #24
0
 //现在更新字符串配置需要根据语言来切换
 private void ReadUpdateStringXmlFromResources(string strLanguage)
 {
     try
     {
         //read UpdateStringConfig.xml
         //_UpdateStringConfigParams.DefaultValue();
         var       ppdateConfigFileName        = HobaText.Format("UpdateStringConfig{0}", strLanguage);
         TextAsset updateStringConfigTextAsset = (TextAsset)Resources.Load(ppdateConfigFileName, typeof(TextAsset));
         if (updateStringConfigTextAsset != null)
         {
             _UpdateStringConfigParams.ParseFromXmlString(updateStringConfigTextAsset.text);
             Resources.UnloadAsset(updateStringConfigTextAsset);
         }
     }
     catch (Exception e)
     {
         HobaDebuger.LogErrorFormat("Failed to Parse UpdateStringXml:{0}", e);
     }
 }
Example #25
0
 public static String GetLog()
 {
     lock (m_logs)
     {
         var strBuilder = HobaText.GetStringBuilder();
         strBuilder.AppendLine("=============IO Log=============");
         Double totalTime = 0;
         for (int i = 0; i < m_logs.Count; ++i)
         {
             var log = m_logs[i];
             totalTime += log.time;
             strBuilder.AppendFormat("{0} @ {1} ms", log.file, log.time * 1000);
             strBuilder.AppendLine();
         }
         strBuilder.AppendFormat("total time: {0} ms", totalTime * 1000);
         strBuilder.AppendLine();
         return(strBuilder.ToString());
     }
 }
Example #26
0
    static string GetErrorFunc(int skip)
    {
        StackFrame sf   = null;
        string     file = string.Empty;
        StackTrace st   = new StackTrace(skip, true);
        int        pos  = 0;

        do
        {
            sf   = st.GetFrame(pos++);
            file = sf.GetFileName();
        } while (!file.Contains("Wrap"));

        int    index1    = file.LastIndexOf('\\');
        int    index2    = file.LastIndexOf("Wrap");
        string className = file.Substring(index1 + 1, index2 - index1 - 1);

        return(HobaText.Format("{0}.{1}", className, sf.GetMethod().Name));
    }
Example #27
0
 private void SafeInitSFX()
 {
     if (_effectAudioSourceList.Count == 0)
     {
         for (int i = 0; i < MaxEffectChannel; ++i)
         {
             GameObject go = new GameObject(HobaText.Format("effect{0}", i));
             go.transform.parent = transform;
             AudioSource           src = go.AddComponent <AudioSource>();
             EffectAudioSourceItem m   = new EffectAudioSourceItem();
             m.id                      = i;
             m.audioSource             = src;
             m.priority                = 0;
             m.audioSource.minDistance = 10;
             m.audioSource.maxDistance = 30;
             _effectAudioSourceList.Add(m);
         }
     }
 }
Example #28
0
    //查找 keword 后的 第一个 "XXX" 匹配
    private static void ParseTranslateValue_Keyword(string fileName, string[] ignoreFields, string strLine, string keyword, out string desc, out string val)
    {
        desc = "";
        val  = "";

        int nNameStr = strLine.IndexOf(keyword + " =");

        if (nNameStr < 0)
        {
            return;
        }

        //Name = 前面不能是其他单词的一部分
        if (nNameStr > 0)
        {
            if (Char.IsLetter(strLine, nNameStr - 1) || Char.IsDigit(strLine, nNameStr - 1))
            {
                return;
            }
        }

        string shortFileName = System.IO.Path.GetFileNameWithoutExtension(fileName);
        int    nStart        = IndexOfString(strLine, nNameStr);

        if (nStart < 0)
        {
            return;
        }

        int nEnd = IndexOfString(strLine, nStart + 1);

        if (nStart >= 0 && nEnd >= 0 && nEnd > nStart)
        {
            if (IsIgnored(strLine, ignoreFields))
            {
                return;
            }

            ++nStart;
            val  = strLine.Substring(nStart, nEnd - nStart);
            desc = HobaText.Format("{0}^({1})^{2}", shortFileName, keyword, val);
        }
    }
Example #29
0
    private void LoadPathIDData()
    {
        if (Instance == null)
        {
            throw new Exception("Failed to Initialize");
        }

        var filePath      = HobaText.Format("{0}{1}", IsUpdateFileExist("PATHID.dat") ? _UpdateAssetBundleURL : _GameResBasePath, "PATHID.dat");
        var pathidContent = Util.ReadFile(filePath);

        if (pathidContent != null && pathidContent.Length > 0)
        {
            using (StreamReader sr = new StreamReader(new MemoryStream(pathidContent)))
            {
                var strLine = sr.ReadLine();
                while (strLine != null)
                {
                    string[] assetTemp = strLine.Split(',');
                    if (assetTemp.Length >= 2 && !_AssetPath2BundleMap.ContainsKey(assetTemp[1]))
                    {
                        _AssetPath2BundleMap.Add(assetTemp[1], assetTemp[0]);
                    }

                    strLine = sr.ReadLine();
                }
                ;

                sr.Close();
            }
        }

        var lines = File.ReadAllLines(filePath);

        foreach (var v in lines)
        {
            string[] assetTemp = v.Split(',');
            if (assetTemp.Length >= 2 && !_AssetPath2BundleMap.ContainsKey(assetTemp[1]))
            {
                _AssetPath2BundleMap.Add(assetTemp[1], assetTemp[0]);
            }
        }
    }
Example #30
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;
    }