타워 자동 공격 시스템 수정
이전 타워 수정의 사이드 이펙트 미사용 SO 제거
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8c40fef5ebc37b743a3f225c1ca57c32, type: 3}
|
||||
m_Name: Tower001
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Northbound.Data.TowerData
|
||||
id: 1
|
||||
memo: "\uD0C0\uC6CC"
|
||||
mana: 25
|
||||
manpower: 10
|
||||
sizeX: 3
|
||||
sizeY: 3
|
||||
maxHp: 50
|
||||
atkRange: 10
|
||||
atkDamage: 5
|
||||
atkIntervalSec: 2
|
||||
prefabPath: Assets/Prefabs/TowerArrow
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d75326370af2a2840958aae74db56dee
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8c40fef5ebc37b743a3f225c1ca57c32, type: 3}
|
||||
m_Name: Tower002
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Northbound.Data.TowerData
|
||||
id: 2
|
||||
memo: "\uBCBD"
|
||||
mana: 5
|
||||
manpower: 5
|
||||
sizeX: 1
|
||||
sizeY: 1
|
||||
maxHp: 30
|
||||
atkRange: 0
|
||||
atkDamage: 0
|
||||
atkIntervalSec: 0
|
||||
prefabPath: Assets/Prefabs/Wall
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df145fdd58f30464eb4eb02cfbfb280d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -14,6 +14,7 @@ GameObject:
|
||||
- component: {fileID: 8546144977850478548}
|
||||
- component: {fileID: -4086363217010332088}
|
||||
- component: {fileID: 4822792797652874450}
|
||||
- component: {fileID: -6756709031183627887}
|
||||
m_Layer: 0
|
||||
m_Name: TowerTemplate
|
||||
m_TagString: Untagged
|
||||
@@ -144,3 +145,20 @@ MonoBehaviour:
|
||||
minHeightForDistantVisibility: 3
|
||||
useExploredMaterial: 0
|
||||
exploredMaterial: {fileID: 0}
|
||||
--- !u!114 &-6756709031183627887
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7169488976654481418}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8dd1c341faa09554aa2bc35164888453, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Northbound.AutoTargetSystem
|
||||
ShowTopMostFoldoutHeaderGroup: 1
|
||||
targetLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 2304
|
||||
showDebugInfo: 1
|
||||
|
||||
@@ -195,6 +195,7 @@ GameObject:
|
||||
- component: {fileID: 100877884298911200}
|
||||
- component: {fileID: 8485093670801034058}
|
||||
- component: {fileID: 7262612124217315611}
|
||||
- component: {fileID: 2379635900458054490}
|
||||
m_Layer: 0
|
||||
m_Name: Tower1
|
||||
m_TagString: Untagged
|
||||
@@ -326,3 +327,20 @@ MonoBehaviour:
|
||||
minHeightForDistantVisibility: 3
|
||||
useExploredMaterial: 0
|
||||
exploredMaterial: {fileID: 0}
|
||||
--- !u!114 &2379635900458054490
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8512676738329978770}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8dd1c341faa09554aa2bc35164888453, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Northbound.AutoTargetSystem
|
||||
ShowTopMostFoldoutHeaderGroup: 1
|
||||
targetLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 2304
|
||||
showDebugInfo: 1
|
||||
|
||||
@@ -14,6 +14,7 @@ GameObject:
|
||||
- component: {fileID: 2615519446934682856}
|
||||
- component: {fileID: 3203720634638459019}
|
||||
- component: {fileID: 3906797260079127802}
|
||||
- component: {fileID: 7538736331158383620}
|
||||
m_Layer: 0
|
||||
m_Name: Tower2
|
||||
m_TagString: Untagged
|
||||
@@ -145,6 +146,23 @@ MonoBehaviour:
|
||||
minHeightForDistantVisibility: 3
|
||||
useExploredMaterial: 0
|
||||
exploredMaterial: {fileID: 0}
|
||||
--- !u!114 &7538736331158383620
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3671057791414486316}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8dd1c341faa09554aa2bc35164888453, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Northbound.AutoTargetSystem
|
||||
ShowTopMostFoldoutHeaderGroup: 1
|
||||
targetLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 2304
|
||||
showDebugInfo: 1
|
||||
--- !u!1 &8947776510381915047
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -9,33 +9,27 @@ namespace Northbound
|
||||
public class AutoTargetSystem : NetworkBehaviour
|
||||
{
|
||||
[Header("Targeting")]
|
||||
[Tooltip("적을 감지하는 범위")]
|
||||
public float detectionRange = 15f;
|
||||
|
||||
[Tooltip("공격 가능한 범위")]
|
||||
public float attackRange = 10f;
|
||||
|
||||
[Tooltip("공격 간격 (초)")]
|
||||
public float attackInterval = 1f;
|
||||
|
||||
[Tooltip("탐지할 레이어")]
|
||||
public LayerMask targetLayer = ~0;
|
||||
|
||||
[Header("Combat")]
|
||||
[Tooltip("공격 데미지")]
|
||||
public int attackDamage = 10;
|
||||
|
||||
[Header("Debug")]
|
||||
[Tooltip("디버그 정보 표시")]
|
||||
public bool showDebugInfo = true;
|
||||
|
||||
private Building _building;
|
||||
private ITeamMember _teamMember;
|
||||
private float _lastAttackTime;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_building = GetComponent<Building>();
|
||||
_teamMember = GetComponent<ITeamMember>();
|
||||
|
||||
if (_building == null)
|
||||
{
|
||||
Debug.LogError($"<color=red>[AutoTargetSystem] {gameObject.name}에 Building 컴포넌트가 없습니다!</color>");
|
||||
}
|
||||
|
||||
if (_teamMember == null)
|
||||
{
|
||||
Debug.LogError($"<color=red>[AutoTargetSystem] {gameObject.name}에 ITeamMember 컴포넌트가 없습니다!</color>");
|
||||
@@ -45,9 +39,9 @@ namespace Northbound
|
||||
private void Update()
|
||||
{
|
||||
if (!IsServer) return;
|
||||
if (_teamMember == null) return;
|
||||
if (_building == null || _teamMember == null) return;
|
||||
|
||||
if (Time.time - _lastAttackTime >= attackInterval)
|
||||
if (Time.time - _lastAttackTime >= _building.buildingData.atkIntervalSec)
|
||||
{
|
||||
FindAndAttackEnemy();
|
||||
}
|
||||
@@ -55,6 +49,10 @@ namespace Northbound
|
||||
|
||||
private void FindAndAttackEnemy()
|
||||
{
|
||||
float detectionRange = _building.buildingData.atkRange;
|
||||
float attackRange = _building.buildingData.atkRange;
|
||||
int attackDamage = _building.buildingData.atkDamage;
|
||||
|
||||
// 범위 내 모든 콜라이더 탐지
|
||||
Collider[] colliders = Physics.OverlapSphere(transform.position, detectionRange, targetLayer);
|
||||
|
||||
@@ -152,13 +150,17 @@ namespace Northbound
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (_building == null || _building.buildingData == null) return;
|
||||
|
||||
float range = _building.buildingData.atkRange;
|
||||
|
||||
// 탐지 범위 (노란색)
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawWireSphere(transform.position, detectionRange);
|
||||
Gizmos.DrawWireSphere(transform.position, range);
|
||||
|
||||
// 공격 범위 (빨간색)
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawWireSphere(transform.position, attackRange);
|
||||
Gizmos.DrawWireSphere(transform.position, range);
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
@@ -166,10 +168,10 @@ namespace Northbound
|
||||
OnDrawGizmos();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (_teamMember != null && Application.isPlaying)
|
||||
if (_teamMember != null && _building != null && _building.buildingData != null && Application.isPlaying)
|
||||
{
|
||||
UnityEditor.Handles.Label(transform.position + Vector3.up * 3f,
|
||||
$"Auto Target\nTeam: {TeamManager.GetTeamName(_teamMember.GetTeam())}\nDetection: {detectionRange}m\nAttack: {attackRange}m");
|
||||
$"Auto Target\nTeam: {TeamManager.GetTeamName(_teamMember.GetTeam())}\nRange: {_building.buildingData.atkRange}m\nDamage: {_building.buildingData.atkDamage}");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user