using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityGameFramework.Runtime; using GameFramework.Event; using BattleDefine; namespace YLBattle { /// public class SpawnerSystem : MonoBehaviour { /// /// 单键 /// private static SpawnerSystem m_Instance; private Dictionary _spawnerDict; private EBattleSceneType _battleType; public int crateGroupNowNum; public int crateGroupMax; /// /// 单键 /// public static SpawnerSystem Instance { get { if (m_Instance == null) { m_Instance = GameObject.Find("SpawnerSystem").AddComponent(); } return m_Instance; } } public void Awake() { _spawnerDict = new Dictionary(); crateGroupNowNum = 0; crateGroupMax = 0; } public void Start() { } public void Init() { Reset(); } public void Add(ZoneSpawnerLogic spawner) { _spawnerDict[spawner.spawnerInfo.index] = spawner; } public ZoneSpawnerLogic GetSpawnerByIndex(int index) { return _spawnerDict[index]; } public Dictionary GetAllSpawner() { return _spawnerDict; } public void OpenSystem() { foreach(var item in _spawnerDict) { item.Value.IsClose = false; } } public void CloseSystem() { foreach (var item in _spawnerDict) { item.Value.IsClose = true; } } public void Reset() { foreach(var item in _spawnerDict) { item.Value.Reset(); } } public void SetBattleType(EBattleSceneType btType) { _battleType = btType; } public EBattleSceneType GetBattleType() { return _battleType; } public bool IsCloseAllSpawner() { foreach(var item in _spawnerDict) { if(item.Value.GetAllRole().Count > 0) { return false; } } return true; } public bool IsLastSpawner() { foreach (var item in _spawnerDict) { if (!item.Value.IsLastNode()) { return false; } } return true; } public void EnableSpawnerByIndex(int index) { _spawnerDict[index].EnableSpawner(); } public void EnableSpawnerByNext() { foreach (var item in _spawnerDict) { if (!item.Value.IsCreateFinish()) { item.Value.EnableSpawner(); break; } } } } }