| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System.Linq;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- /// <summary>
- /// Debug helper for testing battle scene transitions and victory scenarios
- /// </summary>
- public class BattleSceneDebugHelper : MonoBehaviour
- {
- [Header("Debug Controls")]
- [Tooltip("Enable debug mode to show additional logging and controls")]
- public bool enableDebugMode = false;
- [Header("Scene Testing")]
- [Tooltip("Name of the map scene to return to")]
- public string mapSceneName = "MapScene2";
- private void Update()
- {
- if (!enableDebugMode) return;
- }
- private void ForceKillAllEnemies()
- {
- Debug.Log("🧪 [DEBUG] Manually killing all enemies...");
- if (GameManager.Instance != null && GameManager.Instance.enemyCharacters != null)
- {
- foreach (var enemy in GameManager.Instance.enemyCharacters)
- {
- if (enemy != null)
- {
- var character = enemy.GetComponent<Character>();
- if (character != null && !character.IsDead)
- {
- character.TakeDamage(1000); // Force death
- Debug.Log($"🔪 Killed enemy: {enemy.name}");
- }
- }
- }
- }
- }
- [ContextMenu("Debug Battle State")]
- public void DebugBattleState()
- {
- Debug.Log("🔍 [DEBUG] Current battle state:");
- if (GameManager.Instance != null)
- {
- Debug.Log($" Players: {GameManager.Instance.playerCharacters?.Count ?? 0}");
- Debug.Log($" Enemies: {GameManager.Instance.enemyCharacters?.Count ?? 0}");
- var alivePlayers = GameManager.Instance.GetAlivePlayers();
- var aliveEnemies = GameManager.Instance.enemyCharacters?.Where(e => e != null && !e.GetComponent<Character>()?.IsDead == true).Count() ?? 0;
- Debug.Log($" Alive Players: {alivePlayers?.Count ?? 0}");
- Debug.Log($" Alive Enemies: {aliveEnemies}");
- bool battleShouldEnd = (alivePlayers?.Count ?? 0) == 0 || aliveEnemies == 0;
- Debug.Log($" Battle should end: {battleShouldEnd}");
- }
- else
- {
- Debug.LogError(" GameManager.Instance is null!");
- }
- }
- private void OnGUI()
- {
- if (!enableDebugMode) return;
- // Simple debug GUI
- GUILayout.BeginArea(new Rect(10, 10, 300, 200));
- GUILayout.Label("Battle Debug Controls", GUI.skin.box);
- GUILayout.Label("Hotkeys: F1, F2, F3");
- GUILayout.EndArea();
- }
- }
|