Auxiliary.cs 42 KB

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