플레이어/적/몬스터 팀 시스템 생성

몬스터 및 적 AI 구현
This commit is contained in:
2026-01-27 15:30:02 +09:00
parent 9a47af4317
commit 194845a9e1
33 changed files with 2519 additions and 445 deletions

View File

@@ -4,7 +4,7 @@ using UnityEngine;
namespace Northbound
{
/// <summary>
/// 액션 - 공격 (대상 없이도 실행 가능)
/// 액션 - 공격 (팀 시스템 적용)
/// </summary>
public class AttackAction : NetworkBehaviour, IAction
{
@@ -15,7 +15,7 @@ namespace Northbound
public LayerMask attackableLayer = ~0;
[Header("Animation")]
public string attackAnimationTrigger = "Attack"; // 공격 애니메이션 트리거
public string attackAnimationTrigger = "Attack";
[Header("Visual")]
public GameObject attackEffectPrefab;
@@ -23,10 +23,12 @@ namespace Northbound
private float _lastAttackTime;
private Animator _animator;
private ITeamMember _teamMember;
private void Awake()
{
_animator = GetComponent<Animator>();
_teamMember = GetComponent<ITeamMember>();
}
public bool CanExecute(ulong playerId)
@@ -44,7 +46,7 @@ namespace Northbound
// 애니메이션 재생
PlayAttackAnimation();
// 범위 내 적이 있으면 데미지
// 범위 내 적 검색
Vector3 attackOrigin = attackPoint != null ? attackPoint.position : transform.position;
Collider[] hits = Physics.OverlapSphere(attackOrigin, attackRange, attackableLayer);
@@ -54,10 +56,22 @@ namespace Northbound
if (hit.transform.root == transform.root)
continue;
// 적에게 데미지
var enemy = hit.GetComponent<IDamageable>();
if (enemy != null)
// 대상 확인
var targetDamageable = hit.GetComponent<IDamageable>();
var targetTeamMember = hit.GetComponent<ITeamMember>();
if (targetDamageable != null)
{
// 팀 확인 - 적대 관계인 경우에만 공격
if (_teamMember != null && targetTeamMember != null)
{
if (!TeamManager.CanAttack(_teamMember, targetTeamMember))
{
Debug.Log($"<color=yellow>[AttackAction] {TeamManager.GetTeamName(_teamMember.GetTeam())} 팀은 {TeamManager.GetTeamName(targetTeamMember.GetTeam())} 팀을 공격할 수 없습니다.</color>");
continue;
}
}
var netObj = hit.GetComponent<NetworkObject>();
if (netObj != null)
{
@@ -66,7 +80,7 @@ namespace Northbound
}
}
Debug.Log($"플레이어 {playerId} 공격! (적중: {hits.Length}개)");
Debug.Log($"<color=cyan>[AttackAction] 플레이어 {playerId} ({TeamManager.GetTeamName(_teamMember?.GetTeam() ?? TeamType.Neutral)}) 공격!</color>");
}
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]