Auxiliary.cs 30 KB

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