Auxiliary.cs 30 KB

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