Auxiliary.cs 31 KB

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