Auxiliary.cs 42 KB

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