Auxiliary.cs 31 KB

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