Auxiliary.cs 34 KB

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