Auxiliary.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using System;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.Security.Cryptography;
  11. using UnityEngine.Events;
  12. public class Auxiliary : MonoBehaviour
  13. {
  14. #region 变量
  15. public string String;
  16. public Font Font;
  17. public GameObject Go;
  18. public List<GameObject> GoList;
  19. public List<SpriteRenderer> SrList;
  20. public static DESCryptoServiceProvider Des
  21. {
  22. get
  23. {
  24. if (_Des == null)
  25. {
  26. _Des = new DESCryptoServiceProvider();
  27. _Des.IV = Encoding.UTF8.GetBytes("12345678");
  28. _Des.Key = Encoding.UTF8.GetBytes("12345678");
  29. }
  30. return _Des;
  31. }
  32. set { _Des = value; }
  33. }
  34. private static DESCryptoServiceProvider _Des;
  35. #endregion
  36. private void Start()
  37. {
  38. }
  39. private void Update()
  40. {
  41. if (Input.GetKeyDown(KeyCode.P))
  42. {
  43. ManaData.Level += 10;
  44. }
  45. if (Input.GetKeyDown(KeyCode.O))
  46. {
  47. for (int i = 0; i < ManaData.SkillList.Count; i++)
  48. {
  49. ManaData.SkillList[i].ReceiveCool(1, true, true);
  50. }
  51. }
  52. if (Input.GetKeyDown(KeyCode.I))
  53. {
  54. ManaData.Coin += 1000;
  55. ManaData.Diamond += 1000;
  56. }
  57. if (Input.GetKeyDown(KeyCode.U))
  58. {
  59. Data.SavePlayerConfig();
  60. }
  61. if (Input.GetKeyDown(KeyCode.Y))
  62. {
  63. Data.ResetPlayerConfig();
  64. }
  65. }
  66. public static byte[] Encrypt(string str)
  67. {
  68. byte[] bytes = Encoding.UTF8.GetBytes(str);
  69. byte[] encryptBytes = Des.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length);
  70. return encryptBytes;
  71. }
  72. public static string Decrypt(string str)
  73. {
  74. byte[] encryptBytes = ToBytes(str);
  75. byte[] decryptBytes = Des.CreateDecryptor().TransformFinalBlock(encryptBytes, 0, encryptBytes.Length);
  76. return Encoding.UTF8.GetString(decryptBytes);
  77. }
  78. public static void CompileDic(Transform tra, Dictionary<string, Transform> dic)
  79. {
  80. Transform[] transforms = tra.GetComponentsInChildren<Transform>(true);
  81. for (int i = 0; i < transforms.Length; i++)
  82. {
  83. if (dic.ContainsKey(transforms[i].name))
  84. {
  85. throw new Exception(transforms[i].name);
  86. }
  87. else
  88. {
  89. dic.Add(transforms[i].name, transforms[i]);
  90. }
  91. }
  92. }
  93. public static byte[] ToBytes(string str)
  94. {
  95. string[] strings = str.Split(' ');
  96. byte[] bytes = new byte[strings.Length];
  97. for (int i = 0; i < bytes.Length; i++)
  98. {
  99. bytes[i] = byte.Parse(strings[i]);
  100. }
  101. return bytes;
  102. }
  103. public static string ToString(byte[] bytes)
  104. {
  105. StringBuilder strB = new StringBuilder();
  106. for (int i = 0; i < bytes.Length; i++)
  107. {
  108. if (i == bytes.Length - 1)
  109. {
  110. strB.Append(bytes[i]);
  111. }
  112. else
  113. {
  114. strB.Append(bytes[i] + " ");
  115. }
  116. }
  117. return strB.ToString();
  118. }
  119. public static IEnumerator DelayCall(UnityAction function, int frame)
  120. {
  121. int count = 0;
  122. if (count++ < frame)
  123. {
  124. yield return null;
  125. }
  126. function.Invoke();
  127. }
  128. }