Auxiliary.cs 31 KB

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