Auxiliary.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  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. //ManaPlayer.Player.PlayAnim("newAnimation");
  130. //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));
  131. //ManaMiniGame.GameTimer = 45;
  132. //Lottery.TempTypeList = new List<int>();
  133. //Lottery.TempValueList = new List<int>();
  134. //Lottery.TempLotteryList = new List<Lottery>();
  135. //Lottery.EnterAnimation();
  136. //ManaReso.Get("Bc_LotteryItem1").TweenForEuler();
  137. //ManaReso.Get("Bc_LotteryItem2").TweenForEuler();
  138. //ManaReso.Get("Bc_LotteryItem3").TweenForEuler();
  139. }
  140. if (Input.GetKeyDown(KeyCode.C))
  141. {
  142. //ManaPlayer.Player.PlayAnim("newAnimation1");
  143. //ManaReso.Get("C_Notify").TweenForCG();
  144. //ManaMiniGame.Score += 400;
  145. //ManaSign.SignTime = new DateTime(2007, 1, 1);
  146. }
  147. if (Input.GetKeyDown(KeyCode.V))
  148. {
  149. ManaPlayer.Player.PlayAnim("newAnimation2");
  150. //ManaPlayer.Player.Flip(PlayerDirection.Right);
  151. //ManaServer.MailReward mailReward = new ManaServer.MailReward("1", "pack", "4");
  152. //ManaServer.MailReward mailReward1 = new ManaServer.MailReward("1", "close", "2");
  153. //ManaServer.GetMainReward(mailReward);
  154. //ManaServer.GetMainReward(mailReward1);
  155. //ManaGarden.ElfTimer = 0;
  156. //ManaServer.Time = new DateTime(2007, 1, 1);
  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("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. ManaMiniGame.Pause = true;
  221. Bubble.Show(Language.GetStr("Common", "QuitGame"), null, null, null, Application.Quit, () => { ManaMiniGame.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 < ManaCenter.CoolList.Count; i++)
  247. {
  248. ManaCenter.CoolList[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 (ManaLan.CurrentLan == Lan.English)
  345. {
  346. if (value == 0 || value == 1)
  347. {
  348. return " Second";
  349. }
  350. else
  351. {
  352. return " Seconds";
  353. }
  354. }
  355. else if (ManaLan.CurrentLan == Lan.ChineseSimplified)
  356. {
  357. return "秒";
  358. }
  359. else if (ManaLan.CurrentLan == Lan.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 (ManaLan.CurrentLan == Lan.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 (ManaLan.CurrentLan == Lan.ChineseSimplified || ManaLan.CurrentLan == Lan.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 (ManaLan.CurrentLan == Lan.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 (ManaLan.CurrentLan == Lan.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 (ManaLan.CurrentLan == Lan.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 "<(金币)>";
  812. }
  813. else if (current == Current.Diamond)
  814. {
  815. return "<(钻石)>";
  816. }
  817. else if (current == Current.Cash)
  818. {
  819. return Language.GetStr("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 IntParse(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 LongParse(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 BoolParse(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 FloatParse(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 DoubleParse(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 VectorParse(char cah, string str, Vector3 defaultValue)
  917. {
  918. if (string.IsNullOrEmpty(str))
  919. {
  920. return defaultValue;
  921. }
  922. else
  923. {
  924. string[] strings = str.Split(',');
  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> IntListParse(char cah, string str, List<int> defaultValue)
  948. {
  949. if (string.IsNullOrEmpty(str))
  950. {
  951. return defaultValue;
  952. }
  953. else
  954. {
  955. string[] strings = str.Split(cah);
  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> StringListParse(char cah, string str, List<string> defaultValue)
  965. {
  966. if (string.IsNullOrEmpty(str))
  967. {
  968. return defaultValue;
  969. }
  970. else
  971. {
  972. string[] strings = str.Split(cah);
  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> DoubleListParse(char cah, string str, List<double> defaultValue)
  982. {
  983. if (string.IsNullOrEmpty(str))
  984. {
  985. return defaultValue;
  986. }
  987. else
  988. {
  989. string[] strings = str.Split(cah);
  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. }