4dad9e5d5b
- BeatSageUploader: audio_url 지원(UploadFromUrl), PollAndDownload 공통화, ZIP 500 오류 3회 재시도 - BeatSageConverter: info.dat 파싱(SongMetadata), BPM 자동 감지 → 노트 타이밍 변환에 적용 - SongCreatorManager: title/BPM 필수 입력 제거, 난이도 4개 자동 선택, GenerateFlowFromUrl 버그 수정 - NasPublisher: audioPath null 허용(URL 흐름에서 로컬 파일 없는 경우 스킵) - .gitignore/.gitattributes 초기 설정 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
|
|
namespace VRSDK
|
|
{
|
|
public class EnemySpawner : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject[] enemies = null;
|
|
[SerializeField] private float spawnTime = 5.0f;
|
|
[SerializeField] private float spawnRadius = 1.0f;
|
|
[SerializeField] private int maxEnemies = 10;
|
|
|
|
|
|
private float timer = 0.0f;
|
|
|
|
private void Awake()
|
|
{
|
|
timer = Random.Range(spawnTime / 2.0f , spawnTime);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
timer -= Time.deltaTime;
|
|
|
|
if(timer <= 0.0f)
|
|
Spawn();
|
|
}
|
|
|
|
//creates a new enemy
|
|
private void Spawn()
|
|
{
|
|
timer = Random.Range(spawnTime / 2.0f, spawnTime);
|
|
|
|
//check if dont have to many enemies already
|
|
if (GameObject.FindGameObjectsWithTag( "Enemy" ).Length > maxEnemies)
|
|
return;
|
|
|
|
GameObject enemy = enemies[Random.Range(0 , enemies.Length)];
|
|
|
|
if (RandomNavmeshLocation(spawnRadius, out Vector3 spawnPoint))
|
|
{
|
|
Instantiate(enemy, spawnPoint, transform.rotation);
|
|
}
|
|
}
|
|
|
|
|
|
//return a random point inside the navmesh radius
|
|
private bool RandomNavmeshLocation(float radius, out Vector3 spawnPosition)
|
|
{
|
|
Vector3 randomDirection = Random.insideUnitSphere * radius;
|
|
randomDirection += transform.position;
|
|
NavMeshHit hit;
|
|
spawnPosition = Vector3.zero;
|
|
|
|
if (NavMesh.SamplePosition(randomDirection, out hit, radius, 1))
|
|
{
|
|
spawnPosition = hit.position;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|