Auxiliary.cs 31 KB

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