Auxiliary.cs 30 KB

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