NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Show/ShowManager.cs

65 lines
1.5 KiB
C#

using cfg.ShowCfg;
using Cysharp.Threading.Tasks;
using PhxhSDK;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 演出管理器
/// </summary>
public class ShowManager : Singlenton<ShowManager>, IInitable
{
private Dictionary<E_ShowSceneType, IShow> dicShow;
public void Init()
{
dicShow = new();
}
public void Release()
{
dicShow.Clear();
dicShow = null;
}
public void Add(IShow show)
{
dicShow[show.ShowSceneTyp] = show;
}
/// <summary>
/// 刷新演出
/// </summary>
/// <param name="showSceneType"></param>
/// <returns></returns>
public async UniTask RefreshShow(E_ShowSceneType showSceneType)
{
if (TryGetShow(showSceneType, out IShow show))
await show.RefreshShow();
}
/// <summary>
/// 获取刷新进度
/// </summary>
/// <param name="showSceneType"></param>
/// <returns></returns>
public float GetRefreshProcess(E_ShowSceneType showSceneType)
{
if (TryGetShow(showSceneType, out IShow show))
return show.GetRefreshProcess();
else
return 0f;
}
/// <summary>
/// 获取演出
/// </summary>
/// <param name="showSceneType"></param>
/// <returns></returns>
private bool TryGetShow(E_ShowSceneType showSceneType, out IShow show)
{
return dicShow.TryGetValue(showSceneType, out show) && show != null;
}
}