시야감지 작업 완료 에너미 상태 완료 상태 변환 로직 완료 필요한건 todo 파일 보면서 확인 할 것 Todo 1. 에너미 추가학기 위한 path 하는 작업 하기
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SpawnController : MonoBehaviour
|
|
{
|
|
private Dictionary<string, EnemyData> _enemyDatas;
|
|
|
|
[SerializeField] private string _enemyPrefabPath; // 스폰할 프리팹
|
|
[SerializeField] private string _enemyDataPath; // 스폰할 프리팹
|
|
[SerializeField] private LayerMask _spawnedTargetLayers; // 스포너 Inspector에서 설정
|
|
[SerializeField] private LayerMask _spawnedObstacleLayers; // 스포너 Inspector에서 설정
|
|
int monsterCount = 0;
|
|
|
|
public string EnemyPrefabPath { get { return _enemyPrefabPath; } set { _enemyPrefabPath = value; }}
|
|
public string EnemyDataPath { get { return _enemyDataPath; } set { _enemyDataPath = value; }}
|
|
|
|
void Awake()
|
|
{
|
|
_enemyDatas =
|
|
Manager.Data.LoadToDict<EnemyDataLoader, string, EnemyData>(EnemyDataPath, (enemy) => enemy.name);
|
|
|
|
//"Data/E_Test1"
|
|
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
// GameObject enemy = Manager.Resource.Instantiate("Prefabs/Characters/Test_Enemy");
|
|
// enemy.AddComponent<EnemyController>();
|
|
// enemy.transform.position = new Vector3(0,0,10);
|
|
|
|
}
|
|
// Prefabs/Characters/{_enemyPrefab.name}
|
|
void Update()
|
|
{
|
|
float radius = 2.0f;
|
|
if (EnemyPrefabPath == null ) return;
|
|
for (; monsterCount < 5; monsterCount++)
|
|
{
|
|
float angle = monsterCount * Mathf.PI * 2 / 5;
|
|
Vector3 pos = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * radius + new Vector3(0, 0, 10);
|
|
GameObject enemy = Manager.Resource.Instantiate(EnemyPrefabPath);
|
|
enemy.AddComponent<EnemyController>();
|
|
enemy.transform.position = pos;
|
|
}
|
|
}
|
|
}
|