Auxiliary.cs 32 KB

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