Auxiliary.cs 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453
  1. using LitJson;
  2. using ScottGarland;
  3. using DragonBones;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using UnityEngine.Events;
  7. using UnityEngine.Advertisements;
  8. using System;
  9. using System.IO;
  10. using System.Xml;
  11. using System.Linq;
  12. using System.Net.Mail;
  13. using System.Net;
  14. using System.Text;
  15. using System.Collections;
  16. using System.Diagnostics;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Security.Cryptography;
  20. using System.Runtime.Serialization.Formatters.Binary;
  21. using System.Security;
  22. using System.Text.RegularExpressions;
  23. using System.Security.Cryptography.Xml;
  24. using Sfs2X.Entities.Data;
  25. using Sfs2X.Requests;
  26. using Debug = UnityEngine.Debug;
  27. using Random = UnityEngine.Random;
  28. using Transform = UnityEngine.Transform;
  29. public enum Unit
  30. {
  31. Second
  32. }
  33. public class Amount
  34. {
  35. public static double 百 = 100;
  36. public static double 千 = 1000;
  37. public static double 万 = 10000;
  38. public static double 十万 = 100000;
  39. public static double 百万 = 1000000;
  40. public static double 千万 = 10000000;
  41. public static double 亿 = 100000000;
  42. public static double 十亿 = 1000000000;
  43. public static double 千亿 = 100000000000;
  44. public static double 兆 = 1000000000000;
  45. public static double 千兆 = 1000000000000000;
  46. public static double 京 = 10000000000000000;
  47. public static double 千京 = 10000000000000000000;
  48. public static BigInteger 垓 = new BigInteger("100000000000000000000");
  49. public static BigInteger 千垓 = new BigInteger("100000000000000000000000");
  50. }
  51. public class Auxiliary : Regist
  52. {
  53. #region Config
  54. public string String1;
  55. public string String2;
  56. public TextAsset DragonboneSke;
  57. public List<Sprite> Sprites;
  58. public Sprite Sprite;
  59. public TextAsset TextAsset;
  60. public Texture2D Texture;
  61. public Texture2D Texture1;
  62. public Texture2D Texture2;
  63. public AnimationClip AnimationClip;
  64. public Font Font;
  65. public GameObject Go;
  66. public List<GameObject> GoList;
  67. public List<SpriteRenderer> SrList;
  68. public static bool AnyKeyUp;
  69. public static bool AnyKeyDown;
  70. public static Auxiliary Instance;
  71. public static MD5 MD5
  72. {
  73. get
  74. {
  75. if (_MD5 == null)
  76. {
  77. _MD5 = new MD5CryptoServiceProvider();
  78. }
  79. return _MD5;
  80. }
  81. set { _MD5 = value; }
  82. }
  83. public static DESCryptoServiceProvider Des
  84. {
  85. get
  86. {
  87. if (_Des == null)
  88. {
  89. _Des = new DESCryptoServiceProvider();
  90. _Des.IV = Encoding.UTF8.GetBytes("19283740");
  91. _Des.Key = Encoding.UTF8.GetBytes("93287123");
  92. }
  93. return _Des;
  94. }
  95. set { _Des = value; }
  96. }
  97. private static MD5 _MD5;
  98. private static DESCryptoServiceProvider _Des;
  99. #endregion
  100. public override bool InitAtOnce()
  101. {
  102. if (base.InitAtOnce())
  103. {
  104. return true;
  105. }
  106. enabled = true;
  107. return false;
  108. }
  109. private void Awake()
  110. {
  111. Instance = this;
  112. }
  113. private void Update()
  114. {
  115. #region 调试
  116. //if (Input.GetKeyDown(KeyCode.Escape))
  117. //{
  118. // SFSManager.GardenSmartFox.SmartFox.Disconnect();
  119. // RobotManager.DeactivateAllRobots(false);
  120. //}
  121. //if (Input.GetKeyDown(KeyCode.Space))
  122. //{
  123. // foreach (var skill in Manager.UsingSkillList)
  124. // {
  125. // skill.UseTimer = 0;
  126. // }
  127. // foreach (var skill in Manager.CoolSkillList)
  128. // {
  129. // skill.CoolTimer = 0;
  130. // }
  131. // HttpManager.GetTargetConfig
  132. // (
  133. // "1801203341708362776",
  134. // data =>
  135. // {
  136. // VisitManager.VisiteeSerialNumber = "1801169491424370642";
  137. // VisitManager.SavePulledConfig(data);
  138. // }
  139. // );
  140. // PlayerPrefManager.SaveBool(PlayerPrefManager.INTERACT_CONFIG, false);
  141. // Debug.Log(ResourceManager.Get<Canvas>(CanvasLabel.Canvas).scaleFactor);
  142. // RectTransform rectTransform = ResourceManager.Get<RectTransform>(CanvasLabel.P_ScreenShotRect);
  143. // Vector2 screenPosition = RectTransformUtility.WorldToScreenPoint(null, rectTransform.position);
  144. // Debug.Log(screenPosition);
  145. // Debug.Log(ConfigManager.ConfigRootNode.OuterXml);
  146. // DebugManager.ResetGardenLevel(22);
  147. // DebugManager.ResetVisitTutorial();
  148. // HttpManager.GetThanksGiftInfo(RechargeGiftManager.Init, () => Bubble.Show(null, Language.GetStr(LanguageLabel.UI__GetThanksGiftInfoFailed)));
  149. //}
  150. //if (Input.GetKeyDown(KeyCode.A))
  151. //{
  152. // XmlDocument document = new XmlDocument();
  153. // Debug.Log(ConfigManager.ConfigDocument.InnerXml);
  154. // Debug.Log(ConfigManager.ConfigDocument.OuterXml);
  155. // document.LoadXml(ConfigManager.ConfigDocument.InnerXml);
  156. // XmlNode rootNode = document.SelectSingleNode(PlayerConfigLabel.RootNode);
  157. // rootNode.RemoveChild(rootNode.SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorial));
  158. // rootNode.RemoveChild(rootNode.SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorialIndex));
  159. // rootNode.SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 15.ToString();
  160. // rootNode.SelectSingleNode(PlayerConfigLabel.ID).Attributes[0].Value = "jrjL84";
  161. // rootNode.SelectSingleNode(PlayerConfigLabel.SerialNumber).Attributes[0].Value = "1708014471457405866";
  162. // URLRequestData urlData = new URLRequestData();
  163. // urlData.Add("u", "1708014471457405866");
  164. // urlData.Add("v", "1");
  165. // urlData.Add("l", rootNode.OuterXml);
  166. // URLRequest.CreateStrURLRequest(false, HttpManager.SaveURL, urlData, data => { Debug.Log(data); }, URLRequest.Method.POST);
  167. // StringFilter.ContainSensitiveWord("真");
  168. // TutorialManager.findMissingMinigameTutorial = true;
  169. // DebugManager.ResetGardenLevel(30);
  170. // Manager.Diamond = 1000;
  171. // PlayerManager.Player.ChangeClose(BodyPart.Eye, "眼睛3");
  172. // FashionShowEditPage.DisplayPlayer.ChangeClose(BodyPart.Eye, "眼睛3");
  173. //}
  174. //if (Input.GetKeyDown(KeyCode.S))
  175. //{
  176. // Manager.CoinPerson = 10000050000;
  177. // DebugManager.ResetGardenLevel(49);
  178. // PlayerManager.Player.ChangeClose(BodyPart.Top, "上衣14");
  179. // PlayerManager.Player.DisplayInScene();
  180. // Manager.Coin = 0;
  181. // Manager.Diamond = 0;
  182. //}
  183. //if (Input.GetKeyDown(KeyCode.D))
  184. //{
  185. // Manager.Coin = 100000;
  186. // Manager.Diamond = 1000;
  187. //}
  188. //if (Input.GetKeyDown(KeyCode.Z))
  189. //{
  190. // Manager.MinigameCDTimer = 0;
  191. //}
  192. //if (Input.GetKeyDown(KeyCode.X))
  193. //{
  194. // MiniGameManager.GameTimer = 45;
  195. //}
  196. //if (Input.GetKeyDown(KeyCode.C))
  197. //{
  198. // DebugManager.ResetAbilityAnim();
  199. //}
  200. //if (Input.GetKeyDown(KeyCode.V))
  201. //{
  202. // AccountData accountData = new AccountData("测试名字", "1710065808151506837", DateTime.Now.ToString());
  203. // MessagePanel.OpenPanel(accountData);
  204. //}
  205. //if (Input.GetKeyDown(KeyCode.B))
  206. //{
  207. // ManaPlayer.Player.PlayAnim("newAnimation3");
  208. // ManaPlayer.Player.Flip(PlayerDirection.Left);
  209. // foreach (var VARIABLE in ManaPlayer.CloseUnitDic)
  210. // {
  211. // VARIABLE.Value.Unlock();
  212. // }
  213. //}
  214. //if (Input.GetKeyDown(KeyCode.M))
  215. //{
  216. // ManaReso.Get(PrefabLabel.G_Flower).SetActive(false);
  217. // Debug.Log(ManaGarden.Slot);
  218. //}
  219. //if (Input.GetKeyDown(KeyCode.N))
  220. //{
  221. // ManaCenter.Coin = 0;
  222. // ManaCenter.Diamond = 0;
  223. // foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
  224. // {
  225. // VARIABLE.Value.Unlock = true;
  226. // }
  227. // foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
  228. // {
  229. // VARIABLE.Value.Unlock = false;
  230. // }
  231. // ManaGarden.FlowerInfoDic.First().Value.Unlock = true;
  232. //}
  233. //if (Input.GetKeyDown(KeyCode.P))
  234. //{
  235. // ManaData.Level += 20;
  236. //}
  237. //if (Input.GetKeyDown(KeyCode.O))
  238. //{
  239. // for (int i = 0; i < ManaCenter.CoolList.Count; i++)
  240. // {
  241. // ManaCenter.CoolList[i].CoolTimer = 0;
  242. // }
  243. //}
  244. //if (Input.GetKeyDown(KeyCode.I))
  245. //{
  246. // ManaCenter.Coin += 1000;
  247. // ManaCenter.Diamond += 1000;
  248. //}
  249. //if (Input.GetKeyDown(KeyCode.U))
  250. //{
  251. // Data.SavePlayerConfig();
  252. // Data.SaveXml();
  253. //}
  254. //if (Input.GetKeyDown(KeyCode.Y))
  255. //{
  256. // Data.ResetPlayerConfig();
  257. // Data.SaveXml();
  258. //}
  259. //if (Input.GetKeyDown(KeyCode.T))
  260. //{
  261. // ManaData.Pause = !ManaData.Pause;
  262. //}
  263. #endregion
  264. #region 输入检测
  265. if (Input.GetKeyDown(KeyCode.Escape))
  266. {
  267. MiniGameManager.Pause = true;
  268. Bubble.Show(null, Language.GetStr(LanguageLabel.Common__QuitGame), null, null, Application.Quit, () => { MiniGameManager.Pause = false; });
  269. }
  270. if (AnyKeyUp)
  271. {
  272. if (Input.anyKey == false)
  273. {
  274. AnyKeyUp = false;
  275. }
  276. }
  277. if (Input.anyKeyDown)
  278. {
  279. AnyKeyDown = true;
  280. }
  281. if (AnyKeyDown)
  282. {
  283. if (Input.anyKey == false)
  284. {
  285. AnyKeyUp = true;
  286. AnyKeyDown = false;
  287. }
  288. }
  289. #endregion
  290. }
  291. private static void ResetAllCd()
  292. {
  293. for (int i = 0; i < Manager.CoolSkillList.Count; i++)
  294. {
  295. Manager.CoolSkillList[i].CoolTimer = 0;
  296. }
  297. }
  298. public static byte[] GetMD5(object obj)
  299. {
  300. MemoryStream memoryStream = new MemoryStream();
  301. BinaryFormatter binaryFormatter = new BinaryFormatter();
  302. binaryFormatter.Serialize(memoryStream, obj);
  303. byte[] bytes = memoryStream.GetBuffer();
  304. memoryStream.Dispose();
  305. return MD5.ComputeHash(bytes);
  306. }
  307. public static void EncryptXml(XmlDocument doc)
  308. {
  309. EncryptedXml encryptedXml = new EncryptedXml();
  310. XmlElement xmlElement = doc.DocumentElement;
  311. byte[] bytes = encryptedXml.EncryptData(xmlElement, Des, false);
  312. EncryptedData encryptedData = new EncryptedData();
  313. encryptedData.Type = EncryptedXml.XmlEncElementUrl;
  314. encryptedData.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncDESUrl);
  315. encryptedData.CipherData.CipherValue = bytes;
  316. EncryptedXml.ReplaceElement(xmlElement, encryptedData, false);
  317. }
  318. public static void DecryptXml(XmlDocument doc)
  319. {
  320. EncryptedXml encryptedXml = new EncryptedXml();
  321. XmlElement encryptXmlElement = (XmlElement)doc.GetElementsByTagName("EncryptedData")[0];
  322. EncryptedData encryptedData = new EncryptedData();
  323. encryptedData.LoadXml(encryptXmlElement);
  324. byte[] bytes = encryptedXml.DecryptData(encryptedData, Des);
  325. encryptedXml.ReplaceData(encryptXmlElement, bytes);
  326. }
  327. public static byte[] Encrypt(string str)
  328. {
  329. byte[] bytes = Encoding.UTF8.GetBytes(str);
  330. byte[] encryptBytes = Des.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length);
  331. return encryptBytes;
  332. }
  333. public static byte[] ToBytes(string str)
  334. {
  335. string[] strings = str.Split(' ');
  336. byte[] bytes = new byte[strings.Length];
  337. for (int i = 0; i < bytes.Length; i++)
  338. {
  339. bytes[i] = byte.Parse(strings[i]);
  340. }
  341. return bytes;
  342. }
  343. public static string Decrypt(string str)
  344. {
  345. byte[] encryptBytes = ToBytes(str);
  346. byte[] decryptBytes = Des.CreateDecryptor().TransformFinalBlock(encryptBytes, 0, encryptBytes.Length);
  347. return Encoding.UTF8.GetString(decryptBytes);
  348. }
  349. public static string ToString(byte[] bytes)
  350. {
  351. StringBuilder strB = new StringBuilder();
  352. for (int i = 0; i < bytes.Length; i++)
  353. {
  354. if (i == bytes.Length - 1)
  355. {
  356. strB.Append(bytes[i]);
  357. }
  358. else
  359. {
  360. strB.Append(bytes[i] + " ");
  361. }
  362. }
  363. return strB.ToString();
  364. }
  365. public static void CompileDic(Transform tra, Dictionary<string, Transform> dic, bool enableIgnore = true)
  366. {
  367. Transform[] transforms = tra.GetComponentsInChildren<Transform>(true);
  368. for (int i = 0; i < transforms.Length; i++)
  369. {
  370. if (enableIgnore)
  371. {
  372. if (transforms[i].GetComponent<IgnoreIndexing>())
  373. {
  374. continue;
  375. }
  376. }
  377. if (dic.ContainsKey(transforms[i].name))
  378. {
  379. throw new Exception(transforms[i].name);
  380. }
  381. else
  382. {
  383. dic.Add(transforms[i].name, transforms[i]);
  384. }
  385. }
  386. }
  387. public static string GetUnit(int value, Unit unit)
  388. {
  389. if (unit == Unit.Second)
  390. {
  391. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  392. {
  393. if (value == 0 || value == 1)
  394. {
  395. return " Second";
  396. }
  397. else
  398. {
  399. return " Seconds";
  400. }
  401. }
  402. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  403. {
  404. return "秒";
  405. }
  406. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  407. {
  408. return "秒";
  409. }
  410. else
  411. {
  412. throw new Exception();
  413. }
  414. }
  415. else
  416. {
  417. throw new Exception();
  418. }
  419. }
  420. public static string GetStreamPath()
  421. {
  422. if (Application.isEditor)
  423. {
  424. return "file://" + Application.streamingAssetsPath;
  425. }
  426. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  427. {
  428. return "file://" + Application.streamingAssetsPath;
  429. }
  430. else if (Application.isMobilePlatform)
  431. {
  432. return Application.streamingAssetsPath;
  433. }
  434. else
  435. {
  436. throw new Exception();
  437. }
  438. }
  439. public Coroutine DelayCall(UnityAction function, int frame)
  440. {
  441. return StartCoroutine(IDelayCall(function, frame));
  442. }
  443. public Coroutine DelayCall(UnityAction function, float time)
  444. {
  445. return StartCoroutine(IDelayCall(function, time));
  446. }
  447. public static IEnumerator IDelayCall(UnityAction function, int frame)
  448. {
  449. int count = 0;
  450. while (count < frame)
  451. {
  452. count++;
  453. yield return null;
  454. }
  455. function.Invoke();
  456. }
  457. public static IEnumerator IDelayCall(UnityAction function, float time)
  458. {
  459. yield return new WaitForSeconds(time);
  460. function.Invoke();
  461. }
  462. public static string FmlParse1(string str)
  463. {
  464. int index = 0;
  465. int openIndex = 0;
  466. bool flag = false;
  467. bool group = false;
  468. for (int i = 0; i < str.Length; i++)
  469. {
  470. if (group)
  471. {
  472. if (str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/')
  473. {
  474. str = str.Replace(openIndex, i - 1, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i - 1)));
  475. i = 0;
  476. group = false;
  477. }
  478. else if (i == str.Length - 1)
  479. {
  480. str = str.Replace(openIndex, i, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i)));
  481. break;
  482. }
  483. }
  484. else
  485. {
  486. if (str[i] == '+' || str[i] == '-')
  487. {
  488. flag = true;
  489. openIndex = i + 1;
  490. }
  491. else if (str[i] == '*' || str[i] == '/')
  492. {
  493. index = i;
  494. group = true;
  495. if (!flag)
  496. {
  497. openIndex = 0;
  498. }
  499. }
  500. }
  501. }
  502. group = false;
  503. for (int i = 0; i < str.Length; i++)
  504. {
  505. if (group)
  506. {
  507. if (str[i] == '+' || str[i] == '-')
  508. {
  509. str = str.Replace(0, i - 1, FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i - 1)));
  510. i = -1;
  511. group = false;
  512. }
  513. else if (i == str.Length - 1)
  514. {
  515. return FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i));
  516. }
  517. }
  518. else
  519. {
  520. if (str[i] == '+' || str[i] == '-')
  521. {
  522. index = i;
  523. group = true;
  524. }
  525. }
  526. }
  527. return str;
  528. }
  529. public static string FmlParse2(char op, string str1, string str2)
  530. {
  531. double var1 = double.Parse(str1);
  532. double var2 = double.Parse(str2);
  533. if (op == '+')
  534. {
  535. return (var1 + var2).ToString("F7");
  536. }
  537. else if (op == '-')
  538. {
  539. return (var1 - var2).ToString("F7");
  540. }
  541. else if (op == '*')
  542. {
  543. return (var1 * var2).ToString("F7");
  544. }
  545. else if (op == '/')
  546. {
  547. return (var1 / var2).ToString("F7");
  548. }
  549. else
  550. {
  551. throw new Exception(op.ToString());
  552. }
  553. }
  554. public static double FmlParse(string str, params string[] strings)
  555. {
  556. for (int i = 0; i < strings.Length; i += 2)
  557. {
  558. if (str.Contains(strings[i]))
  559. {
  560. str = str.Replace(strings[i], strings[i + 1]);
  561. }
  562. else
  563. {
  564. //Debug.Log("No such var " + strings[i + 1]);
  565. }
  566. }
  567. int openIndex = 0;
  568. for (int i = 0; i < str.Length; i++)
  569. {
  570. if (str[i] == '(')
  571. {
  572. openIndex = i;
  573. }
  574. else if (str[i] == ')')
  575. {
  576. str = str.Replace(openIndex, i, FmlParse1(str.Between(openIndex + 1, i - 1)));
  577. i = -1;
  578. }
  579. }
  580. return double.Parse(FmlParse1(str));
  581. }
  582. public static string OmitNumberStr(int accuray, string str)
  583. {
  584. int index = str.IndexOf('.');
  585. if (index == -1)
  586. {
  587. return str;
  588. }
  589. if (accuray == 0)
  590. {
  591. return str.Substring(0, index);
  592. }
  593. else
  594. {
  595. for (int i = index + 1; i < index + accuray + 1; i++)
  596. {
  597. if (str[i] != '0')
  598. {
  599. return str.Substring(0, index + accuray + 1);
  600. }
  601. }
  602. return str.Substring(0, index);
  603. }
  604. }
  605. public static double ShrinkNumber(double value, int accuracy = 1)
  606. {
  607. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  608. {
  609. if (value < Amount.千)
  610. {
  611. return value;
  612. }
  613. else if (value < Amount.百万)
  614. {
  615. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  616. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千;
  617. }
  618. else if (value < Amount.十亿)
  619. {
  620. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  621. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.百万;
  622. }
  623. else if (value < Amount.兆)
  624. {
  625. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  626. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.十亿;
  627. }
  628. else if (value < Amount.千兆)
  629. {
  630. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  631. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
  632. }
  633. else
  634. {
  635. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  636. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千兆;
  637. }
  638. }
  639. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified || LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  640. {
  641. if (value < Amount.万)
  642. {
  643. return value;
  644. }
  645. else if (value < Amount.千万)
  646. {
  647. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  648. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.万;
  649. }
  650. else if (value < Amount.亿)
  651. {
  652. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  653. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千万;
  654. }
  655. else if (value < Amount.千亿)
  656. {
  657. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  658. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.亿;
  659. }
  660. else if (value < Amount.兆)
  661. {
  662. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  663. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千亿;
  664. }
  665. else if (value < Amount.千兆)
  666. {
  667. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  668. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
  669. }
  670. else if (value < Amount.京)
  671. {
  672. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  673. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千兆;
  674. }
  675. else if (value < Amount.千京)
  676. {
  677. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  678. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.京;
  679. }
  680. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  681. {
  682. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  683. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千京;
  684. }
  685. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  686. {
  687. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  688. return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10;
  689. }
  690. else
  691. {
  692. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  693. return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10000;
  694. }
  695. }
  696. else
  697. {
  698. throw new Exception();
  699. }
  700. }
  701. public static string ShrinkBigNumberStr(double value, int accuracy = 1)
  702. {
  703. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  704. {
  705. if (value < Amount.千)
  706. {
  707. return value.ToString("0");
  708. }
  709. else if (value < Amount.百万)
  710. {
  711. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  712. return OmitNumberStr(accuracy, str) + "K";
  713. }
  714. else if (value < Amount.十亿)
  715. {
  716. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  717. return OmitNumberStr(accuracy, str) + "M";
  718. }
  719. else if (value < Amount.兆)
  720. {
  721. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  722. return OmitNumberStr(accuracy, str) + "B";
  723. }
  724. else if (value < Amount.千兆)
  725. {
  726. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  727. return OmitNumberStr(accuracy, str) + "T";
  728. }
  729. else
  730. {
  731. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  732. return OmitNumberStr(accuracy, str) + "T";
  733. }
  734. }
  735. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  736. {
  737. if (value < Amount.万)
  738. {
  739. return value.ToString("0");
  740. }
  741. else if (value < Amount.千万)
  742. {
  743. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  744. return OmitNumberStr(accuracy, str) + "万";
  745. }
  746. else if (value < Amount.亿)
  747. {
  748. string str = (value/Amount.千万).ToString("F" + (accuracy + 1));
  749. return OmitNumberStr(accuracy, str) + "千万";
  750. }
  751. else if (value < Amount.千亿)
  752. {
  753. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  754. return OmitNumberStr(accuracy, str) + "亿";
  755. }
  756. else if (value < Amount.兆)
  757. {
  758. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  759. return OmitNumberStr(accuracy, str) + "千亿";
  760. }
  761. else if (value < Amount.千兆)
  762. {
  763. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  764. return OmitNumberStr(accuracy, str) + "兆";
  765. }
  766. else if (value < Amount.京)
  767. {
  768. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  769. return OmitNumberStr(accuracy, str) + "千兆";
  770. }
  771. else if (value < Amount.千京)
  772. {
  773. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  774. return OmitNumberStr(accuracy, str) + "京";
  775. }
  776. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  777. {
  778. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  779. return OmitNumberStr(accuracy, str) + "千京";
  780. }
  781. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  782. {
  783. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  784. return OmitNumberStr(0, str) + "垓";
  785. }
  786. else
  787. {
  788. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  789. return OmitNumberStr(0, str) + "千垓";
  790. }
  791. }
  792. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  793. {
  794. if (value < Amount.万)
  795. {
  796. return value.ToString("0");
  797. }
  798. else if (value < Amount.千万)
  799. {
  800. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  801. return OmitNumberStr(accuracy, str) + "萬";
  802. }
  803. else if (value < Amount.亿)
  804. {
  805. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  806. return OmitNumberStr(accuracy, str) + "千萬";
  807. }
  808. else if (value < Amount.千亿)
  809. {
  810. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  811. return OmitNumberStr(accuracy, str) + "億";
  812. }
  813. else if (value < Amount.兆)
  814. {
  815. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  816. return OmitNumberStr(accuracy, str) + "千億";
  817. }
  818. else if (value < Amount.千兆)
  819. {
  820. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  821. return OmitNumberStr(accuracy, str) + "兆";
  822. }
  823. else if (value < Amount.京)
  824. {
  825. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  826. return OmitNumberStr(accuracy, str) + "千兆";
  827. }
  828. else if (value < Amount.千京)
  829. {
  830. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  831. return OmitNumberStr(accuracy, str) + "京";
  832. }
  833. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  834. {
  835. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  836. return OmitNumberStr(accuracy, str) + "千京";
  837. }
  838. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  839. {
  840. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  841. return OmitNumberStr(0, str) + "垓";
  842. }
  843. else
  844. {
  845. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  846. return OmitNumberStr(0, str) + "千垓";
  847. }
  848. }
  849. else
  850. {
  851. throw new Exception();
  852. }
  853. }
  854. public static string ShrinkAllNumberStr(double value, int accuracy = 1)
  855. {
  856. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  857. {
  858. if (value < Amount.千)
  859. {
  860. return value.ToString("F" + accuracy);
  861. }
  862. else if (value < Amount.百万)
  863. {
  864. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  865. return OmitNumberStr(accuracy, str) + "K";
  866. }
  867. else if (value < Amount.十亿)
  868. {
  869. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  870. return OmitNumberStr(accuracy, str) + "M";
  871. }
  872. else if (value < Amount.兆)
  873. {
  874. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  875. return OmitNumberStr(accuracy, str) + "B";
  876. }
  877. else if (value < Amount.千兆)
  878. {
  879. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  880. return OmitNumberStr(accuracy, str) + "T";
  881. }
  882. else
  883. {
  884. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  885. return OmitNumberStr(accuracy, str) + "T";
  886. }
  887. }
  888. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  889. {
  890. if (value < Amount.万)
  891. {
  892. return value.ToString("F" + accuracy);
  893. }
  894. else if (value < Amount.千万)
  895. {
  896. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  897. return OmitNumberStr(accuracy, str) + "万";
  898. }
  899. else if (value < Amount.亿)
  900. {
  901. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  902. return OmitNumberStr(accuracy, str) + "千万";
  903. }
  904. else if (value < Amount.千亿)
  905. {
  906. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  907. return OmitNumberStr(accuracy, str) + "亿";
  908. }
  909. else if (value < Amount.兆)
  910. {
  911. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  912. return OmitNumberStr(accuracy, str) + "千亿";
  913. }
  914. else if (value < Amount.千兆)
  915. {
  916. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  917. return OmitNumberStr(accuracy, str) + "兆";
  918. }
  919. else if (value < Amount.京)
  920. {
  921. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  922. return OmitNumberStr(accuracy, str) + "千兆";
  923. }
  924. else if (value < Amount.千京)
  925. {
  926. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  927. return OmitNumberStr(accuracy, str) + "京";
  928. }
  929. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  930. {
  931. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  932. return OmitNumberStr(accuracy, str) + "千京";
  933. }
  934. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  935. {
  936. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  937. return OmitNumberStr(0, str) + "垓";
  938. }
  939. else
  940. {
  941. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  942. return OmitNumberStr(0, str) + "千垓";
  943. }
  944. }
  945. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  946. {
  947. if (value < Amount.万)
  948. {
  949. return value.ToString("F" + accuracy);
  950. }
  951. else if (value < Amount.千万)
  952. {
  953. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  954. return OmitNumberStr(accuracy, str) + "萬";
  955. }
  956. else if (value < Amount.亿)
  957. {
  958. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  959. return OmitNumberStr(accuracy, str) + "千萬";
  960. }
  961. else if (value < Amount.千亿)
  962. {
  963. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  964. return OmitNumberStr(accuracy, str) + "億";
  965. }
  966. else if (value < Amount.兆)
  967. {
  968. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  969. return OmitNumberStr(accuracy, str) + "千億";
  970. }
  971. else if (value < Amount.千兆)
  972. {
  973. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  974. return OmitNumberStr(accuracy, str) + "兆";
  975. }
  976. else if (value < Amount.京)
  977. {
  978. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  979. return OmitNumberStr(accuracy, str) + "千兆";
  980. }
  981. else if (value < Amount.千京)
  982. {
  983. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  984. return OmitNumberStr(accuracy, str) + "京";
  985. }
  986. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  987. {
  988. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  989. return OmitNumberStr(accuracy, str) + "千京";
  990. }
  991. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  992. {
  993. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  994. return OmitNumberStr(0, str) + "垓";
  995. }
  996. else
  997. {
  998. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  999. return OmitNumberStr(0, str) + "千垓";
  1000. }
  1001. }
  1002. else
  1003. {
  1004. throw new Exception();
  1005. }
  1006. }
  1007. public static string ImageParse(Current current)
  1008. {
  1009. if (current == Current.Coin)
  1010. {
  1011. return TransferLabel.CoinSprite;
  1012. }
  1013. else if (current == Current.Diamond)
  1014. {
  1015. return TransferLabel.DiamondSprite;
  1016. }
  1017. else if (current == Current.Cash)
  1018. {
  1019. return Language.GetStr(LanguageLabel.Common__Cash);
  1020. }
  1021. else
  1022. {
  1023. throw new Exception(current.ToString());
  1024. }
  1025. }
  1026. public static Current CurrentParse(string str)
  1027. {
  1028. if (string.IsNullOrEmpty(str))
  1029. {
  1030. return Current.Free;
  1031. }
  1032. else
  1033. {
  1034. int number = int.Parse(str);
  1035. if (number == 1)
  1036. {
  1037. return Current.Coin;
  1038. }
  1039. else if (number == 2)
  1040. {
  1041. return Current.Diamond;
  1042. }
  1043. else if (number == 3)
  1044. {
  1045. return Current.Cash;
  1046. }
  1047. else if (number == 4)
  1048. {
  1049. return Current.Other;
  1050. }
  1051. else if (number == 5)
  1052. {
  1053. return Current.AD;
  1054. }
  1055. else
  1056. {
  1057. throw new Exception(number.ToString());
  1058. }
  1059. }
  1060. }
  1061. public static int StringToInt(string str, int defaultValue)
  1062. {
  1063. if (string.IsNullOrEmpty(str))
  1064. {
  1065. return defaultValue;
  1066. }
  1067. else
  1068. {
  1069. return int.Parse(str);
  1070. }
  1071. }
  1072. public static long StringToLong(string str, long defaultValue)
  1073. {
  1074. if (string.IsNullOrEmpty(str))
  1075. {
  1076. return defaultValue;
  1077. }
  1078. else
  1079. {
  1080. return long.Parse(str);
  1081. }
  1082. }
  1083. public static bool StringToBool(string str, bool defaultValue)
  1084. {
  1085. if (string.IsNullOrEmpty(str))
  1086. {
  1087. return defaultValue;
  1088. }
  1089. else
  1090. {
  1091. return Convert.ToBoolean(int.Parse(str));
  1092. }
  1093. }
  1094. public static float StringToFloat(string str, float defaultValue)
  1095. {
  1096. if (string.IsNullOrEmpty(str))
  1097. {
  1098. return defaultValue;
  1099. }
  1100. else
  1101. {
  1102. return float.Parse(str);
  1103. }
  1104. }
  1105. public static double StringToDouble(string str, double defaultValue)
  1106. {
  1107. if (string.IsNullOrEmpty(str))
  1108. {
  1109. return defaultValue;
  1110. }
  1111. else
  1112. {
  1113. return float.Parse(str);
  1114. }
  1115. }
  1116. public static Vector3 StringToVector(char seperateChar, string str, Vector3 defaultValue)
  1117. {
  1118. if (string.IsNullOrEmpty(str))
  1119. {
  1120. return defaultValue;
  1121. }
  1122. else
  1123. {
  1124. string[] strings = str.Split(seperateChar);
  1125. if (strings.Length == 2)
  1126. {
  1127. Vector2 result = new Vector2();
  1128. result.x = float.Parse(strings[0]);
  1129. result.y = float.Parse(strings[1]);
  1130. return result;
  1131. }
  1132. else if (strings.Length == 3)
  1133. {
  1134. Vector3 result = new Vector3();
  1135. result.x = float.Parse(strings[0]);
  1136. result.y = float.Parse(strings[1]);
  1137. result.z = float.Parse(strings[2]);
  1138. return result;
  1139. }
  1140. else
  1141. {
  1142. Debug.Log(str);
  1143. throw new Exception();
  1144. }
  1145. }
  1146. }
  1147. public static List<int> StringToInts(char seperateChar, string str, List<int> defaultValue)
  1148. {
  1149. if (string.IsNullOrEmpty(str))
  1150. {
  1151. return defaultValue;
  1152. }
  1153. else
  1154. {
  1155. string[] strings = str.Split(seperateChar);
  1156. List<int> list = new List<int>();
  1157. for (int i = 0; i < strings.Length; i++)
  1158. {
  1159. list.Add(int.Parse(strings[i]));
  1160. }
  1161. return list;
  1162. }
  1163. }
  1164. public static List<string> StringToStrings(char seperateChar, string str, List<string> defaultValue)
  1165. {
  1166. if (string.IsNullOrEmpty(str))
  1167. {
  1168. return defaultValue;
  1169. }
  1170. else
  1171. {
  1172. string[] strings = str.Split(seperateChar);
  1173. List<string> list = new List<string>();
  1174. for (int i = 0; i < strings.Length; i++)
  1175. {
  1176. list.Add(strings[i]);
  1177. }
  1178. return list;
  1179. }
  1180. }
  1181. public static List<double> StringToDoubles(char seperateChar, string str, List<double> defaultValue)
  1182. {
  1183. if (string.IsNullOrEmpty(str))
  1184. {
  1185. return defaultValue;
  1186. }
  1187. else
  1188. {
  1189. string[] strings = str.Split(seperateChar);
  1190. List<double> list = new List<double>();
  1191. for (int i = 0; i < strings.Length; i++)
  1192. {
  1193. list.Add(double.Parse(strings[i]));
  1194. }
  1195. return list;
  1196. }
  1197. }
  1198. public static List<int> StartEndIndexToInts(int startIndex, int endIndex)
  1199. {
  1200. List<int> ints = new List<int>();
  1201. for (int i = startIndex; i <= endIndex; i++)
  1202. {
  1203. ints.Add(i);
  1204. }
  1205. return ints;
  1206. }
  1207. public static string IntsToString(List<int> ints)
  1208. {
  1209. StringBuilder stringBuilder = new StringBuilder();
  1210. for (int i = 0; i < ints.Count; i++)
  1211. {
  1212. stringBuilder.Append(ints[i] + " ");
  1213. }
  1214. return stringBuilder.ToString();
  1215. }
  1216. }