Auxiliary.cs 35 KB

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