데이터 파이프라인 추가 및 수정 + 크립 및 크립 캠프 배치 자동화
Hierachy > System > MapGenerator 에서 크립 관련 변수 설정 가능 Kaykit PlantWarrior 애셋 추가
This commit is contained in:
62
Assets/Scripts/CreepDataComponent.cs
Normal file
62
Assets/Scripts/CreepDataComponent.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user