Auxiliary.cs 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  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. // foreach (var skill in Manager.UsingSkillList)
  130. // {
  131. // skill.UseTimer = 0;
  132. // }
  133. // foreach (var skill in Manager.CoolSkillList)
  134. // {
  135. // skill.CoolTimer = 0;
  136. // }
  137. // HttpManager.GetTargetConfig
  138. // (
  139. // "1801134288353834791",
  140. // data =>
  141. // {
  142. // VisitManager.VisiteeSerialNumber = "1801134288353834791";
  143. // VisitManager.SavePulledConfig(data);
  144. // }
  145. // );
  146. // PlayerPrefManager.SaveBool(PlayerPrefManager.INTERACT_CONFIG, false);
  147. // Debug.Log(ResourceManager.Get<Canvas>(CanvasLabel.Canvas).scaleFactor);
  148. // RectTransform rectTransform = ResourceManager.Get<RectTransform>(CanvasLabel.P_ScreenShotRect);
  149. // Vector2 screenPosition = RectTransformUtility.WorldToScreenPoint(null, rectTransform.position);
  150. // Debug.Log(screenPosition);
  151. // Debug.Log(ConfigManager.ConfigRootNode.OuterXml);
  152. // DebugManager.ResetGardenLevel(22);
  153. // DebugManager.ResetVisitTutorial();
  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. // Manager.Coin = 100000;
  192. // Manager.Diamond = 1000;
  193. //}
  194. //if (Input.GetKeyDown(KeyCode.Z))
  195. //{
  196. // Manager.MinigameCDTimer = 0;
  197. //}
  198. //if (Input.GetKeyDown(KeyCode.X))
  199. //{
  200. // MiniGameManager.GameTimer = 45;
  201. //}
  202. //if (Input.GetKeyDown(KeyCode.C))
  203. //{
  204. // ConfigManager.SaveStringToConfig(PlayerConfigLabel.OneTimeReward, "");
  205. // SignManager.LastSignTime = DateTime.MinValue;
  206. // DebugManager.ResetAbilityAnim();
  207. //}
  208. //if (Input.GetKeyDown(KeyCode.V))
  209. //{
  210. // AccountData accountData = new AccountData("测试名字", "1710065808151506837", DateTime.Now.ToString());
  211. // MessagePanel.OpenPanel(accountData);
  212. //}
  213. //if (Input.GetKeyDown(KeyCode.B))
  214. //{
  215. // ManaPlayer.Player.PlayAnim("newAnimation3");
  216. // ManaPlayer.Player.Flip(PlayerDirection.Left);
  217. // foreach (var VARIABLE in ManaPlayer.CloseUnitDic)
  218. // {
  219. // VARIABLE.Value.Unlock();
  220. // }
  221. //}
  222. //if (Input.GetKeyDown(KeyCode.M))
  223. //{
  224. // ManaReso.Get(PrefabLabel.G_Flower).SetActive(false);
  225. // Debug.Log(ManaGarden.Slot);
  226. //}
  227. //if (Input.GetKeyDown(KeyCode.N))
  228. //{
  229. // ManaCenter.Coin = 0;
  230. // ManaCenter.Diamond = 0;
  231. // foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
  232. // {
  233. // VARIABLE.Value.Unlock = true;
  234. // }
  235. // foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
  236. // {
  237. // VARIABLE.Value.Unlock = false;
  238. // }
  239. // ManaGarden.FlowerInfoDic.First().Value.Unlock = true;
  240. //}
  241. //if (Input.GetKeyDown(KeyCode.P))
  242. //{
  243. // ManaData.Level += 20;
  244. //}
  245. //if (Input.GetKeyDown(KeyCode.O))
  246. //{
  247. // for (int i = 0; i < ManaCenter.CoolList.Count; i++)
  248. // {
  249. // ManaCenter.CoolList[i].CoolTimer = 0;
  250. // }
  251. //}
  252. //if (Input.GetKeyDown(KeyCode.I))
  253. //{
  254. // ManaCenter.Coin += 1000;
  255. // ManaCenter.Diamond += 1000;
  256. //}
  257. //if (Input.GetKeyDown(KeyCode.U))
  258. //{
  259. // Data.SavePlayerConfig();
  260. // Data.SaveXml();
  261. //}
  262. //if (Input.GetKeyDown(KeyCode.Y))
  263. //{
  264. // Data.ResetPlayerConfig();
  265. // Data.SaveXml();
  266. //}
  267. //if (Input.GetKeyDown(KeyCode.T))
  268. //{
  269. // ManaData.Pause = !ManaData.Pause;
  270. //}
  271. #endregion
  272. #region 输入检测
  273. if (Input.GetKeyDown(KeyCode.Escape))
  274. {
  275. MiniGameManager.Pause = true;
  276. Bubble.Show(null, Language.GetStr(LanguageLabel.Common__QuitGame), null, null, Application.Quit, () => { MiniGameManager.Pause = false; });
  277. }
  278. if (AnyKeyUp)
  279. {
  280. if (Input.anyKey == false)
  281. {
  282. AnyKeyUp = false;
  283. }
  284. }
  285. if (Input.anyKeyDown)
  286. {
  287. AnyKeyDown = true;
  288. }
  289. if (AnyKeyDown)
  290. {
  291. if (Input.anyKey == false)
  292. {
  293. AnyKeyUp = true;
  294. AnyKeyDown = false;
  295. }
  296. }
  297. #endregion
  298. }
  299. private static void ResetAllCd()
  300. {
  301. for (int i = 0; i < Manager.CoolSkillList.Count; i++)
  302. {
  303. Manager.CoolSkillList[i].CoolTimer = 0;
  304. }
  305. }
  306. public static byte[] GetMD5(object obj)
  307. {
  308. MemoryStream memoryStream = new MemoryStream();
  309. BinaryFormatter binaryFormatter = new BinaryFormatter();
  310. binaryFormatter.Serialize(memoryStream, obj);
  311. byte[] bytes = memoryStream.GetBuffer();
  312. memoryStream.Dispose();
  313. return MD5.ComputeHash(bytes);
  314. }
  315. public static void EncryptXml(XmlDocument doc)
  316. {
  317. EncryptedXml encryptedXml = new EncryptedXml();
  318. XmlElement xmlElement = doc.DocumentElement;
  319. byte[] bytes = encryptedXml.EncryptData(xmlElement, Des, false);
  320. EncryptedData encryptedData = new EncryptedData();
  321. encryptedData.Type = EncryptedXml.XmlEncElementUrl;
  322. encryptedData.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncDESUrl);
  323. encryptedData.CipherData.CipherValue = bytes;
  324. EncryptedXml.ReplaceElement(xmlElement, encryptedData, false);
  325. }
  326. public static void DecryptXml(XmlDocument doc)
  327. {
  328. EncryptedXml encryptedXml = new EncryptedXml();
  329. XmlElement encryptXmlElement = (XmlElement)doc.GetElementsByTagName("EncryptedData")[0];
  330. EncryptedData encryptedData = new EncryptedData();
  331. encryptedData.LoadXml(encryptXmlElement);
  332. byte[] bytes = encryptedXml.DecryptData(encryptedData, Des);
  333. encryptedXml.ReplaceData(encryptXmlElement, bytes);
  334. }
  335. public static byte[] Encrypt(string str)
  336. {
  337. byte[] bytes = Encoding.UTF8.GetBytes(str);
  338. byte[] encryptBytes = Des.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length);
  339. return encryptBytes;
  340. }
  341. public static byte[] ToBytes(string str)
  342. {
  343. string[] strings = str.Split(' ');
  344. byte[] bytes = new byte[strings.Length];
  345. for (int i = 0; i < bytes.Length; i++)
  346. {
  347. bytes[i] = byte.Parse(strings[i]);
  348. }
  349. return bytes;
  350. }
  351. public static string Decrypt(string str)
  352. {
  353. byte[] encryptBytes = ToBytes(str);
  354. byte[] decryptBytes = Des.CreateDecryptor().TransformFinalBlock(encryptBytes, 0, encryptBytes.Length);
  355. return Encoding.UTF8.GetString(decryptBytes);
  356. }
  357. public static string ToString(byte[] bytes)
  358. {
  359. StringBuilder strB = new StringBuilder();
  360. for (int i = 0; i < bytes.Length; i++)
  361. {
  362. if (i == bytes.Length - 1)
  363. {
  364. strB.Append(bytes[i]);
  365. }
  366. else
  367. {
  368. strB.Append(bytes[i] + " ");
  369. }
  370. }
  371. return strB.ToString();
  372. }
  373. public static void CompileDic(Transform tra, Dictionary<string, Transform> dic, bool enableIgnore = true)
  374. {
  375. Transform[] transforms = tra.GetComponentsInChildren<Transform>(true);
  376. for (int i = 0; i < transforms.Length; i++)
  377. {
  378. if (enableIgnore)
  379. {
  380. if (transforms[i].GetComponent<IgnoreIndexing>())
  381. {
  382. continue;
  383. }
  384. }
  385. if (dic.ContainsKey(transforms[i].name))
  386. {
  387. throw new Exception(transforms[i].name);
  388. }
  389. else
  390. {
  391. dic.Add(transforms[i].name, transforms[i]);
  392. }
  393. }
  394. }
  395. public static string GetUnit(int value, Unit unit)
  396. {
  397. if (unit == Unit.Second)
  398. {
  399. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  400. {
  401. if (value == 0 || value == 1)
  402. {
  403. return " Second";
  404. }
  405. else
  406. {
  407. return " Seconds";
  408. }
  409. }
  410. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  411. {
  412. return "秒";
  413. }
  414. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  415. {
  416. return "秒";
  417. }
  418. else
  419. {
  420. throw new Exception();
  421. }
  422. }
  423. else
  424. {
  425. throw new Exception();
  426. }
  427. }
  428. public static string GetStreamPath()
  429. {
  430. if (Application.isEditor)
  431. {
  432. return "file://" + Application.streamingAssetsPath;
  433. }
  434. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  435. {
  436. return "file://" + Application.streamingAssetsPath;
  437. }
  438. else if (Application.isMobilePlatform)
  439. {
  440. return Application.streamingAssetsPath;
  441. }
  442. else
  443. {
  444. throw new Exception();
  445. }
  446. }
  447. public Coroutine DelayCall(UnityAction function, int frame)
  448. {
  449. return StartCoroutine(IDelayCall(function, frame));
  450. }
  451. public Coroutine DelayCall(UnityAction function, float time)
  452. {
  453. return StartCoroutine(IDelayCall(function, time));
  454. }
  455. public static IEnumerator IDelayCall(UnityAction function, int frame)
  456. {
  457. int count = 0;
  458. while (count < frame)
  459. {
  460. count++;
  461. yield return null;
  462. }
  463. function.Invoke();
  464. }
  465. public static IEnumerator IDelayCall(UnityAction function, float time)
  466. {
  467. yield return new WaitForSeconds(time);
  468. function.Invoke();
  469. }
  470. public static string FmlParse1(string str)
  471. {
  472. int index = 0;
  473. int openIndex = 0;
  474. bool flag = false;
  475. bool group = false;
  476. for (int i = 0; i < str.Length; i++)
  477. {
  478. if (group)
  479. {
  480. if (str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/')
  481. {
  482. str = str.Replace(openIndex, i - 1, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i - 1)));
  483. i = 0;
  484. group = false;
  485. }
  486. else if (i == str.Length - 1)
  487. {
  488. str = str.Replace(openIndex, i, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i)));
  489. break;
  490. }
  491. }
  492. else
  493. {
  494. if (str[i] == '+' || str[i] == '-')
  495. {
  496. flag = true;
  497. openIndex = i + 1;
  498. }
  499. else if (str[i] == '*' || str[i] == '/')
  500. {
  501. index = i;
  502. group = true;
  503. if (!flag)
  504. {
  505. openIndex = 0;
  506. }
  507. }
  508. }
  509. }
  510. group = false;
  511. for (int i = 0; i < str.Length; i++)
  512. {
  513. if (group)
  514. {
  515. if (str[i] == '+' || str[i] == '-')
  516. {
  517. str = str.Replace(0, i - 1, FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i - 1)));
  518. i = -1;
  519. group = false;
  520. }
  521. else if (i == str.Length - 1)
  522. {
  523. return FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i));
  524. }
  525. }
  526. else
  527. {
  528. if (str[i] == '+' || str[i] == '-')
  529. {
  530. index = i;
  531. group = true;
  532. }
  533. }
  534. }
  535. return str;
  536. }
  537. public static string FmlParse2(char op, string str1, string str2)
  538. {
  539. double var1 = double.Parse(str1);
  540. double var2 = double.Parse(str2);
  541. if (op == '+')
  542. {
  543. return (var1 + var2).ToString("F7");
  544. }
  545. else if (op == '-')
  546. {
  547. return (var1 - var2).ToString("F7");
  548. }
  549. else if (op == '*')
  550. {
  551. return (var1 * var2).ToString("F7");
  552. }
  553. else if (op == '/')
  554. {
  555. return (var1 / var2).ToString("F7");
  556. }
  557. else
  558. {
  559. throw new Exception(op.ToString());
  560. }
  561. }
  562. public static double FmlParse(string str, params string[] strings)
  563. {
  564. for (int i = 0; i < strings.Length; i += 2)
  565. {
  566. if (str.Contains(strings[i]))
  567. {
  568. str = str.Replace(strings[i], strings[i + 1]);
  569. }
  570. else
  571. {
  572. //Debug.Log("No such var " + strings[i + 1]);
  573. }
  574. }
  575. int openIndex = 0;
  576. for (int i = 0; i < str.Length; i++)
  577. {
  578. if (str[i] == '(')
  579. {
  580. openIndex = i;
  581. }
  582. else if (str[i] == ')')
  583. {
  584. str = str.Replace(openIndex, i, FmlParse1(str.Between(openIndex + 1, i - 1)));
  585. i = -1;
  586. }
  587. }
  588. return double.Parse(FmlParse1(str));
  589. }
  590. public static string OmitNumberStr(int accuray, string str)
  591. {
  592. int index = str.IndexOf('.');
  593. if (index == -1)
  594. {
  595. return str;
  596. }
  597. if (accuray == 0)
  598. {
  599. return str.Substring(0, index);
  600. }
  601. else
  602. {
  603. for (int i = index + 1; i < index + accuray + 1; i++)
  604. {
  605. if (str[i] != '0')
  606. {
  607. return str.Substring(0, index + accuray + 1);
  608. }
  609. }
  610. return str.Substring(0, index);
  611. }
  612. }
  613. public static double ShrinkNumber(double value, int accuracy = 1)
  614. {
  615. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  616. {
  617. if (value < Amount.千)
  618. {
  619. return value;
  620. }
  621. else if (value < Amount.百万)
  622. {
  623. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  624. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千;
  625. }
  626. else if (value < Amount.十亿)
  627. {
  628. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  629. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.百万;
  630. }
  631. else if (value < Amount.兆)
  632. {
  633. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  634. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.十亿;
  635. }
  636. else if (value < Amount.千兆)
  637. {
  638. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  639. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
  640. }
  641. else
  642. {
  643. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  644. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千兆;
  645. }
  646. }
  647. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified || LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  648. {
  649. if (value < Amount.万)
  650. {
  651. return value;
  652. }
  653. else if (value < Amount.千万)
  654. {
  655. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  656. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.万;
  657. }
  658. else if (value < Amount.亿)
  659. {
  660. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  661. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千万;
  662. }
  663. else if (value < Amount.千亿)
  664. {
  665. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  666. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.亿;
  667. }
  668. else if (value < Amount.兆)
  669. {
  670. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  671. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千亿;
  672. }
  673. else if (value < Amount.千兆)
  674. {
  675. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  676. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
  677. }
  678. else if (value < Amount.京)
  679. {
  680. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  681. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千兆;
  682. }
  683. else if (value < Amount.千京)
  684. {
  685. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  686. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.京;
  687. }
  688. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  689. {
  690. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  691. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千京;
  692. }
  693. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  694. {
  695. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  696. return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10;
  697. }
  698. else
  699. {
  700. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  701. return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10000;
  702. }
  703. }
  704. else
  705. {
  706. throw new Exception();
  707. }
  708. }
  709. public static string ShrinkBigNumberStr(double value, int accuracy = 1)
  710. {
  711. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  712. {
  713. if (value < Amount.千)
  714. {
  715. return value.ToString("0");
  716. }
  717. else if (value < Amount.百万)
  718. {
  719. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  720. return OmitNumberStr(accuracy, str) + "K";
  721. }
  722. else if (value < Amount.十亿)
  723. {
  724. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  725. return OmitNumberStr(accuracy, str) + "M";
  726. }
  727. else if (value < Amount.兆)
  728. {
  729. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  730. return OmitNumberStr(accuracy, str) + "B";
  731. }
  732. else if (value < Amount.千兆)
  733. {
  734. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  735. return OmitNumberStr(accuracy, str) + "T";
  736. }
  737. else
  738. {
  739. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  740. return OmitNumberStr(accuracy, str) + "T";
  741. }
  742. }
  743. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  744. {
  745. if (value < Amount.万)
  746. {
  747. return value.ToString("0");
  748. }
  749. else if (value < Amount.千万)
  750. {
  751. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  752. return OmitNumberStr(accuracy, str) + "万";
  753. }
  754. else if (value < Amount.亿)
  755. {
  756. string str = (value/Amount.千万).ToString("F" + (accuracy + 1));
  757. return OmitNumberStr(accuracy, str) + "千万";
  758. }
  759. else if (value < Amount.千亿)
  760. {
  761. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  762. return OmitNumberStr(accuracy, str) + "亿";
  763. }
  764. else if (value < Amount.兆)
  765. {
  766. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  767. return OmitNumberStr(accuracy, str) + "千亿";
  768. }
  769. else if (value < Amount.千兆)
  770. {
  771. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  772. return OmitNumberStr(accuracy, str) + "兆";
  773. }
  774. else if (value < Amount.京)
  775. {
  776. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  777. return OmitNumberStr(accuracy, str) + "千兆";
  778. }
  779. else if (value < Amount.千京)
  780. {
  781. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  782. return OmitNumberStr(accuracy, str) + "京";
  783. }
  784. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  785. {
  786. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  787. return OmitNumberStr(accuracy, str) + "千京";
  788. }
  789. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  790. {
  791. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  792. return OmitNumberStr(0, str) + "垓";
  793. }
  794. else
  795. {
  796. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  797. return OmitNumberStr(0, str) + "千垓";
  798. }
  799. }
  800. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  801. {
  802. if (value < Amount.万)
  803. {
  804. return value.ToString("0");
  805. }
  806. else if (value < Amount.千万)
  807. {
  808. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  809. return OmitNumberStr(accuracy, str) + "萬";
  810. }
  811. else if (value < Amount.亿)
  812. {
  813. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  814. return OmitNumberStr(accuracy, str) + "千萬";
  815. }
  816. else if (value < Amount.千亿)
  817. {
  818. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  819. return OmitNumberStr(accuracy, str) + "億";
  820. }
  821. else if (value < Amount.兆)
  822. {
  823. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  824. return OmitNumberStr(accuracy, str) + "千億";
  825. }
  826. else if (value < Amount.千兆)
  827. {
  828. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  829. return OmitNumberStr(accuracy, str) + "兆";
  830. }
  831. else if (value < Amount.京)
  832. {
  833. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  834. return OmitNumberStr(accuracy, str) + "千兆";
  835. }
  836. else if (value < Amount.千京)
  837. {
  838. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  839. return OmitNumberStr(accuracy, str) + "京";
  840. }
  841. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  842. {
  843. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  844. return OmitNumberStr(accuracy, str) + "千京";
  845. }
  846. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  847. {
  848. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  849. return OmitNumberStr(0, str) + "垓";
  850. }
  851. else
  852. {
  853. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  854. return OmitNumberStr(0, str) + "千垓";
  855. }
  856. }
  857. else
  858. {
  859. throw new Exception();
  860. }
  861. }
  862. public static string ShrinkAllNumberStr(double value, int accuracy = 1)
  863. {
  864. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  865. {
  866. if (value < Amount.千)
  867. {
  868. return value.ToString("F" + accuracy);
  869. }
  870. else if (value < Amount.百万)
  871. {
  872. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  873. return OmitNumberStr(accuracy, str) + "K";
  874. }
  875. else if (value < Amount.十亿)
  876. {
  877. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  878. return OmitNumberStr(accuracy, str) + "M";
  879. }
  880. else if (value < Amount.兆)
  881. {
  882. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  883. return OmitNumberStr(accuracy, str) + "B";
  884. }
  885. else if (value < Amount.千兆)
  886. {
  887. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  888. return OmitNumberStr(accuracy, str) + "T";
  889. }
  890. else
  891. {
  892. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  893. return OmitNumberStr(accuracy, str) + "T";
  894. }
  895. }
  896. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  897. {
  898. if (value < Amount.万)
  899. {
  900. return value.ToString("F" + accuracy);
  901. }
  902. else if (value < Amount.千万)
  903. {
  904. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  905. return OmitNumberStr(accuracy, str) + "万";
  906. }
  907. else if (value < Amount.亿)
  908. {
  909. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  910. return OmitNumberStr(accuracy, str) + "千万";
  911. }
  912. else if (value < Amount.千亿)
  913. {
  914. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  915. return OmitNumberStr(accuracy, str) + "亿";
  916. }
  917. else if (value < Amount.兆)
  918. {
  919. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  920. return OmitNumberStr(accuracy, str) + "千亿";
  921. }
  922. else if (value < Amount.千兆)
  923. {
  924. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  925. return OmitNumberStr(accuracy, str) + "兆";
  926. }
  927. else if (value < Amount.京)
  928. {
  929. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  930. return OmitNumberStr(accuracy, str) + "千兆";
  931. }
  932. else if (value < Amount.千京)
  933. {
  934. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  935. return OmitNumberStr(accuracy, str) + "京";
  936. }
  937. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  938. {
  939. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  940. return OmitNumberStr(accuracy, str) + "千京";
  941. }
  942. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  943. {
  944. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  945. return OmitNumberStr(0, str) + "垓";
  946. }
  947. else
  948. {
  949. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  950. return OmitNumberStr(0, str) + "千垓";
  951. }
  952. }
  953. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  954. {
  955. if (value < Amount.万)
  956. {
  957. return value.ToString("F" + accuracy);
  958. }
  959. else if (value < Amount.千万)
  960. {
  961. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  962. return OmitNumberStr(accuracy, str) + "萬";
  963. }
  964. else if (value < Amount.亿)
  965. {
  966. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  967. return OmitNumberStr(accuracy, str) + "千萬";
  968. }
  969. else if (value < Amount.千亿)
  970. {
  971. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  972. return OmitNumberStr(accuracy, str) + "億";
  973. }
  974. else if (value < Amount.兆)
  975. {
  976. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  977. return OmitNumberStr(accuracy, str) + "千億";
  978. }
  979. else if (value < Amount.千兆)
  980. {
  981. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  982. return OmitNumberStr(accuracy, str) + "兆";
  983. }
  984. else if (value < Amount.京)
  985. {
  986. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  987. return OmitNumberStr(accuracy, str) + "千兆";
  988. }
  989. else if (value < Amount.千京)
  990. {
  991. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  992. return OmitNumberStr(accuracy, str) + "京";
  993. }
  994. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  995. {
  996. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  997. return OmitNumberStr(accuracy, str) + "千京";
  998. }
  999. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  1000. {
  1001. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  1002. return OmitNumberStr(0, str) + "垓";
  1003. }
  1004. else
  1005. {
  1006. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  1007. return OmitNumberStr(0, str) + "千垓";
  1008. }
  1009. }
  1010. else
  1011. {
  1012. throw new Exception();
  1013. }
  1014. }
  1015. public static string ImageParse(Current current)
  1016. {
  1017. if (current == Current.Coin)
  1018. {
  1019. return TransferLabel.CoinSprite;
  1020. }
  1021. else if (current == Current.Diamond)
  1022. {
  1023. return TransferLabel.DiamondSprite;
  1024. }
  1025. else if (current == Current.Cash)
  1026. {
  1027. return Language.GetStr(LanguageLabel.Common__Cash);
  1028. }
  1029. else
  1030. {
  1031. throw new Exception(current.ToString());
  1032. }
  1033. }
  1034. public static Current CurrentParse(string str)
  1035. {
  1036. if (string.IsNullOrEmpty(str))
  1037. {
  1038. return Current.Free;
  1039. }
  1040. else
  1041. {
  1042. int number = int.Parse(str);
  1043. if (number == 1)
  1044. {
  1045. return Current.Coin;
  1046. }
  1047. else if (number == 2)
  1048. {
  1049. return Current.Diamond;
  1050. }
  1051. else if (number == 3)
  1052. {
  1053. return Current.Cash;
  1054. }
  1055. else if (number == 4)
  1056. {
  1057. return Current.Other;
  1058. }
  1059. else if (number == 5)
  1060. {
  1061. return Current.AD;
  1062. }
  1063. else
  1064. {
  1065. throw new Exception(number.ToString());
  1066. }
  1067. }
  1068. }
  1069. public static int StringToInt(string str, int defaultValue)
  1070. {
  1071. if (string.IsNullOrEmpty(str))
  1072. {
  1073. return defaultValue;
  1074. }
  1075. else
  1076. {
  1077. return int.Parse(str);
  1078. }
  1079. }
  1080. public static long StringToLong(string str, long defaultValue)
  1081. {
  1082. if (string.IsNullOrEmpty(str))
  1083. {
  1084. return defaultValue;
  1085. }
  1086. else
  1087. {
  1088. return long.Parse(str);
  1089. }
  1090. }
  1091. public static bool StringToBool(string str, bool defaultValue)
  1092. {
  1093. if (string.IsNullOrEmpty(str))
  1094. {
  1095. return defaultValue;
  1096. }
  1097. else
  1098. {
  1099. return Convert.ToBoolean(int.Parse(str));
  1100. }
  1101. }
  1102. public static float StringToFloat(string str, float defaultValue)
  1103. {
  1104. if (string.IsNullOrEmpty(str))
  1105. {
  1106. return defaultValue;
  1107. }
  1108. else
  1109. {
  1110. return float.Parse(str);
  1111. }
  1112. }
  1113. public static double StringToDouble(string str, double defaultValue)
  1114. {
  1115. if (string.IsNullOrEmpty(str))
  1116. {
  1117. return defaultValue;
  1118. }
  1119. else
  1120. {
  1121. return float.Parse(str);
  1122. }
  1123. }
  1124. public static Vector3 StringToVector(char seperateChar, string str, Vector3 defaultValue)
  1125. {
  1126. if (string.IsNullOrEmpty(str))
  1127. {
  1128. return defaultValue;
  1129. }
  1130. else
  1131. {
  1132. string[] strings = str.Split(seperateChar);
  1133. if (strings.Length == 2)
  1134. {
  1135. Vector2 result = new Vector2();
  1136. result.x = float.Parse(strings[0]);
  1137. result.y = float.Parse(strings[1]);
  1138. return result;
  1139. }
  1140. else if (strings.Length == 3)
  1141. {
  1142. Vector3 result = new Vector3();
  1143. result.x = float.Parse(strings[0]);
  1144. result.y = float.Parse(strings[1]);
  1145. result.z = float.Parse(strings[2]);
  1146. return result;
  1147. }
  1148. else
  1149. {
  1150. Debug.Log(str);
  1151. throw new Exception();
  1152. }
  1153. }
  1154. }
  1155. public static List<int> StringToInts(char seperateChar, string str, List<int> defaultValue)
  1156. {
  1157. if (string.IsNullOrEmpty(str))
  1158. {
  1159. return defaultValue;
  1160. }
  1161. else
  1162. {
  1163. string[] strings = str.Split(seperateChar);
  1164. List<int> list = new List<int>();
  1165. for (int i = 0; i < strings.Length; i++)
  1166. {
  1167. list.Add(int.Parse(strings[i]));
  1168. }
  1169. return list;
  1170. }
  1171. }
  1172. public static List<string> StringToStrings(char seperateChar, string str, List<string> defaultValue)
  1173. {
  1174. if (string.IsNullOrEmpty(str))
  1175. {
  1176. return defaultValue;
  1177. }
  1178. else
  1179. {
  1180. string[] strings = str.Split(seperateChar);
  1181. List<string> list = new List<string>();
  1182. for (int i = 0; i < strings.Length; i++)
  1183. {
  1184. list.Add(strings[i]);
  1185. }
  1186. return list;
  1187. }
  1188. }
  1189. public static List<double> StringToDoubles(char seperateChar, string str, List<double> defaultValue)
  1190. {
  1191. if (string.IsNullOrEmpty(str))
  1192. {
  1193. return defaultValue;
  1194. }
  1195. else
  1196. {
  1197. string[] strings = str.Split(seperateChar);
  1198. List<double> list = new List<double>();
  1199. for (int i = 0; i < strings.Length; i++)
  1200. {
  1201. list.Add(double.Parse(strings[i]));
  1202. }
  1203. return list;
  1204. }
  1205. }
  1206. public static List<int> StartEndIndexToInts(int startIndex, int endIndex)
  1207. {
  1208. List<int> ints = new List<int>();
  1209. for (int i = startIndex; i <= endIndex; i++)
  1210. {
  1211. ints.Add(i);
  1212. }
  1213. return ints;
  1214. }
  1215. public static string IntsToString(List<int> ints)
  1216. {
  1217. StringBuilder stringBuilder = new StringBuilder();
  1218. for (int i = 0; i < ints.Count; i++)
  1219. {
  1220. stringBuilder.Append(ints[i] + " ");
  1221. }
  1222. return stringBuilder.ToString();
  1223. }
  1224. }