1
This commit is contained in:
60
unity/Assets/Script/Managers/SceneMonsterManager.cs
Normal file
60
unity/Assets/Script/Managers/SceneMonsterManager.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user