123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164 |
- using LitJson;
- using MiniJSON;
- using ScottGarland;
- using DragonBones;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using UnityEngine.Advertisements;
- using System;
- using System.IO;
- using System.Xml;
- using System.Linq;
- using System.Net.Mail;
- using System.Net;
- using System.Text;
- using System.Collections;
- using System.Diagnostics;
- using System.Collections.Generic;
- using System.Security.Cryptography;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Security;
- using System.Text.RegularExpressions;
- using System.Security.Cryptography.Xml;
- using Debug = UnityEngine.Debug;
- using Random = UnityEngine.Random;
- using Transform = UnityEngine.Transform;
- public enum Unit
- {
- Second
- }
- public class Amount
- {
- public static double 百 = 100;
- public static double 千 = 1000;
- public static double 万 = 10000;
- public static double 十万 = 100000;
- public static double 百万 = 1000000;
- public static double 千万 = 10000000;
- public static double 亿 = 100000000;
- public static double 十亿 = 1000000000;
- public static double 千亿 = 100000000000;
- public static double 兆 = 1000000000000;
- public static double 千兆 = 1000000000000000;
- public static double 京 = 10000000000000000;
- public static double 千京 = 10000000000000000000;
- public static BigInteger 垓 = new BigInteger("100000000000000000000");
- public static BigInteger 千垓 = new BigInteger("100000000000000000000000");
- }
- public class Auxiliary : Regist
- {
- #region 变量
- public string String1;
- public string String2;
- public TextAsset TextAsset;
- public Texture2D Texture;
- public Font Font;
- public GameObject Go;
- public List<GameObject> GoList;
- public List<SpriteRenderer> SrList;
- public static bool AnyKeyUp;
- public static bool AnyKeyDown;
- public static Auxiliary Instance;
- public static MD5 MD5
- {
- get
- {
- if (_MD5 == null)
- {
- _MD5 = new MD5CryptoServiceProvider();
- }
- return _MD5;
- }
- set { _MD5 = value; }
- }
- public static DESCryptoServiceProvider Des
- {
- get
- {
- if (_Des == null)
- {
- _Des = new DESCryptoServiceProvider();
- _Des.IV = Encoding.UTF8.GetBytes("19283740");
- _Des.Key = Encoding.UTF8.GetBytes("93287123");
- }
- return _Des;
- }
- set { _Des = value; }
- }
- private static MD5 _MD5;
- private static DESCryptoServiceProvider _Des;
- #endregion
-
- public override bool RegistImmed()
- {
- if (base.RegistImmed())
- {
- return true;
- }
-
- enabled = true;
- return false;
- }
- private void Awake()
- {
- Instance = this;
- }
- private void Update()
- {
- #region 调试
- if (Input.GetKeyDown(KeyCode.Escape))
- {
-
- }
-
- if (Input.GetKeyDown(KeyCode.N))
- {
- ManaCenter.Coin = 0;
- ManaCenter.Diamond = 0;
- //foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
- //{
- // VARIABLE.Value.Unlock = true;
- //}
- foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
- {
- VARIABLE.Value.Unlock = false;
- }
- ManaGarden.FlowerInfoDic.First().Value.Unlock = true;
- }
- if (Input.GetKeyDown(KeyCode.B))
- {
- foreach (var VARIABLE in ManaPlayer.CloseUnitDic)
- {
- VARIABLE.Value.Unlock();
- }
- }
- if (Input.GetKeyDown(KeyCode.Z))
- {
- ManaCenter.MiniTimer = 0;
- }
- if (Input.GetKeyDown(KeyCode.X))
- {
- ManaMiniGame.GameTimer = 45;
- //Lottery.TempTypeList = new List<int>();
- //Lottery.TempValueList = new List<int>();
- //Lottery.TempLotteryList = new List<Lottery>();
- //Lottery.EnterAnimation();
- //ManaReso.Get("Bc_LotteryItem1").TweenForEuler();
- //ManaReso.Get("Bc_LotteryItem2").TweenForEuler();
- //ManaReso.Get("Bc_LotteryItem3").TweenForEuler();
- }
- if (Input.GetKeyDown(KeyCode.C))
- {
- ManaMiniGame.Score = 1000;
- }
- if (Input.GetKeyDown(KeyCode.V))
- {
- ManaGarden.ElfTimer = 0;
- }
- //if (Input.GetKeyDown(KeyCode.P))
- //{
- // ManaData.Level += 20;
- //}
- //if (Input.GetKeyDown(KeyCode.O))
- //{
- // for (int i = 0; i < ManaData.SkillList.Count; i++)
- // {
- // ManaData.SkillList[i].ReceiveCool(1, true, true);
- // }
- //}
- //if (Input.GetKeyDown(KeyCode.I))
- //{
- // ManaCenter.Coin += 1000;
- // ManaCenter.Diamond += 1000;
- //}
- //if (Input.GetKeyDown(KeyCode.U))
- //{
- // Data.SavePlayerConfig();
- // Data.SaveXml();
- //}
- //if (Input.GetKeyDown(KeyCode.Y))
- //{
- // Data.ResetPlayerConfig();
- // Data.SaveXml();
- //}
- //if (Input.GetKeyDown(KeyCode.T))
- //{
- // ManaData.Pause = !ManaData.Pause;
- //}
- #endregion
- #region 输入检测
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- ManaMiniGame.Pause = true;
- Bubble.Show(Language.GetStr("Common", "QuitGame"), null, null, Application.Quit, () => { ManaMiniGame.Pause = false; });
- }
- if (AnyKeyUp)
- {
- if (Input.anyKey == false)
- {
- AnyKeyUp = false;
- }
- }
- if (Input.anyKeyDown)
- {
- AnyKeyDown = true;
- }
-
- if (AnyKeyDown)
- {
- if (Input.anyKey == false)
- {
- AnyKeyUp = true;
- AnyKeyDown = false;
- }
- }
- #endregion
- }
- private static void ResetAllCd()
- {
- for (int i = 0; i < ManaCenter.CoolList.Count; i++)
- {
- ManaCenter.CoolList[i].CoolTimer = 0;
- }
- }
- public static byte[] GetMD5(object obj)
- {
-
- MemoryStream memoryStream = new MemoryStream();
- BinaryFormatter binaryFormatter = new BinaryFormatter();
- binaryFormatter.Serialize(memoryStream, obj);
- byte[] bytes = memoryStream.GetBuffer();
- memoryStream.Dispose();
- return MD5.ComputeHash(bytes);
- }
- public static void EncryptXml(XmlDocument doc)
- {
- EncryptedXml encryptedXml = new EncryptedXml();
- XmlElement xmlElement = doc.DocumentElement;
- byte[] bytes = encryptedXml.EncryptData(xmlElement, Des, false);
- EncryptedData encryptedData = new EncryptedData();
- encryptedData.Type = EncryptedXml.XmlEncElementUrl;
- encryptedData.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncDESUrl);
- encryptedData.CipherData.CipherValue = bytes;
- EncryptedXml.ReplaceElement(xmlElement, encryptedData, false);
- }
- public static void DecryptXml(XmlDocument doc)
- {
- EncryptedXml encryptedXml = new EncryptedXml();
- XmlElement encryptXmlElement = (XmlElement)doc.GetElementsByTagName("EncryptedData")[0];
- EncryptedData encryptedData = new EncryptedData();
-
- encryptedData.LoadXml(encryptXmlElement);
- byte[] bytes = encryptedXml.DecryptData(encryptedData, Des);
- encryptedXml.ReplaceData(encryptXmlElement, bytes);
- }
- public static byte[] Encrypt(string str)
- {
- byte[] bytes = Encoding.UTF8.GetBytes(str);
- byte[] encryptBytes = Des.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length);
- return encryptBytes;
- }
- public static byte[] ToBytes(string str)
- {
- string[] strings = str.Split(' ');
- byte[] bytes = new byte[strings.Length];
- for (int i = 0; i < bytes.Length; i++)
- {
- bytes[i] = byte.Parse(strings[i]);
- }
- return bytes;
- }
- public static string Decrypt(string str)
- {
- byte[] encryptBytes = ToBytes(str);
- byte[] decryptBytes = Des.CreateDecryptor().TransformFinalBlock(encryptBytes, 0, encryptBytes.Length);
- return Encoding.UTF8.GetString(decryptBytes);
- }
- public static string ToString(byte[] bytes)
- {
- StringBuilder strB = new StringBuilder();
- for (int i = 0; i < bytes.Length; i++)
- {
- if (i == bytes.Length - 1)
- {
- strB.Append(bytes[i]);
- }
- else
- {
- strB.Append(bytes[i] + " ");
- }
- }
- return strB.ToString();
- }
- public static void CompileDic(Transform tra, Dictionary<string, Transform> dic, bool enableIgnore = true)
- {
- Transform[] transforms = tra.GetComponentsInChildren<Transform>(true);
- for (int i = 0; i < transforms.Length; i++)
- {
- if (enableIgnore)
- {
- if (transforms[i].GetComponent<IgnoreIndexing>())
- {
- continue;
- }
- }
- if (dic.ContainsKey(transforms[i].name))
- {
- throw new Exception(transforms[i].name);
- }
- else
- {
- dic.Add(transforms[i].name, transforms[i]);
- }
- }
- }
- public static string GetUnit(int value, Unit unit)
- {
- if (unit == Unit.Second)
- {
- if (ManaLan.CurrentLan == Lan.English)
- {
- if (value == 0 || value == 1)
- {
- return " Second";
- }
- else
- {
- return " Seconds";
- }
- }
- else if (ManaLan.CurrentLan == Lan.ChineseSimplified)
- {
- return "秒";
- }
- else if (ManaLan.CurrentLan == Lan.ChineseTraditional)
- {
- return "秒";
- }
- else
- {
- throw new Exception();
- }
- }
- else
- {
- throw new Exception();
- }
- }
- public static string GetStreamPath()
- {
- if (Application.isEditor)
- {
- return "file://" + Application.streamingAssetsPath;
- }
- else if (Application.platform == RuntimePlatform.IPhonePlayer)
- {
- return "file://" + Application.streamingAssetsPath;
- }
- else if (Application.isMobilePlatform)
- {
- return Application.streamingAssetsPath;
- }
- else
- {
- throw new Exception();
- }
- }
- public Coroutine DelayCall(UnityAction function, int frame)
- {
- return StartCoroutine(IDelayCall(function, frame));
- }
- public Coroutine DelayCall(UnityAction function, float time)
- {
- return StartCoroutine(IDelayCall(function, time));
- }
- public static IEnumerator IDelayCall(UnityAction function, int frame)
- {
- int count = 0;
- while (count < frame)
- {
- count++;
- yield return null;
- }
- function.Invoke();
- }
- public static IEnumerator IDelayCall(UnityAction function, float time)
- {
- yield return new WaitForSeconds(time);
- function.Invoke();
- }
- public static string FmlParse1(string str)
- {
- int index = 0;
- int openIndex = 0;
- bool flag = false;
- bool group = false;
-
- for (int i = 0; i < str.Length; i++)
- {
- if (group)
- {
- if (str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/')
- {
- str = str.Replace(openIndex, i - 1, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i - 1)));
-
- i = 0;
- group = false;
- }
- else if (i == str.Length - 1)
- {
- str = str.Replace(openIndex, i, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i)));
- break;
- }
- }
- else
- {
- if (str[i] == '+' || str[i] == '-')
- {
- flag = true;
- openIndex = i + 1;
- }
- else if (str[i] == '*' || str[i] == '/')
- {
- index = i;
- group = true;
- if (!flag)
- {
- openIndex = 0;
- }
- }
- }
- }
- group = false;
- for (int i = 0; i < str.Length; i++)
- {
- if (group)
- {
- if (str[i] == '+' || str[i] == '-')
- {
- str = str.Replace(0, i - 1, FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i - 1)));
- i = -1;
- group = false;
- }
- else if (i == str.Length - 1)
- {
- return FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i));
- }
- }
- else
- {
- if (str[i] == '+' || str[i] == '-')
- {
- index = i;
- group = true;
- }
- }
- }
- return str;
- }
- public static string FmlParse2(char op, string str1, string str2)
- {
- double var1 = double.Parse(str1);
- double var2 = double.Parse(str2);
- if (op == '+')
- {
- return (var1 + var2).ToString();
- }
- else if (op == '-')
- {
- return (var1 - var2).ToString();
- }
- else if (op == '*')
- {
- return (var1 * var2).ToString();
- }
- else if (op == '/')
- {
- return (var1 / var2).ToString();
- }
- else
- {
- throw new Exception(op.ToString());
- }
- }
- public static double FmlParse(string str, params string[] strings)
- {
- for (int i = 0; i < strings.Length; i += 2)
- {
- if (str.Contains(strings[i]))
- {
- str = str.Replace(strings[i], strings[i + 1]);
- }
- else
- {
- //Debug.Log("No such var " + strings[i + 1]);
- }
- }
-
- int openIndex = 0;
- for (int i = 0; i < str.Length; i++)
- {
- if (str[i] == '(')
- {
- openIndex = i;
- }
- else if (str[i] == ')')
- {
- str = str.Replace(openIndex, i, FmlParse1(str.Between(openIndex + 1, i - 1)));
- i = -1;
- }
- }
- return double.Parse(FmlParse1(str));
- }
- public static string OmitNumberStr(int accuray, string str)
- {
- int index = str.IndexOf('.');
- if (index == -1)
- {
- return str;
- }
- if (accuray == 0)
- {
- return str.Substring(0, index);
- }
- else
- {
- for (int i = index + 1; i < index + accuray + 1; i++)
- {
- if (str[i] != '0')
- {
- return str.Substring(0, index + accuray + 1);
- }
- }
- return str.Substring(0, index);
- }
- }
- public static double ShrinkNumber(double value, int accuracy = 1)
- {
- if (ManaLan.CurrentLan == Lan.English)
- {
- if (value < Amount.千)
- {
- return value;
- }
- else if (value < Amount.百万)
- {
- string str = (value / Amount.千).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千;
- }
- else if (value < Amount.十亿)
- {
- string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.百万;
- }
- else if (value < Amount.兆)
- {
- string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.十亿;
- }
- else if (value < Amount.千兆)
- {
- string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
- }
- else
- {
- string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千兆;
- }
- }
- else if (ManaLan.CurrentLan == Lan.ChineseSimplified || ManaLan.CurrentLan == Lan.ChineseTraditional)
- {
- if (value < Amount.万)
- {
- return value;
- }
- else if (value < Amount.千万)
- {
- string str = (value / Amount.万).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.万;
- }
- else if (value < Amount.亿)
- {
- string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千万;
- }
- else if (value < Amount.千亿)
- {
- string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.亿;
- }
- else if (value < Amount.兆)
- {
- string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千亿;
- }
- else if (value < Amount.千兆)
- {
- string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.兆;
- }
- else if (value < Amount.京)
- {
- string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千兆;
- }
- else if (value < Amount.千京)
- {
- string str = (value / Amount.京).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.京;
- }
- else if (new BigInteger(value.ToString("0")) < Amount.垓)
- {
- string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
- return double.Parse(OmitNumberStr(accuracy, str)) * Amount.千京;
- }
- else if (new BigInteger(value.ToString("0")) < Amount.千垓)
- {
- string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
- return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10;
- }
- else
- {
- string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
- return double.Parse(OmitNumberStr(0, str)) * Amount.千京 * 10000;
- }
- }
- else
- {
- throw new Exception();
- }
- }
- public static string ShrinkNumberStr(double value, int accuracy = 1)
- {
- if (ManaLan.CurrentLan == Lan.English)
- {
- if (value < Amount.千)
- {
- return value.ToString("0");
- }
- else if (value < Amount.百万)
- {
- string str = (value / Amount.千).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "K";
- }
- else if (value < Amount.十亿)
- {
- string str = (value / Amount.百万).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "M";
- }
- else if (value < Amount.兆)
- {
- string str = (value / Amount.十亿).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "B";
- }
- else if (value < Amount.千兆)
- {
- string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "T";
- }
- else
- {
- string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "T";
- }
- }
- else if (ManaLan.CurrentLan == Lan.ChineseSimplified)
- {
- if (value < Amount.万)
- {
- return value.ToString("0");
- }
- else if (value < Amount.千万)
- {
- string str = (value / Amount.万).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "万";
- }
- else if (value < Amount.亿)
- {
- string str = (value/Amount.千万).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "千万";
- }
- else if (value < Amount.千亿)
- {
- string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "亿";
- }
- else if (value < Amount.兆)
- {
- string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "千亿";
- }
- else if (value < Amount.千兆)
- {
- string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "兆";
- }
- else if (value < Amount.京)
- {
- string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "千兆";
- }
- else if (value < Amount.千京)
- {
- string str = (value / Amount.京).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "京";
- }
- else if (new BigInteger(value.ToString("0")) < Amount.垓)
- {
- string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "千京";
- }
- else if (new BigInteger(value.ToString("0")) < Amount.千垓)
- {
- string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
- return OmitNumberStr(0, str) + "垓";
- }
- else
- {
- string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
- return OmitNumberStr(0, str) + "千垓";
- }
- }
- else if (ManaLan.CurrentLan == Lan.ChineseTraditional)
- {
- if (value < Amount.万)
- {
- return value.ToString("0");
- }
- else if (value < Amount.千万)
- {
- string str = (value / Amount.万).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "萬";
- }
- else if (value < Amount.亿)
- {
- string str = (value / Amount.千万).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "千萬";
- }
- else if (value < Amount.千亿)
- {
- string str = (value / Amount.亿).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "億";
- }
- else if (value < Amount.兆)
- {
- string str = (value / Amount.千亿).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "千億";
- }
- else if (value < Amount.千兆)
- {
- string str = (value / Amount.兆).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "兆";
- }
- else if (value < Amount.京)
- {
- string str = (value / Amount.千兆).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "千兆";
- }
- else if (value < Amount.千京)
- {
- string str = (value / Amount.京).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "京";
- }
- else if (new BigInteger(value.ToString("0")) < Amount.垓)
- {
- string str = (value / Amount.千京).ToString("F" + (accuracy + 1));
- return OmitNumberStr(accuracy, str) + "千京";
- }
- else if (new BigInteger(value.ToString("0")) < Amount.千垓)
- {
- string str = (new BigInteger(value.ToString("0")) / Amount.垓).ToString();
- return OmitNumberStr(0, str) + "垓";
- }
- else
- {
- string str = (new BigInteger(value.ToString("0")) / Amount.千垓).ToString();
- return OmitNumberStr(0, str) + "千垓";
- }
- }
- else
- {
- throw new Exception();
- }
- }
- public static string ImageParse(Current current)
- {
- if (current == Current.Coin)
- {
- return "<(金币)>";
- }
- else if (current == Current.Diamond)
- {
- return "<(钻石)>";
- }
- else if (current == Current.Cash)
- {
- return Language.GetStr("Common", "Cash");
- }
- else
- {
- throw new Exception(current.ToString());
- }
- }
- public static Current CurrentParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return Current.Free;
- }
- else
- {
- int number = int.Parse(str);
- if (number == 1)
- {
- return Current.Coin;
- }
- else if (number == 2)
- {
- return Current.Diamond;
- }
- else if (number == 3)
- {
- return Current.Cash;
- }
- else if (number == 4)
- {
- return Current.Other;
- }
- else if (number == 5)
- {
- return Current.AD;
- }
- else
- {
- throw new Exception(number.ToString());
- }
- }
- }
- public static int IntParse(string str, int defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- return int.Parse(str);
- }
- }
- public static long LongParse(string str, long defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- return long.Parse(str);
- }
- }
- public static bool BoolParse(string str, bool defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- return Convert.ToBoolean(int.Parse(str));
- }
- }
- public static float FloatParse(string str, float defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- return float.Parse(str);
- }
- }
- public static double DoubleParse(string str, double defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- return float.Parse(str);
- }
- }
- public static Vector3 VectorParse(char cah, string str, Vector3 defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- string[] strings = str.Split(',');
- if (strings.Length == 2)
- {
- Vector2 result = new Vector2();
- result.x = float.Parse(strings[0]);
- result.y = float.Parse(strings[1]);
- return result;
- }
- else if (strings.Length == 3)
- {
- Vector3 result = new Vector3();
- result.x = float.Parse(strings[0]);
- result.y = float.Parse(strings[1]);
- result.z = float.Parse(strings[2]);
- return result;
- }
- else
- {
- throw new Exception();
- }
- }
- }
- public static List<int> IntListParse(char cah, string str, List<int> defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- string[] strings = str.Split(cah);
- List<int> list = new List<int>();
- for (int i = 0; i < strings.Length; i++)
- {
- list.Add(int.Parse(strings[i]));
- }
- return list;
- }
- }
- public static List<string> StringListParse(char cah, string str, List<string> defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- string[] strings = str.Split(cah);
- List<string> list = new List<string>();
- for (int i = 0; i < strings.Length; i++)
- {
- list.Add(strings[i]);
- }
- return list;
- }
- }
- public static List<double> DoubleListParse(char cah, string str, List<double> defaultValue)
- {
- if (string.IsNullOrEmpty(str))
- {
- return defaultValue;
- }
- else
- {
- string[] strings = str.Split(cah);
- List<double> list = new List<double>();
- for (int i = 0; i < strings.Length; i++)
- {
- list.Add(double.Parse(strings[i]));
- }
- return list;
- }
- }
- }
|