Files
Northbound/Assets/Scripts/EnemyPortal.cs
dal4segno a9a744589d 전장의 안개 기능 개선
미탐험 구역의 모든 오브젝트는 보이지 않음
적이 시야를 제공하는 문제 수정
높은 장애물은 더 먼 거리에서부터 보일 수 있음
2026-01-30 16:04:22 +09:00

45 lines
1.3 KiB
C#

using Northbound;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
using static Northbound.ObstacleSpawner;
using static UnityEditor.FilePathAttribute;
public class EnemyPortal : MonoBehaviour
{
[Header("Spawn Settings")]
[Tooltip("소환할 몬스터 목록")]
[SerializeField] private List<GameObject> Enemies = new();
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
GlobalTimer.Instance.OnCycleComplete += SpawnEnemy;
}
private void SpawnEnemy()
{
foreach (GameObject obj in Enemies)
{
GameObject enemy = Instantiate(obj, transform);
// Add FogOfWarVisibility component to hide enemies in unexplored areas
if (enemy.GetComponent<FogOfWarVisibility>() == null)
{
var visibility = enemy.AddComponent<FogOfWarVisibility>();
visibility.showInExploredAreas = false; // Enemies hidden when not visible
visibility.updateInterval = 0.2f;
}
enemy.GetComponent<NetworkObject>().Spawn();
Debug.Log(enemy);
}
}
// Update is called once per frame
void Update()
{
}
}