Auxiliary.cs 32 KB

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