Auxiliary.cs 30 KB

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