Auxiliary.cs 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  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 Sprite Sprite;
  57. public TextAsset TextAsset;
  58. public Texture2D Texture;
  59. public Texture2D Texture1;
  60. public Texture2D Texture2;
  61. public AnimationClip AnimationClip;
  62. public Font Font;
  63. public GameObject Go;
  64. public List<Sprite> Sprites;
  65. public List<GameObject> GoList;
  66. public List<SpriteRenderer> SrList;
  67. public static bool AnyKeyUp;
  68. public static bool AnyKeyDown;
  69. public static Auxiliary Instance;
  70. public static MD5 MD5
  71. {
  72. get
  73. {
  74. if (_MD5 == null)
  75. {
  76. _MD5 = new MD5CryptoServiceProvider();
  77. }
  78. return _MD5;
  79. }
  80. set { _MD5 = value; }
  81. }
  82. public static DESCryptoServiceProvider Des
  83. {
  84. get
  85. {
  86. if (_Des == null)
  87. {
  88. _Des = new DESCryptoServiceProvider();
  89. _Des.IV = Encoding.UTF8.GetBytes("19283740");
  90. _Des.Key = Encoding.UTF8.GetBytes("93287123");
  91. }
  92. return _Des;
  93. }
  94. set { _Des = value; }
  95. }
  96. private static MD5 _MD5;
  97. private static DESCryptoServiceProvider _Des;
  98. #endregion
  99. public override bool InitAtOnce()
  100. {
  101. if (base.InitAtOnce())
  102. {
  103. return true;
  104. }
  105. enabled = true;
  106. return false;
  107. }
  108. private void Awake()
  109. {
  110. Instance = this;
  111. }
  112. private void Update()
  113. {
  114. #region 调试
  115. //if (Input.GetKeyDown(KeyCode.Escape))
  116. //{
  117. // SFSManager.GardenSmartFox.SmartFox.Disconnect();
  118. // RobotManager.DeactivateAllRobots(false);
  119. //}
  120. //if (Input.GetKeyDown(KeyCode.Space))
  121. //{
  122. //Debug.Log(ConfigManager.ConfigRootNode.OuterXml);
  123. // DebugManager.ResetGardenLevel(7);
  124. //DebugManager.ResetVisitTutorial();
  125. //HttpManager.GetThanksGiftInfo(RechargeGiftManager.Init, () => Bubble.Show(null, Language.GetStr(LanguageLabel.UI__GetThanksGiftInfoFailed)));
  126. //}
  127. //if (Input.GetKeyDown(KeyCode.A))
  128. //{
  129. // DebugManager.ResetGardenLevel(30);
  130. //}
  131. //if (Input.GetKeyDown(KeyCode.S))
  132. //{
  133. // Manager.Coin = 0;
  134. // Manager.Diamond = 0;
  135. //}
  136. //if (Input.GetKeyDown(KeyCode.D))
  137. //{
  138. // Manager.Coin = 100000;
  139. // Manager.Diamond = 1000;
  140. //}
  141. //if (Input.GetKeyDown(KeyCode.Z))
  142. //{
  143. // Manager.MinigameCDTimer = 0;
  144. //}
  145. //if (Input.GetKeyDown(KeyCode.X))
  146. //{
  147. // MiniGameManager.GameTimer = 45;
  148. //}
  149. //if (Input.GetKeyDown(KeyCode.C))
  150. //{
  151. // DebugManager.ResetAbilityAnim();
  152. //}
  153. //if (Input.GetKeyDown(KeyCode.V))
  154. //{
  155. // AccountData accountData = new AccountData("测试名字", "1710065808151506837", DateTime.Now.ToString());
  156. // MessagePanel.OpenPanel(accountData);
  157. //}
  158. //if (Input.GetKeyDown(KeyCode.B))
  159. //{
  160. // ManaPlayer.Player.PlayAnim("newAnimation3");
  161. // ManaPlayer.Player.Flip(PlayerDirection.Left);
  162. // foreach (var VARIABLE in ManaPlayer.CloseUnitDic)
  163. // {
  164. // VARIABLE.Value.Unlock();
  165. // }
  166. //}
  167. //if (Input.GetKeyDown(KeyCode.M))
  168. //{
  169. // ManaReso.Get(PrefabLabel.G_Flower).SetActive(false);
  170. // Debug.Log(ManaGarden.Slot);
  171. //}
  172. //if (Input.GetKeyDown(KeyCode.N))
  173. //{
  174. // ManaCenter.Coin = 0;
  175. // ManaCenter.Diamond = 0;
  176. // foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
  177. // {
  178. // VARIABLE.Value.Unlock = true;
  179. // }
  180. // foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
  181. // {
  182. // VARIABLE.Value.Unlock = false;
  183. // }
  184. // ManaGarden.FlowerInfoDic.First().Value.Unlock = true;
  185. //}
  186. //if (Input.GetKeyDown(KeyCode.P))
  187. //{
  188. // ManaData.Level += 20;
  189. //}
  190. //if (Input.GetKeyDown(KeyCode.O))
  191. //{
  192. // for (int i = 0; i < ManaCenter.CoolList.Count; i++)
  193. // {
  194. // ManaCenter.CoolList[i].CoolTimer = 0;
  195. // }
  196. //}
  197. //if (Input.GetKeyDown(KeyCode.I))
  198. //{
  199. // ManaCenter.Coin += 1000;
  200. // ManaCenter.Diamond += 1000;
  201. //}
  202. //if (Input.GetKeyDown(KeyCode.U))
  203. //{
  204. // Data.SavePlayerConfig();
  205. // Data.SaveXml();
  206. //}
  207. //if (Input.GetKeyDown(KeyCode.Y))
  208. //{
  209. // Data.ResetPlayerConfig();
  210. // Data.SaveXml();
  211. //}
  212. //if (Input.GetKeyDown(KeyCode.T))
  213. //{
  214. // ManaData.Pause = !ManaData.Pause;
  215. //}
  216. #endregion
  217. #region 输入检测
  218. if (Input.GetKeyDown(KeyCode.Escape))
  219. {
  220. MiniGameManager.Pause = true;
  221. Bubble.Show(Language.GetStr(LanguageLabel.Common__QuitGame), null, null, null, Application.Quit, () => { MiniGameManager.Pause = false; });
  222. }
  223. if (AnyKeyUp)
  224. {
  225. if (Input.anyKey == false)
  226. {
  227. AnyKeyUp = false;
  228. }
  229. }
  230. if (Input.anyKeyDown)
  231. {
  232. AnyKeyDown = true;
  233. }
  234. if (AnyKeyDown)
  235. {
  236. if (Input.anyKey == false)
  237. {
  238. AnyKeyUp = true;
  239. AnyKeyDown = false;
  240. }
  241. }
  242. #endregion
  243. }
  244. private static void ResetAllCd()
  245. {
  246. for (int i = 0; i < Manager.CoolSkillList.Count; i++)
  247. {
  248. Manager.CoolSkillList[i].CoolTimer = 0;
  249. }
  250. }
  251. public static byte[] GetMD5(object obj)
  252. {
  253. MemoryStream memoryStream = new MemoryStream();
  254. BinaryFormatter binaryFormatter = new BinaryFormatter();
  255. binaryFormatter.Serialize(memoryStream, obj);
  256. byte[] bytes = memoryStream.GetBuffer();
  257. memoryStream.Dispose();
  258. return MD5.ComputeHash(bytes);
  259. }
  260. public static void EncryptXml(XmlDocument doc)
  261. {
  262. EncryptedXml encryptedXml = new EncryptedXml();
  263. XmlElement xmlElement = doc.DocumentElement;
  264. byte[] bytes = encryptedXml.EncryptData(xmlElement, Des, false);
  265. EncryptedData encryptedData = new EncryptedData();
  266. encryptedData.Type = EncryptedXml.XmlEncElementUrl;
  267. encryptedData.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncDESUrl);
  268. encryptedData.CipherData.CipherValue = bytes;
  269. EncryptedXml.ReplaceElement(xmlElement, encryptedData, false);
  270. }
  271. public static void DecryptXml(XmlDocument doc)
  272. {
  273. EncryptedXml encryptedXml = new EncryptedXml();
  274. XmlElement encryptXmlElement = (XmlElement)doc.GetElementsByTagName("EncryptedData")[0];
  275. EncryptedData encryptedData = new EncryptedData();
  276. encryptedData.LoadXml(encryptXmlElement);
  277. byte[] bytes = encryptedXml.DecryptData(encryptedData, Des);
  278. encryptedXml.ReplaceData(encryptXmlElement, bytes);
  279. }
  280. public static byte[] Encrypt(string str)
  281. {
  282. byte[] bytes = Encoding.UTF8.GetBytes(str);
  283. byte[] encryptBytes = Des.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length);
  284. return encryptBytes;
  285. }
  286. public static byte[] ToBytes(string str)
  287. {
  288. string[] strings = str.Split(' ');
  289. byte[] bytes = new byte[strings.Length];
  290. for (int i = 0; i < bytes.Length; i++)
  291. {
  292. bytes[i] = byte.Parse(strings[i]);
  293. }
  294. return bytes;
  295. }
  296. public static string Decrypt(string str)
  297. {
  298. byte[] encryptBytes = ToBytes(str);
  299. byte[] decryptBytes = Des.CreateDecryptor().TransformFinalBlock(encryptBytes, 0, encryptBytes.Length);
  300. return Encoding.UTF8.GetString(decryptBytes);
  301. }
  302. public static string ToString(byte[] bytes)
  303. {
  304. StringBuilder strB = new StringBuilder();
  305. for (int i = 0; i < bytes.Length; i++)
  306. {
  307. if (i == bytes.Length - 1)
  308. {
  309. strB.Append(bytes[i]);
  310. }
  311. else
  312. {
  313. strB.Append(bytes[i] + " ");
  314. }
  315. }
  316. return strB.ToString();
  317. }
  318. public static void CompileDic(Transform tra, Dictionary<string, Transform> dic, bool enableIgnore = true)
  319. {
  320. Transform[] transforms = tra.GetComponentsInChildren<Transform>(true);
  321. for (int i = 0; i < transforms.Length; i++)
  322. {
  323. if (enableIgnore)
  324. {
  325. if (transforms[i].GetComponent<IgnoreIndexing>())
  326. {
  327. continue;
  328. }
  329. }
  330. if (dic.ContainsKey(transforms[i].name))
  331. {
  332. throw new Exception(transforms[i].name);
  333. }
  334. else
  335. {
  336. dic.Add(transforms[i].name, transforms[i]);
  337. }
  338. }
  339. }
  340. public static string GetUnit(int value, Unit unit)
  341. {
  342. if (unit == Unit.Second)
  343. {
  344. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  345. {
  346. if (value == 0 || value == 1)
  347. {
  348. return " Second";
  349. }
  350. else
  351. {
  352. return " Seconds";
  353. }
  354. }
  355. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  356. {
  357. return "秒";
  358. }
  359. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  360. {
  361. return "秒";
  362. }
  363. else
  364. {
  365. throw new Exception();
  366. }
  367. }
  368. else
  369. {
  370. throw new Exception();
  371. }
  372. }
  373. public static string GetStreamPath()
  374. {
  375. if (Application.isEditor)
  376. {
  377. return "file://" + Application.streamingAssetsPath;
  378. }
  379. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  380. {
  381. return "file://" + Application.streamingAssetsPath;
  382. }
  383. else if (Application.isMobilePlatform)
  384. {
  385. return Application.streamingAssetsPath;
  386. }
  387. else
  388. {
  389. throw new Exception();
  390. }
  391. }
  392. public Coroutine DelayCall(UnityAction function, int frame)
  393. {
  394. return StartCoroutine(IDelayCall(function, frame));
  395. }
  396. public Coroutine DelayCall(UnityAction function, float time)
  397. {
  398. return StartCoroutine(IDelayCall(function, time));
  399. }
  400. public static IEnumerator IDelayCall(UnityAction function, int frame)
  401. {
  402. int count = 0;
  403. while (count < frame)
  404. {
  405. count++;
  406. yield return null;
  407. }
  408. function.Invoke();
  409. }
  410. public static IEnumerator IDelayCall(UnityAction function, float time)
  411. {
  412. yield return new WaitForSeconds(time);
  413. function.Invoke();
  414. }
  415. public static string FmlParse1(string str)
  416. {
  417. int index = 0;
  418. int openIndex = 0;
  419. bool flag = false;
  420. bool group = false;
  421. for (int i = 0; i < str.Length; i++)
  422. {
  423. if (group)
  424. {
  425. if (str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/')
  426. {
  427. str = str.Replace(openIndex, i - 1, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i - 1)));
  428. i = 0;
  429. group = false;
  430. }
  431. else if (i == str.Length - 1)
  432. {
  433. str = str.Replace(openIndex, i, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i)));
  434. break;
  435. }
  436. }
  437. else
  438. {
  439. if (str[i] == '+' || str[i] == '-')
  440. {
  441. flag = true;
  442. openIndex = i + 1;
  443. }
  444. else if (str[i] == '*' || str[i] == '/')
  445. {
  446. index = i;
  447. group = true;
  448. if (!flag)
  449. {
  450. openIndex = 0;
  451. }
  452. }
  453. }
  454. }
  455. group = false;
  456. for (int i = 0; i < str.Length; i++)
  457. {
  458. if (group)
  459. {
  460. if (str[i] == '+' || str[i] == '-')
  461. {
  462. str = str.Replace(0, i - 1, FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i - 1)));
  463. i = -1;
  464. group = false;
  465. }
  466. else if (i == str.Length - 1)
  467. {
  468. return FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i));
  469. }
  470. }
  471. else
  472. {
  473. if (str[i] == '+' || str[i] == '-')
  474. {
  475. index = i;
  476. group = true;
  477. }
  478. }
  479. }
  480. return str;
  481. }
  482. public static string FmlParse2(char op, string str1, string str2)
  483. {
  484. double var1 = double.Parse(str1);
  485. double var2 = double.Parse(str2);
  486. if (op == '+')
  487. {
  488. return (var1 + var2).ToString();
  489. }
  490. else if (op == '-')
  491. {
  492. return (var1 - var2).ToString();
  493. }
  494. else if (op == '*')
  495. {
  496. return (var1 * var2).ToString();
  497. }
  498. else if (op == '/')
  499. {
  500. return (var1 / var2).ToString();
  501. }
  502. else
  503. {
  504. throw new Exception(op.ToString());
  505. }
  506. }
  507. public static double FmlParse(string str, params string[] strings)
  508. {
  509. for (int i = 0; i < strings.Length; i += 2)
  510. {
  511. if (str.Contains(strings[i]))
  512. {
  513. str = str.Replace(strings[i], strings[i + 1]);
  514. }
  515. else
  516. {
  517. //Debug.Log("No such var " + strings[i + 1]);
  518. }
  519. }
  520. int openIndex = 0;
  521. for (int i = 0; i < str.Length; i++)
  522. {
  523. if (str[i] == '(')
  524. {
  525. openIndex = i;
  526. }
  527. else if (str[i] == ')')
  528. {
  529. str = str.Replace(openIndex, i, FmlParse1(str.Between(openIndex + 1, i - 1)));
  530. i = -1;
  531. }
  532. }
  533. return double.Parse(FmlParse1(str));
  534. }
  535. public static string OmitNumberStr(int accuray, string str)
  536. {
  537. int index = str.IndexOf('.');
  538. if (index == -1)
  539. {
  540. return str;
  541. }
  542. if (accuray == 0)
  543. {
  544. return str.Substring(0, index);
  545. }
  546. else
  547. {
  548. for (int i = index + 1; i < index + accuray + 1; i++)
  549. {
  550. if (str[i] != '0')
  551. {
  552. return str.Substring(0, index + accuray + 1);
  553. }
  554. }
  555. return str.Substring(0, index);
  556. }
  557. }
  558. public static double ShrinkNumber(double value, int accuracy = 1)
  559. {
  560. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  561. {
  562. if (value < Amount.千)
  563. {
  564. return value;
  565. }
  566. else if (value < Amount.百万)
  567. {
  568. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  569. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千;
  570. }
  571. else if (value < Amount.十亿)
  572. {
  573. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  574. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.百万;
  575. }
  576. else if (value < Amount.兆)
  577. {
  578. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  579. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.十亿;
  580. }
  581. else if (value < Amount.千兆)
  582. {
  583. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  584. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
  585. }
  586. else
  587. {
  588. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  589. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千兆;
  590. }
  591. }
  592. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified || LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  593. {
  594. if (value < Amount.万)
  595. {
  596. return value;
  597. }
  598. else if (value < Amount.千万)
  599. {
  600. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  601. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.万;
  602. }
  603. else if (value < Amount.亿)
  604. {
  605. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  606. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千万;
  607. }
  608. else if (value < Amount.千亿)
  609. {
  610. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  611. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.亿;
  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 if (new BigInteger(value.ToString("0")) < Amount.垓)
  634. {
  635. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  636. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千京;
  637. }
  638. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  639. {
  640. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  641. return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10;
  642. }
  643. else
  644. {
  645. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  646. return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10000;
  647. }
  648. }
  649. else
  650. {
  651. throw new Exception();
  652. }
  653. }
  654. public static string ShrinkNumberStr(double value, int accuracy = 1)
  655. {
  656. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  657. {
  658. if (value < Amount.千)
  659. {
  660. return value.ToString("0");
  661. }
  662. else if (value < Amount.百万)
  663. {
  664. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  665. return OmitNumberStr(accuracy, str) + "K";
  666. }
  667. else if (value < Amount.十亿)
  668. {
  669. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  670. return OmitNumberStr(accuracy, str) + "M";
  671. }
  672. else if (value < Amount.兆)
  673. {
  674. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  675. return OmitNumberStr(accuracy, str) + "B";
  676. }
  677. else if (value < Amount.千兆)
  678. {
  679. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  680. return OmitNumberStr(accuracy, str) + "T";
  681. }
  682. else
  683. {
  684. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  685. return OmitNumberStr(accuracy, str) + "T";
  686. }
  687. }
  688. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  689. {
  690. if (value < Amount.万)
  691. {
  692. return value.ToString("0");
  693. }
  694. else if (value < Amount.千万)
  695. {
  696. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  697. return OmitNumberStr(accuracy, str) + "万";
  698. }
  699. else if (value < Amount.亿)
  700. {
  701. string str = (value/Amount.千万).ToString("F" + (accuracy + 1));
  702. return OmitNumberStr(accuracy, str) + "千万";
  703. }
  704. else if (value < Amount.千亿)
  705. {
  706. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  707. return OmitNumberStr(accuracy, str) + "亿";
  708. }
  709. else if (value < Amount.兆)
  710. {
  711. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  712. return OmitNumberStr(accuracy, str) + "千亿";
  713. }
  714. else if (value < Amount.千兆)
  715. {
  716. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  717. return OmitNumberStr(accuracy, str) + "兆";
  718. }
  719. else if (value < Amount.京)
  720. {
  721. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  722. return OmitNumberStr(accuracy, str) + "千兆";
  723. }
  724. else if (value < Amount.千京)
  725. {
  726. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  727. return OmitNumberStr(accuracy, str) + "京";
  728. }
  729. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  730. {
  731. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  732. return OmitNumberStr(accuracy, str) + "千京";
  733. }
  734. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  735. {
  736. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  737. return OmitNumberStr(0, str) + "垓";
  738. }
  739. else
  740. {
  741. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  742. return OmitNumberStr(0, str) + "千垓";
  743. }
  744. }
  745. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  746. {
  747. if (value < Amount.万)
  748. {
  749. return value.ToString("0");
  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 (value < Amount.京)
  777. {
  778. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  779. return OmitNumberStr(accuracy, str) + "千兆";
  780. }
  781. else if (value < Amount.千京)
  782. {
  783. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  784. return OmitNumberStr(accuracy, str) + "京";
  785. }
  786. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  787. {
  788. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  789. return OmitNumberStr(accuracy, str) + "千京";
  790. }
  791. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  792. {
  793. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  794. return OmitNumberStr(0, str) + "垓";
  795. }
  796. else
  797. {
  798. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  799. return OmitNumberStr(0, str) + "千垓";
  800. }
  801. }
  802. else
  803. {
  804. throw new Exception();
  805. }
  806. }
  807. public static string ImageParse(Current current)
  808. {
  809. if (current == Current.Coin)
  810. {
  811. return TransferLabel.CoinSprite;
  812. }
  813. else if (current == Current.Diamond)
  814. {
  815. return TransferLabel.DiamondSprite;
  816. }
  817. else if (current == Current.Cash)
  818. {
  819. return Language.GetStr(LanguageLabel.Common__Cash);
  820. }
  821. else
  822. {
  823. throw new Exception(current.ToString());
  824. }
  825. }
  826. public static Current CurrentParse(string str)
  827. {
  828. if (string.IsNullOrEmpty(str))
  829. {
  830. return Current.Free;
  831. }
  832. else
  833. {
  834. int number = int.Parse(str);
  835. if (number == 1)
  836. {
  837. return Current.Coin;
  838. }
  839. else if (number == 2)
  840. {
  841. return Current.Diamond;
  842. }
  843. else if (number == 3)
  844. {
  845. return Current.Cash;
  846. }
  847. else if (number == 4)
  848. {
  849. return Current.Other;
  850. }
  851. else if (number == 5)
  852. {
  853. return Current.AD;
  854. }
  855. else
  856. {
  857. throw new Exception(number.ToString());
  858. }
  859. }
  860. }
  861. public static int StringToInt(string str, int defaultValue)
  862. {
  863. if (string.IsNullOrEmpty(str))
  864. {
  865. return defaultValue;
  866. }
  867. else
  868. {
  869. return int.Parse(str);
  870. }
  871. }
  872. public static long StringToLong(string str, long defaultValue)
  873. {
  874. if (string.IsNullOrEmpty(str))
  875. {
  876. return defaultValue;
  877. }
  878. else
  879. {
  880. return long.Parse(str);
  881. }
  882. }
  883. public static bool StringToBool(string str, bool defaultValue)
  884. {
  885. if (string.IsNullOrEmpty(str))
  886. {
  887. return defaultValue;
  888. }
  889. else
  890. {
  891. return Convert.ToBoolean(int.Parse(str));
  892. }
  893. }
  894. public static float StringToFloat(string str, float defaultValue)
  895. {
  896. if (string.IsNullOrEmpty(str))
  897. {
  898. return defaultValue;
  899. }
  900. else
  901. {
  902. return float.Parse(str);
  903. }
  904. }
  905. public static double StringToDouble(string str, double defaultValue)
  906. {
  907. if (string.IsNullOrEmpty(str))
  908. {
  909. return defaultValue;
  910. }
  911. else
  912. {
  913. return float.Parse(str);
  914. }
  915. }
  916. public static Vector3 StringToVector(char seperateChar, string str, Vector3 defaultValue)
  917. {
  918. if (string.IsNullOrEmpty(str))
  919. {
  920. return defaultValue;
  921. }
  922. else
  923. {
  924. string[] strings = str.Split(seperateChar);
  925. if (strings.Length == 2)
  926. {
  927. Vector2 result = new Vector2();
  928. result.x = float.Parse(strings[0]);
  929. result.y = float.Parse(strings[1]);
  930. return result;
  931. }
  932. else if (strings.Length == 3)
  933. {
  934. Vector3 result = new Vector3();
  935. result.x = float.Parse(strings[0]);
  936. result.y = float.Parse(strings[1]);
  937. result.z = float.Parse(strings[2]);
  938. return result;
  939. }
  940. else
  941. {
  942. Debug.Log(str);
  943. throw new Exception();
  944. }
  945. }
  946. }
  947. public static List<int> StringToInts(char seperateChar, string str, List<int> defaultValue)
  948. {
  949. if (string.IsNullOrEmpty(str))
  950. {
  951. return defaultValue;
  952. }
  953. else
  954. {
  955. string[] strings = str.Split(seperateChar);
  956. List<int> list = new List<int>();
  957. for (int i = 0; i < strings.Length; i++)
  958. {
  959. list.Add(int.Parse(strings[i]));
  960. }
  961. return list;
  962. }
  963. }
  964. public static List<string> StringToStrings(char seperateChar, string str, List<string> defaultValue)
  965. {
  966. if (string.IsNullOrEmpty(str))
  967. {
  968. return defaultValue;
  969. }
  970. else
  971. {
  972. string[] strings = str.Split(seperateChar);
  973. List<string> list = new List<string>();
  974. for (int i = 0; i < strings.Length; i++)
  975. {
  976. list.Add(strings[i]);
  977. }
  978. return list;
  979. }
  980. }
  981. public static List<double> StringToDoubles(char seperateChar, string str, List<double> defaultValue)
  982. {
  983. if (string.IsNullOrEmpty(str))
  984. {
  985. return defaultValue;
  986. }
  987. else
  988. {
  989. string[] strings = str.Split(seperateChar);
  990. List<double> list = new List<double>();
  991. for (int i = 0; i < strings.Length; i++)
  992. {
  993. list.Add(double.Parse(strings[i]));
  994. }
  995. return list;
  996. }
  997. }
  998. public static List<int> StartEndIndexToInts(int startIndex, int endIndex)
  999. {
  1000. List<int> ints = new List<int>();
  1001. for (int i = startIndex; i <= endIndex; i++)
  1002. {
  1003. ints.Add(i);
  1004. }
  1005. return ints;
  1006. }
  1007. public static string IntsToString(List<int> ints)
  1008. {
  1009. StringBuilder stringBuilder = new StringBuilder();
  1010. for (int i = 0; i < ints.Count; i++)
  1011. {
  1012. stringBuilder.Append(ints[i] + " ");
  1013. }
  1014. return stringBuilder.ToString();
  1015. }
  1016. }