BattleSceneDebugHelper.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System.Linq;
  2. using UnityEngine;
  3. using UnityEngine.SceneManagement;
  4. /// <summary>
  5. /// Debug helper for testing battle scene transitions and victory scenarios
  6. /// </summary>
  7. public class BattleSceneDebugHelper : MonoBehaviour
  8. {
  9. [Header("Debug Controls")]
  10. [Tooltip("Enable debug mode to show additional logging and controls")]
  11. public bool enableDebugMode = false;
  12. [Header("Scene Testing")]
  13. [Tooltip("Name of the map scene to return to")]
  14. public string mapSceneName = "MapScene2";
  15. private void Update()
  16. {
  17. if (!enableDebugMode) return;
  18. }
  19. private void ForceKillAllEnemies()
  20. {
  21. Debug.Log("🧪 [DEBUG] Manually killing all enemies...");
  22. if (GameManager.Instance != null && GameManager.Instance.enemyCharacters != null)
  23. {
  24. foreach (var enemy in GameManager.Instance.enemyCharacters)
  25. {
  26. if (enemy != null)
  27. {
  28. var character = enemy.GetComponent<Character>();
  29. if (character != null && !character.IsDead)
  30. {
  31. character.TakeDamage(1000); // Force death
  32. Debug.Log($"🔪 Killed enemy: {enemy.name}");
  33. }
  34. }
  35. }
  36. }
  37. }
  38. [ContextMenu("Debug Battle State")]
  39. public void DebugBattleState()
  40. {
  41. Debug.Log("🔍 [DEBUG] Current battle state:");
  42. if (GameManager.Instance != null)
  43. {
  44. Debug.Log($" Players: {GameManager.Instance.playerCharacters?.Count ?? 0}");
  45. Debug.Log($" Enemies: {GameManager.Instance.enemyCharacters?.Count ?? 0}");
  46. var alivePlayers = GameManager.Instance.GetAlivePlayers();
  47. var aliveEnemies = GameManager.Instance.enemyCharacters?.Where(e => e != null && !e.GetComponent<Character>()?.IsDead == true).Count() ?? 0;
  48. Debug.Log($" Alive Players: {alivePlayers?.Count ?? 0}");
  49. Debug.Log($" Alive Enemies: {aliveEnemies}");
  50. bool battleShouldEnd = (alivePlayers?.Count ?? 0) == 0 || aliveEnemies == 0;
  51. Debug.Log($" Battle should end: {battleShouldEnd}");
  52. }
  53. else
  54. {
  55. Debug.LogError(" GameManager.Instance is null!");
  56. }
  57. }
  58. private void OnGUI()
  59. {
  60. if (!enableDebugMode) return;
  61. // Simple debug GUI
  62. GUILayout.BeginArea(new Rect(10, 10, 300, 200));
  63. GUILayout.Label("Battle Debug Controls", GUI.skin.box);
  64. GUILayout.Label("Hotkeys: F1, F2, F3");
  65. GUILayout.EndArea();
  66. }
  67. }