Auxiliary.cs 31 KB

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