Auxiliary.cs 42 KB

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