using cfg.ShowCfg;
using Gameplay.Show;
using PhxhSDK;
using PhxhSDK.Res;
using System;
using System.Collections.Generic;
///
/// 演出管理器
///
public class ShowManager : Singlenton, IInitable, IUpdatable
{
private Dictionary dicShow;
private ShopShowController shopShowController;
public void Init()
{
shopShowController = new ShopShowController();
dicShow = new()
{
[E_ShowSceneType.Main] = new ShowController(),
[E_ShowSceneType.Camp] = new ShowController(),
[E_ShowSceneType.Raffle] = new RaffleShowController(),
[E_ShowSceneType.Shop] = shopShowController,
};
}
public void Update(float deltaTime)
{
shopShowController.Update();
}
public void Release()
{
dicShow.Clear();
dicShow = null;
}
///
/// 刷新演出
///
///
///
public async void RefreshShow(E_ShowSceneType showSceneType, object data = null)
{
SceneHandle sceneHandle = GameSceneHelper.Instance.GetCurrentUIViewScene();
switch (showSceneType)
{
case E_ShowSceneType.Main:
case E_ShowSceneType.Camp:
{
ShowComponent showComponent = SceneHandle.GetSceneRootComponent(sceneHandle.Scene);
if (null == showComponent)
return;
if (!TryGetShow(showSceneType, out IShow show))
return;
if (show is not ShowController showController)
return;
showController.SetInfo(showComponent);
await show.RefreshShow(data);
}
break;
case E_ShowSceneType.Raffle:
{
RaffleShowComponent raffleShowComponent = SceneHandle.GetSceneRootComponent(sceneHandle.Scene);
if (null == raffleShowComponent)
return;
if (!TryGetShow(showSceneType, out IShow show))
return;
if (show is not RaffleShowController raffleShowController)
return;
raffleShowController.SetInfo(raffleShowComponent);
await show.RefreshShow(data);
}
break;
case E_ShowSceneType.Shop:
{
ShopShowComponent shopShowComponent = SceneHandle.GetSceneRootComponent(sceneHandle.Scene);
if (null == shopShowComponent)
return;
if (!TryGetShow(showSceneType, out IShow show))
return;
if (show is not ShopShowController shopShowController)
return;
shopShowController.SetInfo(shopShowComponent);
await show.RefreshShow(data);
}
break;
}
}
///
/// 播放相机动画
///
/// 演出场景类型
/// 动画播放完成回调
public void PlayCameraAnim(E_ShowSceneType showSceneType, Action callbackAction, params string[] args)
{
SceneHandle sceneHandle = GameSceneHelper.Instance.GetCurrentUIViewScene();
switch (showSceneType)
{
case E_ShowSceneType.Main:
{
ShowComponent showComponent = SceneHandle.GetSceneRootComponent(sceneHandle.Scene);
if (null == showComponent)
return;
if (!TryGetShow(showSceneType, out IShow show))
return;
if (show is not ShowController showController)
return;
showController.SetInfo(showComponent);
show.PlayeCameraAnim(callbackAction, args);
}
break;
case E_ShowSceneType.Shop:
{
ShopShowComponent shopShowComponent = SceneHandle.GetSceneRootComponent(sceneHandle.Scene);
if (null == shopShowComponent)
return;
if (!TryGetShow(showSceneType, out IShow show))
return;
if (show is not ShopShowController shopShowController)
return;
shopShowController.SetInfo(shopShowComponent);
show.PlayeCameraAnim(callbackAction, args);
}
break;
}
}
///
/// 获取演出
///
///
///
private bool TryGetShow(E_ShowSceneType showSceneType, out IShow show)
{
return dicShow.TryGetValue(showSceneType, out show) && show != null;
}
}