Auxiliary.cs 30 KB

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