Auxiliary.cs 33 KB

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