Auxiliary.cs 30 KB

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