Files
Northbound/Assets/Scripts/TeamManager.cs
2026-01-27 15:30:02 +09:00

96 lines
3.4 KiB
C#

using System.Collections.Generic;
using UnityEngine;
namespace Northbound
{
/// <summary>
/// 팀 간의 관계 및 적대 관계를 관리
/// </summary>
public static class TeamManager
{
// 팀 간 적대 관계 테이블
private static readonly Dictionary<(TeamType, TeamType), bool> _hostilityTable = new Dictionary<(TeamType, TeamType), bool>
{
// 플레이어 vs 적대 세력
{ (TeamType.Player, TeamType.Hostile), true },
{ (TeamType.Hostile, TeamType.Player), true },
// 플레이어 vs 몬스터
{ (TeamType.Player, TeamType.Monster), true },
{ (TeamType.Monster, TeamType.Player), true },
// 적대 세력 vs 몬스터 (서로 공격하지 않음)
{ (TeamType.Hostile, TeamType.Monster), false },
{ (TeamType.Monster, TeamType.Hostile), false },
// 같은 팀끼리는 공격하지 않음
{ (TeamType.Player, TeamType.Player), false },
{ (TeamType.Hostile, TeamType.Hostile), false },
{ (TeamType.Monster, TeamType.Monster), false },
// 중립은 공격받지 않음
{ (TeamType.Neutral, TeamType.Player), false },
{ (TeamType.Neutral, TeamType.Hostile), false },
{ (TeamType.Neutral, TeamType.Monster), false },
{ (TeamType.Player, TeamType.Neutral), false },
{ (TeamType.Hostile, TeamType.Neutral), false },
{ (TeamType.Monster, TeamType.Neutral), false },
{ (TeamType.Neutral, TeamType.Neutral), false }
};
/// <summary>
/// 두 팀이 적대 관계인지 확인
/// </summary>
public static bool AreHostile(TeamType team1, TeamType team2)
{
if (_hostilityTable.TryGetValue((team1, team2), out bool isHostile))
{
return isHostile;
}
// 기본적으로 다른 팀이면 적대
return team1 != team2 && team1 != TeamType.Neutral && team2 != TeamType.Neutral;
}
/// <summary>
/// 공격 가능한 대상인지 확인
/// </summary>
public static bool CanAttack(ITeamMember attacker, ITeamMember target)
{
if (attacker == null || target == null)
return false;
return AreHostile(attacker.GetTeam(), target.GetTeam());
}
/// <summary>
/// 팀의 색상 가져오기 (UI 표시용)
/// </summary>
public static Color GetTeamColor(TeamType team)
{
return team switch
{
TeamType.Player => Color.blue,
TeamType.Hostile => Color.red,
TeamType.Monster => new Color(0.8f, 0f, 0.8f), // 보라색
TeamType.Neutral => Color.gray,
_ => Color.white
};
}
/// <summary>
/// 팀 이름 가져오기 (한글)
/// </summary>
public static string GetTeamName(TeamType team)
{
return team switch
{
TeamType.Player => "플레이어",
TeamType.Hostile => "적대 세력",
TeamType.Monster => "몬스터",
TeamType.Neutral => "중립",
_ => "알 수 없음"
};
}
}
}