Files
Colosseum/Assets/Scripts/UI/AbnormalitySystemTest.cs
dal4segno ec99e302ed [Abnormality] 이상 상태 시스템 구현
- 이상 상태 데이터 (버프/디버프) ScriptableObject 정의
- 런타임임 활성 이상 상태 관리 (ActiveAbnormality)
- 캐릭터터별 AbnormalityManager 컴포넌트로 이상 상태 적용/제거
- 스킬 효과(AbnormalityEffect)로 스킬에 이상 상태 연동
- UI 슬롯 및 목록 표시 구현 (버프/디버프 구분)
- 테스트 코드 및 씬 설정 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 01:35:02 +09:00

117 lines
4.2 KiB
C#

using UnityEngine;
using Colosseum.Abnormalities;
namespace Colosseum.UI
{
/// <summary>
/// 이상 상태 시스템 테스트 스크립트
/// Q 키: 버프 적용, E 키: 디버프 적용
/// 로그를 통해 OnEffect 이벤트 호출 및 이상 상태 적용 과정을 추적합니다.
/// </summary>
public class AbnormalitySystemTest : MonoBehaviour
{
private AbnormalityManager abnormalityManager;
private AbnormalityData testBuff;
private AbnormalityData testDebuff;
private float testTimer;
void Start()
{
// 플레이어에서 AbnormalityManager 찾기
abnormalityManager = GetComponent<AbnormalityManager>();
if (abnormalityManager == null)
{
Debug.LogError("[AbnormalitySystemTest] AbnormalityManager not found on player!");
return;
}
// 테스트용 이상 상태 데이터 생성 (에셋 생성)
testBuff = ScriptableObject.CreateInstance<AbnormalityData>();
testBuff.abnormalityName = "Test Buff";
testBuff.duration = 5f;
testBuff.isDebuff = false;
testDebuff = ScriptableObject.CreateInstance<AbnormalityData>();
testDebuff.abnormalityName = "Test Debuff";
testDebuff.duration = 5f;
testDebuff.isDebuff = true;
// 이벤트 구독
abnormalityManager.OnAbnormalityAdded += OnAbnormalityAdded;
abnormalityManager.OnAbnormalityRemoved += OnAbnormalityRemoved;
Debug.Log("=== Abnormality System Test Started ===");
Debug.Log("Press Q to apply buff, Press E to apply debuff");
Debug.Log($"Initial Active Abnormalities Count: {abnormalityManager.ActiveAbnormalities.Count}");
}
void Update()
{
testTimer += Time.deltaTime;
// Q 키로 버프 적용 (3초마다 1회만)
if (Input.GetKeyDown(KeyCode.Q) && testTimer >= 3f)
{
testTimer = 0f;
ApplyTestBuff();
}
// E 키로 디버프 적용 (3초마다 1회만)
if (Input.GetKeyDown(KeyCode.E) && testTimer >= 3f)
{
testTimer = 0f;
ApplyTestDebuff();
}
}
private void ApplyTestBuff()
{
if (testBuff == null || abnormalityManager == null)
{
Debug.LogWarning("[AbnormalitySystemTest] Cannot apply buff - data or manager is null");
return;
}
Debug.Log($"[AbnormalitySystemTest] >>> Applying BUFF: {testBuff.abnormalityName} to {gameObject.name}");
abnormalityManager.ApplyAbnormality(testBuff, gameObject);
}
private void ApplyTestDebuff()
{
if (testDebuff == null || abnormalityManager == null)
{
Debug.LogWarning("[AbnormalitySystemTest] Cannot apply debuff - data or manager is null");
return;
}
Debug.Log($"[AbnormalitySystemTest] >>> Applying DEBUFF: {testDebuff.abnormalityName} to {gameObject.name}");
abnormalityManager.ApplyAbnormality(testDebuff, gameObject);
}
private void OnAbnormalityAdded(ActiveAbnormality abnormality)
{
Debug.Log($"[AbnormalitySystemTest] <<< ABNORMALITY ADDED: {abnormality.Data.abnormalityName} | isDebuff: {abnormality.Data.isDebuff} | Duration: {abnormality.Data.duration}s | Remaining: {abnormality.RemainingDuration:F1}s");
}
private void OnAbnormalityRemoved(ActiveAbnormality abnormality)
{
Debug.Log($"[AbnormalitySystemTest] <<< ABNORMALITY REMOVED: {abnormality.Data.abnormalityName}");
}
void OnDestroy()
{
// 이벤트 구독 해제
if (abnormalityManager != null)
{
abnormalityManager.OnAbnormalityAdded -= OnAbnormalityAdded;
abnormalityManager.OnAbnormalityRemoved -= OnAbnormalityRemoved;
}
// 정리
if (testBuff != null) Destroy(testBuff);
if (testDebuff != null) Destroy(testDebuff);
}
}
}