Auxiliary.cs 33 KB

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