Files
gold_dolphin/unity/Assets/Script/Managers/SceneMonsterManager.cs
2026-06-20 19:35:25 +08:00

61 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
public class SceneMonsterManager : MonoBehaviour
{
[SerializeField, Header("怪物列表")] private List<GameObject> monsters = new List<GameObject>();
[SerializeField, Header("怪物生成速率")] private float timer;
public Transform teleporte;
public bool isTeleport = false;
public GameObject box;
private int count = 0;
private float t = 0;
private void Awake()
{
foreach (var item in monsters)
{
item.SetActive(false);
}
}
private void Update()
{
t += Time.deltaTime;
if (t >= timer)
{
Debug.Log(isTeleport);
ABC();
ProtectedMonster();
}
}
void ProtectedMonster()
{
if (count >= monsters.Count)
{
return;
}
monsters[count].SetActive(true);
count += 1;
t = 0;
}
void ABC()
{
if(transform.childCount==0&&!isTeleport)
{
//UIManager.Instance.Show<UILottery>();
Instantiate(box);
isTeleport = true;
}
}
}