public static string DecodeZZZ(byte[] bytes) { string res = ""; try { if (Encoding.UTF8.GetString(bytes, 0, 3) == "zzz") { List <byte> lst = new List <byte> (); for (int i = 3, index = 1; i < bytes.Length; i++, index++) { int r = (int)bytes [i]; int n = index + (int)Mathf.Floor(1.0f * index / _zzz_key_len); n = (n - 1) % _zzz_key_len + 1; int key = (int)_zzz_key_bytes [n - 1]; // XLAFInnerLog.Debug ("before:", n, r, key); r = r - key - 88; r = (r + 256) % 256; lst.Add((byte)r); } res = Encoding.UTF8.GetString(lst.ToArray()); } } catch (Exception e) { XLAFInnerLog.Error(e.ToString()); } return(res); }
/// <summary> /// Changes the size. /// </summary> /// <param name="t">gameobject.</param> /// <param name="width">Width.</param> /// <param name="height">Height.</param> public static void ChangeSize(GameObject t, float?width = null, float?height = null) { RectTransform rect = t.GetComponent <RectTransform> (); if (rect == null) { XLAFInnerLog.Error("RectTransform is null"); } ChangeSize(rect, width, height); }
/// <summary> /// Adds the setting. /// </summary> /// <param name="settingsName">Settings name.</param> /// <param name="filePathName">File path name.</param> /// <param name="defaultFilePathName">Default file path name.</param> public static void AddSetting(string settingsName, string filePathName, string defaultFilePathName) { if (DATA.ContainsKey(settingsName)) { XLAFInnerLog.Error(settingsName + " already exist!"); return; } DATA.Add(settingsName, new SettingsData(filePathName, defaultFilePathName)); }
/// <summary> /// Changes the position. /// </summary> /// <param name="t">button.</param> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> public static void ChangePos(Button t, float?x = null, float?y = null) { RectTransform rect = t.image.rectTransform; if (rect == null) { XLAFInnerLog.Error("RectTransform is null"); } ChangePos(rect, x, y); }
private static bool _CheckSettingsName(string settingsName, out SettingsData sd) { if (DATA.TryGetValue(settingsName, out sd)) { return(true); } else { XLAFInnerLog.Error(settingsName + " is not added, please call AddSetting before!"); return(false); } }
/// <summary> /// Gets the string from current language config file with placeholder.<para></para> /// e.g. <code>"congratulations! you have got {0} points! rank No. {1}"</code> /// </summary> /// <returns>The string.</returns> /// <param name="stringKeyName">String key name.</param> /// <param name="args">Arguments.</param> public static string GetString(string stringKeyName, params object[] args) { string ret = ""; try { ret = LanguageConfigs [stringKeyName].Value; ret = string.Format(ret, args); } catch (Exception e) { XLAFInnerLog.Error("error in MgrMultiLanguage|GetString:", e); } return(ret); }
public static void Set(string settingsName, string key, object value, bool autoSave = true) { SettingsData sd; if (DATA.TryGetValue(settingsName, out sd)) { sd.Set(key, value, autoSave); } else { XLAFInnerLog.Error(settingsName + " is not added, please call AddSetting before!"); return; } }
/// <summary> /// Gets the child form a transform. /// </summary> /// <returns>The child.</returns> /// <param name="parent">Transform parent.</param> /// <param name="childName">Child name.</param> public static Transform GetChild(Transform parent, string childName) { Transform t = parent.Find(childName); if (t != null) { return(t); } else { XLAFInnerLog.Error("error! find child null"); return(null); } }
/// <summary> /// Gets the child form a transform. /// </summary> /// <returns>The child.</returns> /// <param name="parent">Transform parent.</param> /// <param name="childName">Child name.</param> /// <typeparam name="T">The type of the child.</typeparam> public static T GetChild <T> (Transform parent, string childName) { Transform t = parent.Find(childName); if (t != null) { return(t.GetComponent <T> ()); } else { XLAFInnerLog.Error("error! find child null"); return(default(T)); } }
/// <summary> /// Gets the asset bundle path. /// </summary> /// <returns>The asset bundle path.</returns> /// <param name="sceneName">Scene name.</param> public static string GetAssetBundlePath(string sceneName) { if (jsonData == null) { XLAFInnerLog.Error("please call LoadAssetBundleConfig(path) first"); return(""); } string v = jsonData [sceneName].Value; if (string.IsNullOrEmpty(v)) { return(""); } if (!v.StartsWith("/")) { v = "/" + v; } return(v); }
/// <summary> /// AES decoder /// </summary> /// <param name="str">string you want decode with Base64.</param> /// <returns>string </returns> public static string DecodeAES(string base64Str) { try { byte[] cipherText = Convert.FromBase64String(base64Str); SymmetricAlgorithm des = Rijndael.Create(); des.Key = Encoding.UTF8.GetBytes(_aes_key); des.IV = _aes_IV; byte[] decryptBytes = new byte[cipherText.Length]; using (MemoryStream ms = new MemoryStream(cipherText)) { using (CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read)) { cs.Read(decryptBytes, 0, decryptBytes.Length); cs.Close(); ms.Close(); } } return(Encoding.UTF8.GetString(decryptBytes).Replace("\0", "")); ///remove \0 } catch (Exception e) { XLAFInnerLog.Error(e.ToString()); } return(""); }
/// <summary> /// AES encoder /// </summary> /// <param name="str">string you want to encode.</param> /// <returns>encode string with Base64.</returns> public static string EncodeAES(string str) { try { SymmetricAlgorithm des = Rijndael.Create(); byte[] inputBytes = Encoding.UTF8.GetBytes(str); des.Key = Encoding.UTF8.GetBytes(_aes_key); des.IV = _aes_IV; byte[] cipherBytes = null; using (MemoryStream ms = new MemoryStream()) { using (CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write)) { cs.Write(inputBytes, 0, inputBytes.Length); cs.FlushFinalBlock(); cipherBytes = ms.ToArray(); //get byte array cs.Close(); ms.Close(); } } return(Convert.ToBase64String(cipherBytes)); } catch (Exception e) { XLAFInnerLog.Error(e.ToString()); } return(""); }
/// <summary> /// Dispatch the XLAF_Event. /// </summary> /// <param name="e">XLAF_Event.</param> public static void Dispatch(XLAF_Event e) { if (e.name == null) { XLAFInnerLog.Error("Event is not right", e); return; } List <XLAF_Event> list; if (!listeners.TryGetValue(e.name, out list)) { XLAFInnerLog.Warning("No callback functions names ", e.name); return; } for (int i = 0; i < list.Count; i++) { if (list [i].action != null) { list [i].data = e.data; list [i].action(list [i]); } } }