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