Auxiliary.cs 32 KB

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