Auxiliary.cs 32 KB

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