Files
Northbound/Assets/Scripts/CreepDataComponent.cs
dal4segno dc4d71d4b6 데이터 파이프라인 추가 및 수정 + 크립 및 크립 캠프 배치 자동화
Hierachy > System > MapGenerator 에서 크립 관련 변수 설정 가능
Kaykit PlantWarrior 애셋 추가
2026-02-02 19:50:30 +09:00

63 lines
1.9 KiB
C#

using Northbound.Data;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
namespace Northbound
{
[RequireComponent(typeof(EnemyUnit))]
[RequireComponent(typeof(EnemyAIController))]
[RequireComponent(typeof(NavMeshAgent))]
[RequireComponent(typeof(NetworkObject))]
public class CreepDataComponent : MonoBehaviour
{
[Header("Data Reference")]
[Tooltip("ScriptableObject containing creep data")]
public CreepData creepData;
[Header("Auto-Apply Settings")]
[Tooltip("Automatically apply stats from creepData on Awake")]
public bool autoApplyOnAwake = true;
private void Awake()
{
if (autoApplyOnAwake && creepData != null)
{
ApplyCreepData();
}
}
public void ApplyCreepData()
{
if (creepData == null)
{
Debug.LogWarning("[CreepDataComponent] creepData is null", this);
return;
}
EnemyUnit enemyUnit = GetComponent<EnemyUnit>();
if (enemyUnit != null)
{
enemyUnit.maxHealth = creepData.maxHp;
}
EnemyAIController aiController = GetComponent<EnemyAIController>();
if (aiController != null)
{
aiController.moveSpeed = creepData.moveSpeed;
aiController.attackDamage = creepData.atkDamage;
aiController.attackRange = creepData.atkRange;
aiController.attackInterval = creepData.atkIntervalSec;
}
NavMeshAgent navAgent = GetComponent<NavMeshAgent>();
if (navAgent != null)
{
navAgent.speed = creepData.moveSpeed;
}
Debug.Log($"[CreepDataComponent] Applied data for {creepData.id} ({creepData.memo})", this);
}
}
}