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