Auxiliary.cs 31 KB

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