Auxiliary.cs 32 KB

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