Auxiliary.cs 33 KB

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