using LitJson; using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; using System; using System.IO; using System.Linq; using System.Text; using System.Collections; using System.Collections.Generic; using System.Security.Cryptography; public class Auxiliary : MonoBehaviour { #region 变量 public string String; public Font Font; public GameObject Go; public List GoList; public List SrList; public static bool AnyKeyUp; public static bool AnyKeyDown; public static Auxiliary Inst; public static DESCryptoServiceProvider Des { get { if (_Des == null) { _Des = new DESCryptoServiceProvider(); _Des.IV = Encoding.UTF8.GetBytes("12345678"); _Des.Key = Encoding.UTF8.GetBytes("12345678"); } return _Des; } set { _Des = value; } } private static DESCryptoServiceProvider _Des; #endregion private void Start() { Inst = this; } private void Update() { if (AnyKeyUp) { if (Input.anyKey == false) { AnyKeyUp = false; } } if (Input.anyKeyDown) { AnyKeyDown = true; } if (AnyKeyDown) { if (Input.anyKey == false) { AnyKeyUp = true; AnyKeyDown = false; } } if (Input.GetKeyDown(KeyCode.P)) { ManaData.Level += 10; } 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)) { ManaData.Coin += 1000; ManaData.Diamond += 1000; } if (Input.GetKeyDown(KeyCode.U)) { Data.SavePlayerConfig(); } if (Input.GetKeyDown(KeyCode.Y)) { Data.ResetPlayerConfig(); } if (Input.GetKeyDown(KeyCode.T)) { if (Math.Abs(Time.timeScale) < 0.0005f) { Time.timeScale = 1; ManaLog.Log("游戏已恢复"); } else { Time.timeScale = 0; ManaLog.Log("游戏已暂停"); } } } 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 string Decrypt(string str) { byte[] encryptBytes = ToBytes(str); byte[] decryptBytes = Des.CreateDecryptor().TransformFinalBlock(encryptBytes, 0, encryptBytes.Length); return Encoding.UTF8.GetString(decryptBytes); } public static void CompileDic(Transform tra, Dictionary dic) { Transform[] transforms = tra.GetComponentsInChildren(true); for (int i = 0; i < transforms.Length; i++) { if (dic.ContainsKey(transforms[i].name)) { throw new Exception(transforms[i].name); } else { dic.Add(transforms[i].name, transforms[i]); } } } 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 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 void DelayCall(UnityAction function, int frame) { StartCoroutine(IDelayCall(function, frame)); } public void DelayCall(UnityAction function, float time) { StartCoroutine(IDelayCall(function, time)); } private static IEnumerator IDelayCall(UnityAction function, int frame) { int count = 0; if (count++ < frame) { yield return null; } function.Invoke(); } private static IEnumerator IDelayCall(UnityAction function, float time) { yield return new WaitForSeconds(time); function.Invoke(); } }