Auxiliary.cs 33 KB

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