- PlayerSpawnPoint.GetRandomSpawnPoint()을 랜덤에서 Round-Robin 순차 할당으로 변경 - 접속 순서대로 스폰 포인트를 순환하며 중복 스폰 방지 - BalanceDummy 씬에 두 번째 스폰 포인트 추가 (x=-5, y=3, z=0)
65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using UnityEngine;
|
|
|
|
namespace Colosseum.Network
|
|
{
|
|
/// <summary>
|
|
/// 플레이어 스폰 위치 마커
|
|
/// 씬에 배치하여 플레이어가 스폰될 위치를 지정
|
|
/// Round-Robin 순차 할당으로 중복 스폰 방지
|
|
/// </summary>
|
|
public class PlayerSpawnPoint : MonoBehaviour
|
|
{
|
|
[Header("Spawn Settings")]
|
|
[SerializeField] private bool useRotation = true;
|
|
|
|
private static readonly System.Collections.Generic.List<PlayerSpawnPoint> spawnPoints = new System.Collections.Generic.List<PlayerSpawnPoint>();
|
|
private static int nextSpawnIndex;
|
|
|
|
private void Awake()
|
|
{
|
|
spawnPoints.Add(this);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
spawnPoints.Remove(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Round-Robin 순차 할당 — 접속 순서대로 순환하며 중복 없이 반환
|
|
/// </summary>
|
|
public static Transform GetNextSpawnPoint()
|
|
{
|
|
if (spawnPoints.Count == 0)
|
|
return null;
|
|
|
|
int index = nextSpawnIndex % spawnPoints.Count;
|
|
nextSpawnIndex++;
|
|
return spawnPoints[index].transform;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 사용 가능한 스폰 포인트 중 하나를 반환 (기존 호환용, 내부적으로 Round-Robin 사용)
|
|
/// </summary>
|
|
public static Transform GetRandomSpawnPoint() => GetNextSpawnPoint();
|
|
|
|
/// <summary>
|
|
/// 스폰 포인트 개수 반환
|
|
/// </summary>
|
|
public static int SpawnPointCount => spawnPoints.Count;
|
|
|
|
private void OnDrawGizmos()
|
|
{
|
|
Gizmos.color = Color.green;
|
|
Gizmos.DrawWireSphere(transform.position, 0.5f);
|
|
Gizmos.color = Color.blue;
|
|
Gizmos.DrawLine(transform.position, transform.position + transform.forward * 1.5f);
|
|
|
|
// 화살표 머리
|
|
Vector3 arrowPos = transform.position + transform.forward * 1.5f;
|
|
Gizmos.DrawLine(arrowPos, arrowPos - transform.forward * 0.3f + transform.right * 0.2f);
|
|
Gizmos.DrawLine(arrowPos, arrowPos - transform.forward * 0.3f - transform.right * 0.2f);
|
|
}
|
|
}
|
|
}
|