Auxiliary.cs 33 KB

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