DebugManager.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.Serialization;
  4. using System;
  5. using System.Text;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using Sfs2X.Core;
  9. using Random = UnityEngine.Random;
  10. public class DebugManager : MonoBehaviour
  11. {
  12. #region Config
  13. public static Text DebugBugText
  14. {
  15. get
  16. {
  17. if (debugBugText == null)
  18. {
  19. DebugBugText = ResourceManager.Get<Text>(CanvasLabel.E_ScrrLab, false);
  20. }
  21. return debugBugText;
  22. }
  23. set { debugBugText = value; }
  24. }
  25. private static Text debugBugText;
  26. public int TextCounter;
  27. public float FrameRateTimer;
  28. #endregion
  29. public void Update()
  30. {
  31. FrameRateTimer += Time.deltaTime;
  32. TextCounter++;
  33. if (FrameRateTimer >= 1)
  34. {
  35. //Log($"当前帧率 {Counter} 目标帧率 {Application.targetFrameRate}");
  36. FrameRateTimer = 0;
  37. TextCounter = 0;
  38. }
  39. }
  40. public static void Log(string message)
  41. {
  42. if (DebugBugText == null)
  43. {
  44. return;
  45. }
  46. DebugBugText.text += '\n' + message;
  47. }
  48. public static void ResetAbilityAnim()
  49. {
  50. SkillRoot skillRoot = Manager.SkillDictionary["Ability2"];
  51. skillRoot.Level = 0;
  52. skillRoot.ItemStatus = SkillStatus.Lock;
  53. skillRoot = Manager.SkillDictionary["Ability3"];
  54. skillRoot.Level = 0;
  55. skillRoot.ItemStatus = SkillStatus.Lock;
  56. skillRoot = Manager.SkillDictionary["Ability4"];
  57. skillRoot.Level = 0;
  58. skillRoot.ItemStatus = SkillStatus.Lock;
  59. }
  60. public static void ResetElf()
  61. {
  62. for (int i = 5; i <= 24; i++)
  63. {
  64. SkillRoot skillRoot = Manager.SkillDictionary["Ability" + i];
  65. skillRoot.Level = 0;
  66. skillRoot.ItemStatus = SkillStatus.Lock;
  67. }
  68. }
  69. public static void ResetGardenLevel(int level)
  70. {
  71. SkillRoot skillRoot = Manager.SkillDictionary["Ability1"];
  72. skillRoot.Level = level;
  73. if (level == 0)
  74. {
  75. skillRoot.itemStatus = SkillStatus.UnLock;
  76. }
  77. else
  78. {
  79. skillRoot.itemStatus = SkillStatus.Upgrade;
  80. }
  81. }
  82. public static void ResetVisitTutorial()
  83. {
  84. TutorialManager.visitTutorial = true;
  85. TutorialManager.VisitTutorial = true;
  86. }
  87. public static void ResetMemoryGameTutorial()
  88. {
  89. TutorialManager.memoryMinigameTutorial = true;
  90. TutorialManager.MemoryMinigameTutorial = true;
  91. }
  92. public static void TryCatch(Action tryAction, Action catchAction)
  93. {
  94. try
  95. {
  96. tryAction.Invoke();
  97. }
  98. catch (Exception)
  99. {
  100. catchAction.Invoke();
  101. }
  102. }
  103. public static void PrintKeysAndValuesOfBaseEvent(string seperator, BaseEvent baseEvent)
  104. {
  105. Debug.LogWarning(seperator);
  106. foreach (var key in baseEvent.Params.Keys)
  107. {
  108. Debug.Log("Key " + key);
  109. }
  110. foreach (var value in baseEvent.Params.Values)
  111. {
  112. Debug.Log("value " + value);
  113. }
  114. Debug.LogWarning(seperator);
  115. }
  116. }