1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027 |
- using LitJson;
- 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.Collections.Generic;
- using System.Security.Cryptography;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Security;
- using System.Security.Cryptography.Xml;
- 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 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;
-
- //gameObject.AddComponent<ManaAnim>().RegistImmed();
- }
- private void Update()
- {
- #region 调试
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- }
- if (Input.GetKeyDown(KeyCode.N))
- {
- ManaData.PlayerDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 670.ToString();
- //foreach (var VARIABLE in ManaGarden.FlowerInfoDic)
- //{
- // if (!VARIABLE.Value.Unlock)
- // {
- // VARIABLE.Value.Unlock = true;
- // }
- //}
- }
- if (Input.GetKeyDown(KeyCode.B))
- {
- for (int i = 0; i < ManaCenter.UseList.Count; i++)
- {
- ManaCenter.UseList[i].UseTimer = 0;
- }
- for (int i = 0; i < ManaCenter.CoolList.Count; i++)
- {
- ManaCenter.CoolList[i].CoolTimer = 0;
- }
- }
- if (Input.GetKeyDown(KeyCode.Z))
- {
- ManaCenter.MiniTimer = 0;
- }
- if (Input.GetKeyDown(KeyCode.X))
- {
- ManaMiniGame.Score = 1000;
- }
- if (Input.GetKeyDown(KeyCode.C))
- {
- ManaMiniGame.GameTimer = 45;
- }
- 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
- }
- 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 void DelayCall(UnityAction function, int frame)
- {
- StartCoroutine(IDelayCall(function, frame));
- }
- public void DelayCall(UnityAction function, float time)
- {
- 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
- {
- return str.Substring(0, index + accuray + 1);
- }
- }
- public static long ShrinkNumber(double value, int accuracy = 1)
- {
- long longValue = (long) value;
-
- if (ManaLan.CurrentLan == Lan.English)
- {
- if (longValue < Amount.千)
- {
- return longValue;
- }
- else if (longValue < Amount.百万)
- {
- long temp = (long) Amount.百;
- return (longValue/ temp) * temp;
- }
- else if (longValue < Amount.十亿)
- {
- long temp = (long)Amount.十万;
- return (longValue / temp) * temp;
- }
- else if (longValue < Amount.万亿)
- {
- long temp = (long)Amount.亿;
- return (longValue / temp) * temp;
- }
- else if (longValue < Amount.千万亿)
- {
- long temp = (long)Amount.千亿;
- return (longValue / temp) * temp;
- }
- else
- {
- long temp = (long)Amount.千亿;
- return (longValue / temp) * temp;
- }
- }
- else if (ManaLan.CurrentLan == Lan.ChineseSimplified || ManaLan.CurrentLan == Lan.ChineseTraditional)
- {
- if (longValue < Amount.万)
- {
- return longValue;
- }
- else if (longValue < Amount.亿)
- {
- long temp = (long)Amount.千;
- return (longValue / temp) * temp;
- }
- else if (longValue < Amount.万亿)
- {
- long temp = (long)Amount.千万;
- return (longValue / temp) * temp;
- }
- else if (longValue < Amount.万万亿)
- {
- long temp = (long)Amount.千亿;
- return (longValue / temp) * temp;
- }
- else
- {
- long temp = (long)Amount.千亿;
- return (longValue / temp) * temp;
- }
- }
- else
- {
- throw new Exception();
- }
- }
- public static string ShrinkNumberStr(double value, int accuracy = 1)
- {
- long longValue = (long) value;
- if (ManaLan.CurrentLan == Lan.English)
- {
- if (longValue < Amount.千)
- {
- return longValue.ToString();
- }
- else if (longValue < Amount.百万)
- {
- string str = (longValue / Amount.千).ToString();
- return OmitNumberStr(accuracy, str) + "K";
- }
- else if (longValue < Amount.十亿)
- {
- string str = (longValue / Amount.百万).ToString();
- return OmitNumberStr(accuracy, str) + "M";
- }
- else if (longValue < Amount.万亿)
- {
- string str = (longValue / Amount.十亿).ToString();
- return OmitNumberStr(accuracy, str) + "B";
- }
- else if (longValue < Amount.千万亿)
- {
- string str = (longValue / Amount.万亿).ToString();
- return OmitNumberStr(accuracy, str) + "T";
- }
- else
- {
- string str = (longValue / Amount.万亿).ToString();
- return OmitNumberStr(accuracy, str) + "T";
- }
- }
- else if (ManaLan.CurrentLan == Lan.ChineseSimplified)
- {
- if (longValue < Amount.万)
- {
- return longValue.ToString();
- }
- else if (longValue < Amount.亿)
- {
- string str = (longValue/Amount.万).ToString();
- return OmitNumberStr(accuracy, str) + "万";
- }
- else if (longValue < Amount.万亿)
- {
- string str = (longValue / Amount.亿).ToString();
- return OmitNumberStr(accuracy, str) + "亿";
- }
- else if (longValue < Amount.万万亿)
- {
- string str = (longValue / Amount.万亿).ToString();
- return OmitNumberStr(accuracy, str) + "万亿";
- }
- else
- {
- string str = (longValue / Amount.万亿).ToString();
- return OmitNumberStr(accuracy, str) + "万亿";
- }
- }
- else if (ManaLan.CurrentLan == Lan.ChineseTraditional)
- {
- if (longValue < Amount.万)
- {
- return longValue.ToString();
- }
- else if (longValue < Amount.亿)
- {
- string str = (longValue / Amount.万).ToString();
- return OmitNumberStr(accuracy, str) + "萬";
- }
- else if (longValue < Amount.万亿)
- {
- string str = (longValue / Amount.亿).ToString();
- return OmitNumberStr(accuracy, str) + "億";
- }
- else if (longValue < Amount.万万亿)
- {
- string str = (longValue / Amount.万亿).ToString();
- return OmitNumberStr(accuracy, str) + "萬億";
- }
- else
- {
- string str = (longValue / Amount.万亿).ToString();
- return OmitNumberStr(accuracy, 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;
- }
- }
- }
|