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

77 lines
1.9 KiB
C#
Raw Normal View History

using cfg.ShowCfg;
using Cysharp.Threading.Tasks;
using PhxhSDK;
using System;
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>
2024-04-19 19:32:11 +08:00
public async void RefreshShow(E_ShowSceneType showSceneType, object data = null)
{
if (TryGetShow(showSceneType, out IShow show))
2024-04-19 19:32:11 +08:00
await show.RefreshShow(data);
}
/// <summary>
/// 播放相机动画
/// </summary>
/// <param name="showSceneType">演出场景类型</param>
/// <param name="callbackAction">动画播放完成回调</param>
2024-06-19 13:59:31 +08:00
public void PlayCameraAnim(E_ShowSceneType showSceneType, Action callbackAction, params string[] args)
{
if (TryGetShow(showSceneType, out IShow show))
2024-06-19 13:59:31 +08:00
show.PlayeCameraAnim(callbackAction, args);
}
/// <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)
{
2024-03-19 16:57:10 +08:00
return dicShow.TryGetValue(showSceneType, out show) && show != null;
}
}