Auxiliary.cs 42 KB

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