123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityGameFramework.Runtime;
- using GameFramework.Event;
- using BattleDefine;
- namespace YLBattle
- {
- /// </summary>
- public class SpawnerSystem : MonoBehaviour
- {
- /// <summary>
- /// 单键
- /// </summary>
- private static SpawnerSystem m_Instance;
- private Dictionary<int, ZoneSpawnerLogic> _spawnerDict;
- private EBattleSceneType _battleType;
- public int crateGroupNowNum;
- public int crateGroupMax;
- /// <summary>
- /// 单键
- /// </summary>
- public static SpawnerSystem Instance
- {
- get
- {
- if (m_Instance == null)
- {
- m_Instance = GameObject.Find("SpawnerSystem").AddComponent<SpawnerSystem>();
- }
- return m_Instance;
- }
- }
- public void Awake()
- {
- _spawnerDict = new Dictionary<int, ZoneSpawnerLogic>();
- 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<int, ZoneSpawnerLogic> 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;
- }
- }
- }
- }
- }
|