Auxiliary.cs 31 KB

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