Auxiliary.cs 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. using LitJson;
  2. using MiniJSON;
  3. using ScottGarland;
  4. using DragonBones;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using UnityEngine.Events;
  8. using UnityEngine.Advertisements;
  9. using System;
  10. using System.IO;
  11. using System.Xml;
  12. using System.Linq;
  13. using System.Net.Mail;
  14. using System.Net;
  15. using System.Text;
  16. using System.Collections;
  17. using System.Diagnostics;
  18. using System.Collections.Generic;
  19. using System.ComponentModel.Design;
  20. using System.Security.Cryptography;
  21. using System.Runtime.Serialization.Formatters.Binary;
  22. using System.Security;
  23. using System.Text.RegularExpressions;
  24. using System.Security.Cryptography.Xml;
  25. using Sfs2X.Entities.Data;
  26. using Sfs2X.Requests;
  27. using Debug = UnityEngine.Debug;
  28. using Random = UnityEngine.Random;
  29. using Transform = UnityEngine.Transform;
  30. public enum Unit
  31. {
  32. Second
  33. }
  34. public class Amount
  35. {
  36. public static double 百 = 100;
  37. public static double 千 = 1000;
  38. public static double 万 = 10000;
  39. public static double 十万 = 100000;
  40. public static double 百万 = 1000000;
  41. public static double 千万 = 10000000;
  42. public static double 亿 = 100000000;
  43. public static double 十亿 = 1000000000;
  44. public static double 千亿 = 100000000000;
  45. public static double 兆 = 1000000000000;
  46. public static double 千兆 = 1000000000000000;
  47. public static double 京 = 10000000000000000;
  48. public static double 千京 = 10000000000000000000;
  49. public static BigInteger 垓 = new BigInteger("100000000000000000000");
  50. public static BigInteger 千垓 = new BigInteger("100000000000000000000000");
  51. }
  52. public class Auxiliary : Regist
  53. {
  54. #region Config
  55. public string String1;
  56. public string String2;
  57. public Sprite Sprite;
  58. public TextAsset TextAsset;
  59. public Texture2D Texture;
  60. public Texture2D Texture1;
  61. public Texture2D Texture2;
  62. public AnimationClip AnimationClip;
  63. public Font Font;
  64. public GameObject Go;
  65. public List<Sprite> Sprites;
  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. // SFSManager.GardenSmartFox.SmartFox.Disconnect();
  119. // RobotManager.DeactivateAllRobots(false);
  120. //}
  121. //if (Input.GetKeyDown(KeyCode.Space))
  122. //{
  123. // Debug.Log(ConfigManager.ConfigRootNode.OuterXml);
  124. // //DebugManager.ResetGardenLevel(7);
  125. // //DebugManager.ResetVisitTutorial();
  126. // //HttpManager.GetThanksGiftInfo(RechargeGiftManager.Init, () => Bubble.Show(null, Language.GetStr(LanguageLabel.UI__GetThanksGiftInfoFailed)));
  127. //}
  128. //if (Input.GetKeyDown(KeyCode.A))
  129. //{
  130. // DebugManager.ResetGardenLevel(30);
  131. //}
  132. //if (Input.GetKeyDown(KeyCode.S))
  133. //{
  134. // Manager.Coin = 0;
  135. // Manager.Diamond = 0;
  136. //}
  137. //if (Input.GetKeyDown(KeyCode.D))
  138. //{
  139. // Manager.Coin = 100000;
  140. // Manager.Diamond = 1000;
  141. //}
  142. //if (Input.GetKeyDown(KeyCode.Z))
  143. //{
  144. // Manager.MinigameCDTimer = 0;
  145. //}
  146. //if (Input.GetKeyDown(KeyCode.X))
  147. //{
  148. // MiniGameManager.GameTimer = 45;
  149. //}
  150. //if (Input.GetKeyDown(KeyCode.C))
  151. //{
  152. // DebugManager.ResetAbilityAnim();
  153. //}
  154. //if (Input.GetKeyDown(KeyCode.V))
  155. //{
  156. // AccountData accountData = new AccountData("测试名字", "1710065808151506837", DateTime.Now.ToString());
  157. // MessagePanel.OpenPanel(accountData);
  158. //}
  159. //if (Input.GetKeyDown(KeyCode.B))
  160. //{
  161. // ManaPlayer.Player.PlayAnim("newAnimation3");
  162. // ManaPlayer.Player.Flip(PlayerDirection.Left);
  163. // foreach (var VARIABLE in ManaPlayer.CloseUnitDic)
  164. // {
  165. // VARIABLE.Value.Unlock();
  166. // }
  167. //}
  168. //if (Input.GetKeyDown(KeyCode.M))
  169. //{
  170. // ManaReso.Get(PrefabLabel.G_Flower).SetActive(false);
  171. // Debug.Log(ManaGarden.Slot);
  172. //}
  173. //if (Input.GetKeyDown(KeyCode.N))
  174. //{
  175. // ManaCenter.Coin = 0;
  176. // ManaCenter.Diamond = 0;
  177. // foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
  178. // {
  179. // VARIABLE.Value.Unlock = true;
  180. // }
  181. // foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
  182. // {
  183. // VARIABLE.Value.Unlock = false;
  184. // }
  185. // ManaGarden.FlowerInfoDic.First().Value.Unlock = true;
  186. //}
  187. //if (Input.GetKeyDown(KeyCode.P))
  188. //{
  189. // ManaData.Level += 20;
  190. //}
  191. //if (Input.GetKeyDown(KeyCode.O))
  192. //{
  193. // for (int i = 0; i < ManaCenter.CoolList.Count; i++)
  194. // {
  195. // ManaCenter.CoolList[i].CoolTimer = 0;
  196. // }
  197. //}
  198. //if (Input.GetKeyDown(KeyCode.I))
  199. //{
  200. // ManaCenter.Coin += 1000;
  201. // ManaCenter.Diamond += 1000;
  202. //}
  203. //if (Input.GetKeyDown(KeyCode.U))
  204. //{
  205. // Data.SavePlayerConfig();
  206. // Data.SaveXml();
  207. //}
  208. //if (Input.GetKeyDown(KeyCode.Y))
  209. //{
  210. // Data.ResetPlayerConfig();
  211. // Data.SaveXml();
  212. //}
  213. //if (Input.GetKeyDown(KeyCode.T))
  214. //{
  215. // ManaData.Pause = !ManaData.Pause;
  216. //}
  217. #endregion
  218. #region 输入检测
  219. if (Input.GetKeyDown(KeyCode.Escape))
  220. {
  221. MiniGameManager.Pause = true;
  222. Bubble.Show(Language.GetStr(LanguageLabel.Common__QuitGame), null, null, null, Application.Quit, () => { MiniGameManager.Pause = false; });
  223. }
  224. if (AnyKeyUp)
  225. {
  226. if (Input.anyKey == false)
  227. {
  228. AnyKeyUp = false;
  229. }
  230. }
  231. if (Input.anyKeyDown)
  232. {
  233. AnyKeyDown = true;
  234. }
  235. if (AnyKeyDown)
  236. {
  237. if (Input.anyKey == false)
  238. {
  239. AnyKeyUp = true;
  240. AnyKeyDown = false;
  241. }
  242. }
  243. #endregion
  244. }
  245. private static void ResetAllCd()
  246. {
  247. for (int i = 0; i < Manager.CoolSkillList.Count; i++)
  248. {
  249. Manager.CoolSkillList[i].CoolTimer = 0;
  250. }
  251. }
  252. public static byte[] GetMD5(object obj)
  253. {
  254. MemoryStream memoryStream = new MemoryStream();
  255. BinaryFormatter binaryFormatter = new BinaryFormatter();
  256. binaryFormatter.Serialize(memoryStream, obj);
  257. byte[] bytes = memoryStream.GetBuffer();
  258. memoryStream.Dispose();
  259. return MD5.ComputeHash(bytes);
  260. }
  261. public static void EncryptXml(XmlDocument doc)
  262. {
  263. EncryptedXml encryptedXml = new EncryptedXml();
  264. XmlElement xmlElement = doc.DocumentElement;
  265. byte[] bytes = encryptedXml.EncryptData(xmlElement, Des, false);
  266. EncryptedData encryptedData = new EncryptedData();
  267. encryptedData.Type = EncryptedXml.XmlEncElementUrl;
  268. encryptedData.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncDESUrl);
  269. encryptedData.CipherData.CipherValue = bytes;
  270. EncryptedXml.ReplaceElement(xmlElement, encryptedData, false);
  271. }
  272. public static void DecryptXml(XmlDocument doc)
  273. {
  274. EncryptedXml encryptedXml = new EncryptedXml();
  275. XmlElement encryptXmlElement = (XmlElement)doc.GetElementsByTagName("EncryptedData")[0];
  276. EncryptedData encryptedData = new EncryptedData();
  277. encryptedData.LoadXml(encryptXmlElement);
  278. byte[] bytes = encryptedXml.DecryptData(encryptedData, Des);
  279. encryptedXml.ReplaceData(encryptXmlElement, bytes);
  280. }
  281. public static byte[] Encrypt(string str)
  282. {
  283. byte[] bytes = Encoding.UTF8.GetBytes(str);
  284. byte[] encryptBytes = Des.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length);
  285. return encryptBytes;
  286. }
  287. public static byte[] ToBytes(string str)
  288. {
  289. string[] strings = str.Split(' ');
  290. byte[] bytes = new byte[strings.Length];
  291. for (int i = 0; i < bytes.Length; i++)
  292. {
  293. bytes[i] = byte.Parse(strings[i]);
  294. }
  295. return bytes;
  296. }
  297. public static string Decrypt(string str)
  298. {
  299. byte[] encryptBytes = ToBytes(str);
  300. byte[] decryptBytes = Des.CreateDecryptor().TransformFinalBlock(encryptBytes, 0, encryptBytes.Length);
  301. return Encoding.UTF8.GetString(decryptBytes);
  302. }
  303. public static string ToString(byte[] bytes)
  304. {
  305. StringBuilder strB = new StringBuilder();
  306. for (int i = 0; i < bytes.Length; i++)
  307. {
  308. if (i == bytes.Length - 1)
  309. {
  310. strB.Append(bytes[i]);
  311. }
  312. else
  313. {
  314. strB.Append(bytes[i] + " ");
  315. }
  316. }
  317. return strB.ToString();
  318. }
  319. public static void CompileDic(Transform tra, Dictionary<string, Transform> dic, bool enableIgnore = true)
  320. {
  321. Transform[] transforms = tra.GetComponentsInChildren<Transform>(true);
  322. for (int i = 0; i < transforms.Length; i++)
  323. {
  324. if (enableIgnore)
  325. {
  326. if (transforms[i].GetComponent<IgnoreIndexing>())
  327. {
  328. continue;
  329. }
  330. }
  331. if (dic.ContainsKey(transforms[i].name))
  332. {
  333. throw new Exception(transforms[i].name);
  334. }
  335. else
  336. {
  337. dic.Add(transforms[i].name, transforms[i]);
  338. }
  339. }
  340. }
  341. public static string GetUnit(int value, Unit unit)
  342. {
  343. if (unit == Unit.Second)
  344. {
  345. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  346. {
  347. if (value == 0 || value == 1)
  348. {
  349. return " Second";
  350. }
  351. else
  352. {
  353. return " Seconds";
  354. }
  355. }
  356. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  357. {
  358. return "秒";
  359. }
  360. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  361. {
  362. return "秒";
  363. }
  364. else
  365. {
  366. throw new Exception();
  367. }
  368. }
  369. else
  370. {
  371. throw new Exception();
  372. }
  373. }
  374. public static string GetStreamPath()
  375. {
  376. if (Application.isEditor)
  377. {
  378. return "file://" + Application.streamingAssetsPath;
  379. }
  380. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  381. {
  382. return "file://" + Application.streamingAssetsPath;
  383. }
  384. else if (Application.isMobilePlatform)
  385. {
  386. return Application.streamingAssetsPath;
  387. }
  388. else
  389. {
  390. throw new Exception();
  391. }
  392. }
  393. public Coroutine DelayCall(UnityAction function, int frame)
  394. {
  395. return StartCoroutine(IDelayCall(function, frame));
  396. }
  397. public Coroutine DelayCall(UnityAction function, float time)
  398. {
  399. return StartCoroutine(IDelayCall(function, time));
  400. }
  401. public static IEnumerator IDelayCall(UnityAction function, int frame)
  402. {
  403. int count = 0;
  404. while (count < frame)
  405. {
  406. count++;
  407. yield return null;
  408. }
  409. function.Invoke();
  410. }
  411. public static IEnumerator IDelayCall(UnityAction function, float time)
  412. {
  413. yield return new WaitForSeconds(time);
  414. function.Invoke();
  415. }
  416. public static string FmlParse1(string str)
  417. {
  418. int index = 0;
  419. int openIndex = 0;
  420. bool flag = false;
  421. bool group = false;
  422. for (int i = 0; i < str.Length; i++)
  423. {
  424. if (group)
  425. {
  426. if (str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/')
  427. {
  428. str = str.Replace(openIndex, i - 1, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i - 1)));
  429. i = 0;
  430. group = false;
  431. }
  432. else if (i == str.Length - 1)
  433. {
  434. str = str.Replace(openIndex, i, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i)));
  435. break;
  436. }
  437. }
  438. else
  439. {
  440. if (str[i] == '+' || str[i] == '-')
  441. {
  442. flag = true;
  443. openIndex = i + 1;
  444. }
  445. else if (str[i] == '*' || str[i] == '/')
  446. {
  447. index = i;
  448. group = true;
  449. if (!flag)
  450. {
  451. openIndex = 0;
  452. }
  453. }
  454. }
  455. }
  456. group = false;
  457. for (int i = 0; i < str.Length; i++)
  458. {
  459. if (group)
  460. {
  461. if (str[i] == '+' || str[i] == '-')
  462. {
  463. str = str.Replace(0, i - 1, FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i - 1)));
  464. i = -1;
  465. group = false;
  466. }
  467. else if (i == str.Length - 1)
  468. {
  469. return FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i));
  470. }
  471. }
  472. else
  473. {
  474. if (str[i] == '+' || str[i] == '-')
  475. {
  476. index = i;
  477. group = true;
  478. }
  479. }
  480. }
  481. return str;
  482. }
  483. public static string FmlParse2(char op, string str1, string str2)
  484. {
  485. double var1 = double.Parse(str1);
  486. double var2 = double.Parse(str2);
  487. if (op == '+')
  488. {
  489. return (var1 + var2).ToString();
  490. }
  491. else if (op == '-')
  492. {
  493. return (var1 - var2).ToString();
  494. }
  495. else if (op == '*')
  496. {
  497. return (var1 * var2).ToString();
  498. }
  499. else if (op == '/')
  500. {
  501. return (var1 / var2).ToString();
  502. }
  503. else
  504. {
  505. throw new Exception(op.ToString());
  506. }
  507. }
  508. public static double FmlParse(string str, params string[] strings)
  509. {
  510. for (int i = 0; i < strings.Length; i += 2)
  511. {
  512. if (str.Contains(strings[i]))
  513. {
  514. str = str.Replace(strings[i], strings[i + 1]);
  515. }
  516. else
  517. {
  518. //Debug.Log("No such var " + strings[i + 1]);
  519. }
  520. }
  521. int openIndex = 0;
  522. for (int i = 0; i < str.Length; i++)
  523. {
  524. if (str[i] == '(')
  525. {
  526. openIndex = i;
  527. }
  528. else if (str[i] == ')')
  529. {
  530. str = str.Replace(openIndex, i, FmlParse1(str.Between(openIndex + 1, i - 1)));
  531. i = -1;
  532. }
  533. }
  534. return double.Parse(FmlParse1(str));
  535. }
  536. public static string OmitNumberStr(int accuray, string str)
  537. {
  538. int index = str.IndexOf('.');
  539. if (index == -1)
  540. {
  541. return str;
  542. }
  543. if (accuray == 0)
  544. {
  545. return str.Substring(0, index);
  546. }
  547. else
  548. {
  549. for (int i = index + 1; i < index + accuray + 1; i++)
  550. {
  551. if (str[i] != '0')
  552. {
  553. return str.Substring(0, index + accuray + 1);
  554. }
  555. }
  556. return str.Substring(0, index);
  557. }
  558. }
  559. public static double ShrinkNumber(double value, int accuracy = 1)
  560. {
  561. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  562. {
  563. if (value < Amount.千)
  564. {
  565. return value;
  566. }
  567. else if (value < Amount.百万)
  568. {
  569. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  570. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千;
  571. }
  572. else if (value < Amount.十亿)
  573. {
  574. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  575. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.百万;
  576. }
  577. else if (value < Amount.兆)
  578. {
  579. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  580. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.十亿;
  581. }
  582. else if (value < Amount.千兆)
  583. {
  584. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  585. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
  586. }
  587. else
  588. {
  589. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  590. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千兆;
  591. }
  592. }
  593. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified || LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  594. {
  595. if (value < Amount.万)
  596. {
  597. return value;
  598. }
  599. else if (value < Amount.千万)
  600. {
  601. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  602. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.万;
  603. }
  604. else if (value < Amount.亿)
  605. {
  606. string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
  607. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千万;
  608. }
  609. else if (value < Amount.千亿)
  610. {
  611. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  612. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.亿;
  613. }
  614. else if (value < Amount.兆)
  615. {
  616. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  617. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千亿;
  618. }
  619. else if (value < Amount.千兆)
  620. {
  621. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  622. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
  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 (new BigInteger(value.ToString("0")) < Amount.垓)
  635. {
  636. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  637. return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千京;
  638. }
  639. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  640. {
  641. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  642. return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10;
  643. }
  644. else
  645. {
  646. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  647. return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10000;
  648. }
  649. }
  650. else
  651. {
  652. throw new Exception();
  653. }
  654. }
  655. public static string ShrinkNumberStr(double value, int accuracy = 1)
  656. {
  657. if (LanguageManager.CurrentLanguage == CurrentLanguage.English)
  658. {
  659. if (value < Amount.千)
  660. {
  661. return value.ToString("0");
  662. }
  663. else if (value < Amount.百万)
  664. {
  665. string str = (value / Amount.千).ToString("F" + (accuracy + 1));
  666. return OmitNumberStr(accuracy, str) + "K";
  667. }
  668. else if (value < Amount.十亿)
  669. {
  670. string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
  671. return OmitNumberStr(accuracy, str) + "M";
  672. }
  673. else if (value < Amount.兆)
  674. {
  675. string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
  676. return OmitNumberStr(accuracy, str) + "B";
  677. }
  678. else if (value < Amount.千兆)
  679. {
  680. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  681. return OmitNumberStr(accuracy, str) + "T";
  682. }
  683. else
  684. {
  685. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  686. return OmitNumberStr(accuracy, str) + "T";
  687. }
  688. }
  689. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseSimplified)
  690. {
  691. if (value < Amount.万)
  692. {
  693. return value.ToString("0");
  694. }
  695. else if (value < Amount.千万)
  696. {
  697. string str = (value / Amount.万).ToString("F" + (accuracy + 1));
  698. return OmitNumberStr(accuracy, str) + "万";
  699. }
  700. else if (value < Amount.亿)
  701. {
  702. string str = (value/Amount.千万).ToString("F" + (accuracy + 1));
  703. return OmitNumberStr(accuracy, str) + "千万";
  704. }
  705. else if (value < Amount.千亿)
  706. {
  707. string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
  708. return OmitNumberStr(accuracy, str) + "亿";
  709. }
  710. else if (value < Amount.兆)
  711. {
  712. string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
  713. return OmitNumberStr(accuracy, str) + "千亿";
  714. }
  715. else if (value < Amount.千兆)
  716. {
  717. string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
  718. return OmitNumberStr(accuracy, str) + "兆";
  719. }
  720. else if (value < Amount.京)
  721. {
  722. string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
  723. return OmitNumberStr(accuracy, str) + "千兆";
  724. }
  725. else if (value < Amount.千京)
  726. {
  727. string str = (value / Amount.京).ToString("F" + (accuracy + 1));
  728. return OmitNumberStr(accuracy, str) + "京";
  729. }
  730. else if (new BigInteger(value.ToString("0")) < Amount.垓)
  731. {
  732. string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
  733. return OmitNumberStr(accuracy, str) + "千京";
  734. }
  735. else if (new BigInteger(value.ToString("0")) < Amount.千垓)
  736. {
  737. string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
  738. return OmitNumberStr(0, str) + "垓";
  739. }
  740. else
  741. {
  742. string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
  743. return OmitNumberStr(0, str) + "千垓";
  744. }
  745. }
  746. else if (LanguageManager.CurrentLanguage == CurrentLanguage.ChineseTraditional)
  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
  804. {
  805. throw new Exception();
  806. }
  807. }
  808. public static string ImageParse(Current current)
  809. {
  810. if (current == Current.Coin)
  811. {
  812. return TransferLabel.CoinSprite;
  813. }
  814. else if (current == Current.Diamond)
  815. {
  816. return TransferLabel.DiamondSprite;
  817. }
  818. else if (current == Current.Cash)
  819. {
  820. return Language.GetStr(LanguageLabel.Common__Cash);
  821. }
  822. else
  823. {
  824. throw new Exception(current.ToString());
  825. }
  826. }
  827. public static Current CurrentParse(string str)
  828. {
  829. if (string.IsNullOrEmpty(str))
  830. {
  831. return Current.Free;
  832. }
  833. else
  834. {
  835. int number = int.Parse(str);
  836. if (number == 1)
  837. {
  838. return Current.Coin;
  839. }
  840. else if (number == 2)
  841. {
  842. return Current.Diamond;
  843. }
  844. else if (number == 3)
  845. {
  846. return Current.Cash;
  847. }
  848. else if (number == 4)
  849. {
  850. return Current.Other;
  851. }
  852. else if (number == 5)
  853. {
  854. return Current.AD;
  855. }
  856. else
  857. {
  858. throw new Exception(number.ToString());
  859. }
  860. }
  861. }
  862. public static int StringToInt(string str, int defaultValue)
  863. {
  864. if (string.IsNullOrEmpty(str))
  865. {
  866. return defaultValue;
  867. }
  868. else
  869. {
  870. return int.Parse(str);
  871. }
  872. }
  873. public static long StringToLong(string str, long defaultValue)
  874. {
  875. if (string.IsNullOrEmpty(str))
  876. {
  877. return defaultValue;
  878. }
  879. else
  880. {
  881. return long.Parse(str);
  882. }
  883. }
  884. public static bool StringToBool(string str, bool defaultValue)
  885. {
  886. if (string.IsNullOrEmpty(str))
  887. {
  888. return defaultValue;
  889. }
  890. else
  891. {
  892. return Convert.ToBoolean(int.Parse(str));
  893. }
  894. }
  895. public static float StringToFloat(string str, float defaultValue)
  896. {
  897. if (string.IsNullOrEmpty(str))
  898. {
  899. return defaultValue;
  900. }
  901. else
  902. {
  903. return float.Parse(str);
  904. }
  905. }
  906. public static double StringToDouble(string str, double defaultValue)
  907. {
  908. if (string.IsNullOrEmpty(str))
  909. {
  910. return defaultValue;
  911. }
  912. else
  913. {
  914. return float.Parse(str);
  915. }
  916. }
  917. public static Vector3 StringToVector(char seperateChar, string str, Vector3 defaultValue)
  918. {
  919. if (string.IsNullOrEmpty(str))
  920. {
  921. return defaultValue;
  922. }
  923. else
  924. {
  925. string[] strings = str.Split(seperateChar);
  926. if (strings.Length == 2)
  927. {
  928. Vector2 result = new Vector2();
  929. result.x = float.Parse(strings[0]);
  930. result.y = float.Parse(strings[1]);
  931. return result;
  932. }
  933. else if (strings.Length == 3)
  934. {
  935. Vector3 result = new Vector3();
  936. result.x = float.Parse(strings[0]);
  937. result.y = float.Parse(strings[1]);
  938. result.z = float.Parse(strings[2]);
  939. return result;
  940. }
  941. else
  942. {
  943. Debug.Log(str);
  944. throw new Exception();
  945. }
  946. }
  947. }
  948. public static List<int> StringToInts(char seperateChar, string str, List<int> defaultValue)
  949. {
  950. if (string.IsNullOrEmpty(str))
  951. {
  952. return defaultValue;
  953. }
  954. else
  955. {
  956. string[] strings = str.Split(seperateChar);
  957. List<int> list = new List<int>();
  958. for (int i = 0; i < strings.Length; i++)
  959. {
  960. list.Add(int.Parse(strings[i]));
  961. }
  962. return list;
  963. }
  964. }
  965. public static List<string> StringToStrings(char seperateChar, string str, List<string> defaultValue)
  966. {
  967. if (string.IsNullOrEmpty(str))
  968. {
  969. return defaultValue;
  970. }
  971. else
  972. {
  973. string[] strings = str.Split(seperateChar);
  974. List<string> list = new List<string>();
  975. for (int i = 0; i < strings.Length; i++)
  976. {
  977. list.Add(strings[i]);
  978. }
  979. return list;
  980. }
  981. }
  982. public static List<double> StringToDoubles(char seperateChar, string str, List<double> defaultValue)
  983. {
  984. if (string.IsNullOrEmpty(str))
  985. {
  986. return defaultValue;
  987. }
  988. else
  989. {
  990. string[] strings = str.Split(seperateChar);
  991. List<double> list = new List<double>();
  992. for (int i = 0; i < strings.Length; i++)
  993. {
  994. list.Add(double.Parse(strings[i]));
  995. }
  996. return list;
  997. }
  998. }
  999. public static List<int> StartEndIndexToInts(int startIndex, int endIndex)
  1000. {
  1001. List<int> ints = new List<int>();
  1002. for (int i = startIndex; i <= endIndex; i++)
  1003. {
  1004. ints.Add(i);
  1005. }
  1006. return ints;
  1007. }
  1008. public static string IntsToString(List<int> ints)
  1009. {
  1010. StringBuilder stringBuilder = new StringBuilder();
  1011. for (int i = 0; i < ints.Count; i++)
  1012. {
  1013. stringBuilder.Append(ints[i] + " ");
  1014. }
  1015. return stringBuilder.ToString();
  1016. }
  1017. }