Auxiliary.cs 31 KB

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