Stash work
This commit is contained in:
184
Assets/Scripts/Minigames/FortFight/FortFightPhase2Tester.cs
Normal file
184
Assets/Scripts/Minigames/FortFight/FortFightPhase2Tester.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Core.Lifecycle;
|
||||
using Minigames.FortFight.Core;
|
||||
using Minigames.FortFight.Fort;
|
||||
|
||||
namespace Minigames.FortFight
|
||||
{
|
||||
/// <summary>
|
||||
/// Debug script to test Phase 2 fort system.
|
||||
/// Attach to a GameObject in the scene to manually trigger fort damage for testing.
|
||||
/// </summary>
|
||||
public class FortFightPhase2Tester : ManagedBehaviour
|
||||
{
|
||||
[Header("Test Settings")]
|
||||
[SerializeField] private bool enableKeyboardControls = true;
|
||||
[SerializeField] private float testDamageAmount = 25f;
|
||||
[SerializeField] private bool autoTestOnStart = false;
|
||||
[SerializeField] private float autoTestDelay = 2f;
|
||||
|
||||
private FortManager fortManager;
|
||||
private FortController playerFort;
|
||||
private FortController enemyFort;
|
||||
|
||||
internal override void OnManagedStart()
|
||||
{
|
||||
base.OnManagedStart();
|
||||
|
||||
// Find fort manager
|
||||
fortManager = FindFirstObjectByType<FortManager>();
|
||||
|
||||
if (fortManager == null)
|
||||
{
|
||||
Logging.Error("[FortFightPhase2Tester] FortManager not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Subscribe to fort spawn events
|
||||
fortManager.OnPlayerFortSpawned += OnPlayerFortSpawned;
|
||||
fortManager.OnEnemyFortSpawned += OnEnemyFortSpawned;
|
||||
|
||||
Logging.Debug("=== PHASE 2 TESTING CONTROLS ===");
|
||||
Logging.Debug("Press '1' to damage random PLAYER fort block");
|
||||
Logging.Debug("Press '2' to damage random ENEMY fort block");
|
||||
Logging.Debug("Press '3' to damage PLAYER fort weak point");
|
||||
Logging.Debug("Press '4' to damage ENEMY fort weak point");
|
||||
Logging.Debug("Press '5' to destroy random PLAYER block");
|
||||
Logging.Debug("Press '6' to destroy random ENEMY block");
|
||||
Logging.Debug("================================");
|
||||
|
||||
if (autoTestOnStart)
|
||||
{
|
||||
InvokeRepeating(nameof(AutoTest), autoTestDelay, autoTestDelay);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerFortSpawned(FortController fort)
|
||||
{
|
||||
playerFort = fort;
|
||||
Logging.Debug($"[Phase2Tester] Player fort spawned: {fort.FortName}");
|
||||
}
|
||||
|
||||
private void OnEnemyFortSpawned(FortController fort)
|
||||
{
|
||||
enemyFort = fort;
|
||||
Logging.Debug($"[Phase2Tester] Enemy fort spawned: {fort.FortName}");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!enableKeyboardControls) return;
|
||||
if (Keyboard.current == null) return;
|
||||
|
||||
// Test controls
|
||||
if (Keyboard.current.digit1Key.wasPressedThisFrame)
|
||||
{
|
||||
DamageRandomBlock(playerFort, testDamageAmount);
|
||||
}
|
||||
|
||||
if (Keyboard.current.digit2Key.wasPressedThisFrame)
|
||||
{
|
||||
DamageRandomBlock(enemyFort, testDamageAmount);
|
||||
}
|
||||
|
||||
if (Keyboard.current.digit3Key.wasPressedThisFrame)
|
||||
{
|
||||
DamageWeakPoint(playerFort);
|
||||
}
|
||||
|
||||
if (Keyboard.current.digit4Key.wasPressedThisFrame)
|
||||
{
|
||||
DamageWeakPoint(enemyFort);
|
||||
}
|
||||
|
||||
if (Keyboard.current.digit5Key.wasPressedThisFrame)
|
||||
{
|
||||
DestroyRandomBlock(playerFort);
|
||||
}
|
||||
|
||||
if (Keyboard.current.digit6Key.wasPressedThisFrame)
|
||||
{
|
||||
DestroyRandomBlock(enemyFort);
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoTest()
|
||||
{
|
||||
// Alternate between player and enemy
|
||||
if (Random.value > 0.5f)
|
||||
{
|
||||
DamageRandomBlock(playerFort, testDamageAmount);
|
||||
}
|
||||
else
|
||||
{
|
||||
DamageRandomBlock(enemyFort, testDamageAmount);
|
||||
}
|
||||
}
|
||||
|
||||
private void DamageRandomBlock(FortController fort, float damage)
|
||||
{
|
||||
if (fort == null || fort.TotalBlockCount == 0)
|
||||
{
|
||||
Logging.Warning("[Phase2Tester] No fort or blocks available to damage!");
|
||||
return;
|
||||
}
|
||||
|
||||
FortBlock randomBlock = fort.GetRandomBlock();
|
||||
if (randomBlock != null)
|
||||
{
|
||||
Logging.Debug($"[Phase2Tester] Damaging {fort.FortName} block '{randomBlock.gameObject.name}' for {damage} damage");
|
||||
randomBlock.TakeDamage(damage);
|
||||
}
|
||||
}
|
||||
|
||||
private void DamageWeakPoint(FortController fort)
|
||||
{
|
||||
if (fort == null)
|
||||
{
|
||||
Logging.Warning("[Phase2Tester] Fort is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
var weakPoints = fort.GetWeakPoints();
|
||||
if (weakPoints.Count == 0)
|
||||
{
|
||||
Logging.Warning($"[Phase2Tester] {fort.FortName} has no weak points!");
|
||||
return;
|
||||
}
|
||||
|
||||
FortBlock weakPoint = weakPoints[Random.Range(0, weakPoints.Count)];
|
||||
Logging.Debug($"[Phase2Tester] Destroying {fort.FortName} WEAK POINT '{weakPoint.gameObject.name}'");
|
||||
weakPoint.TakeDamage(999f); // Instant destruction
|
||||
}
|
||||
|
||||
private void DestroyRandomBlock(FortController fort)
|
||||
{
|
||||
if (fort == null || fort.TotalBlockCount == 0)
|
||||
{
|
||||
Logging.Warning("[Phase2Tester] No fort or blocks available to destroy!");
|
||||
return;
|
||||
}
|
||||
|
||||
FortBlock randomBlock = fort.GetRandomBlock();
|
||||
if (randomBlock != null)
|
||||
{
|
||||
Logging.Debug($"[Phase2Tester] DESTROYING {fort.FortName} block '{randomBlock.gameObject.name}'");
|
||||
randomBlock.TakeDamage(999f); // Instant destruction
|
||||
}
|
||||
}
|
||||
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
base.OnManagedDestroy();
|
||||
|
||||
if (fortManager != null)
|
||||
{
|
||||
fortManager.OnPlayerFortSpawned -= OnPlayerFortSpawned;
|
||||
fortManager.OnEnemyFortSpawned -= OnEnemyFortSpawned;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user