Auxiliary.cs 30 KB

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