일꾼(Worker) 개발 및 Kaykit Adventurer 애셋 추가
코어 오른쪽 건물에서 상호작용 하면 Worker 생성 Worker와 상호작용하면 Worker가 플레이어를 따라옴 그 상태에서 자원과 상호작용하면 Worker를 자원에 배치할 수 있음.
This commit is contained in:
@@ -29,6 +29,9 @@ namespace Northbound
|
||||
[Header("Debug")]
|
||||
public bool showDebugRay = true;
|
||||
|
||||
[Header("Worker")]
|
||||
public Worker assignedWorker;
|
||||
|
||||
private PlayerInputActions _inputActions;
|
||||
private IInteractable _currentInteractable;
|
||||
private Camera _mainCamera;
|
||||
@@ -40,7 +43,6 @@ namespace Northbound
|
||||
private bool _isInteracting = false;
|
||||
private Coroutine _interactionTimeoutCoroutine;
|
||||
|
||||
// 다른 컴포넌트가 이동 차단 여부를 확인할 수 있도록 public 프로퍼티 제공
|
||||
public bool IsInteracting => _isInteracting;
|
||||
public float WorkPower => workPower;
|
||||
|
||||
@@ -124,14 +126,28 @@ namespace Northbound
|
||||
|
||||
if (_currentInteractable != null)
|
||||
{
|
||||
bool isResource = _currentInteractable is Resource;
|
||||
bool hasWorker = assignedWorker != null && assignedWorker.OwnerPlayerId == OwnerClientId;
|
||||
bool isWorkerFollowing = hasWorker && (int)assignedWorker.CurrentState == 1;
|
||||
bool shouldPlayAnimation = !isResource || !hasWorker || !isWorkerFollowing;
|
||||
|
||||
_isInteracting = true;
|
||||
_pendingEquipmentData = _currentInteractable.GetEquipmentData();
|
||||
|
||||
string animTrigger = _currentInteractable.GetInteractionAnimation();
|
||||
bool hasAnimation = !string.IsNullOrEmpty(animTrigger);
|
||||
|
||||
// 장비 장착 (애니메이션 이벤트 사용 안 할 경우)
|
||||
if (!useAnimationEvents && useEquipment && _equipmentSocket != null && _pendingEquipmentData != null)
|
||||
if (playAnimations && _animator != null && hasAnimation && shouldPlayAnimation)
|
||||
{
|
||||
_animator.SetTrigger(animTrigger);
|
||||
_interactionTimeoutCoroutine = StartCoroutine(InteractionTimeout(3f));
|
||||
}
|
||||
else
|
||||
{
|
||||
_isInteracting = false;
|
||||
}
|
||||
|
||||
if (shouldPlayAnimation && !useAnimationEvents && useEquipment && _equipmentSocket != null && _pendingEquipmentData != null)
|
||||
{
|
||||
if (_pendingEquipmentData.attachOnStart && _pendingEquipmentData.equipmentPrefab != null)
|
||||
{
|
||||
@@ -144,20 +160,6 @@ namespace Northbound
|
||||
}
|
||||
}
|
||||
|
||||
// 애니메이션 재생
|
||||
if (playAnimations && _animator != null && hasAnimation)
|
||||
{
|
||||
_animator.SetTrigger(animTrigger);
|
||||
// 애니메이션 완료를 보장하기 위해 타임아웃 코루틴 시작
|
||||
_interactionTimeoutCoroutine = StartCoroutine(InteractionTimeout(3f));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 애니메이션이 없으면 즉시 상호작용 완료
|
||||
_isInteracting = false;
|
||||
}
|
||||
|
||||
// 상호작용 실행 (서버에서 처리)
|
||||
_currentInteractable.Interact(OwnerClientId);
|
||||
}
|
||||
}
|
||||
@@ -250,7 +252,6 @@ namespace Northbound
|
||||
yield return new WaitForSeconds(timeout);
|
||||
if (_isInteracting)
|
||||
{
|
||||
Debug.LogWarning("[PlayerInteraction] Interaction timeout - forcing completion");
|
||||
_isInteracting = false;
|
||||
_interactionTimeoutCoroutine = null;
|
||||
}
|
||||
@@ -268,7 +269,7 @@ namespace Northbound
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!IsOwner || _currentInteractable == null) return;
|
||||
if (!IsOwner) return;
|
||||
|
||||
GUIStyle style = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
@@ -277,15 +278,50 @@ namespace Northbound
|
||||
};
|
||||
style.normal.textColor = Color.white;
|
||||
|
||||
string prompt = _currentInteractable.GetInteractionPrompt();
|
||||
|
||||
if (_isInteracting)
|
||||
string prompt = "";
|
||||
|
||||
if (_currentInteractable != null)
|
||||
{
|
||||
prompt += " (진행 중...)";
|
||||
style.normal.textColor = Color.yellow;
|
||||
prompt = _currentInteractable.GetInteractionPrompt();
|
||||
|
||||
bool isResource = _currentInteractable is Resource;
|
||||
if (isResource && assignedWorker != null && assignedWorker.OwnerPlayerId == OwnerClientId)
|
||||
{
|
||||
prompt += " (워커 할당 가능)";
|
||||
}
|
||||
|
||||
if (_isInteracting)
|
||||
{
|
||||
prompt += " (진행 중...)";
|
||||
style.normal.textColor = Color.yellow;
|
||||
}
|
||||
}
|
||||
|
||||
GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 100, 400, 50), prompt, style);
|
||||
if (assignedWorker != null && assignedWorker.OwnerPlayerId == OwnerClientId)
|
||||
{
|
||||
string workerStatus = assignedWorker.CurrentState switch
|
||||
{
|
||||
WorkerState.Following => "따라가는 중",
|
||||
WorkerState.Mining => "채굴 중",
|
||||
WorkerState.Returning => "반환 중",
|
||||
_ => "대기 중"
|
||||
};
|
||||
|
||||
GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 150, 400, 50),
|
||||
$"워커: {workerStatus} (가방: {assignedWorker.CurrentBagResources}/{assignedWorker.maxBagCapacity})",
|
||||
style);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 150, 400, 50),
|
||||
$"워커: 미할당",
|
||||
style);
|
||||
}
|
||||
|
||||
if (_currentInteractable != null)
|
||||
{
|
||||
GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 100, 400, 50), prompt, style);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
|
||||
Reference in New Issue
Block a user