Auxiliary.cs 32 KB

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