Auxiliary.cs 32 KB

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