Auxiliary.cs 33 KB

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