Auxiliary.cs 30 KB

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