63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
using System.Threading.Tasks;
|
||
using Activity;
|
||
using asap.core;
|
||
using EventSmash.Manager;
|
||
using game;
|
||
using Game;
|
||
using GameCore;
|
||
using UnityEngine;
|
||
|
||
namespace EventSmash
|
||
{
|
||
/// <summary>
|
||
/// 砸罐(开小猪)活动 Act:从 <see cref="FishingAct"/> 切换后打开主面板;离开时销毁相关 UI 并回到钓鱼场景 Act。
|
||
/// 需在 Addressables 中注册与 <see cref="ActAddress"/> 同名的预制体(可仅挂本组件的空物体)。
|
||
/// UI 与 <see cref="MatchGameAct"/> 一致按表路径 <c>new UIType(...)</c>,不依赖 <see cref="UITypes"/> 静态项。
|
||
/// </summary>
|
||
public class EventSmashAct : AGameAct
|
||
{
|
||
public const string ActAddress = nameof(EventSmashAct);
|
||
|
||
private string _uiPanelPath;
|
||
private string _packPanelPath;
|
||
private string _battlePassPanelPath;
|
||
|
||
public override async Task<bool> StartAsync()
|
||
{
|
||
var manager = ActivityResolver.Resolve<EventSmashManager>();
|
||
var data = manager?.LoadData();
|
||
if (data == null || !data.IsActive || data.MainConfig == null)
|
||
{
|
||
Debug.LogError("[EventSmashAct] 活动数据或 MainConfig 无效,无法打开砸罐界面,切回 FishingAct。");
|
||
GContext.Publish(new UnloadActToNextAct("FishingAct"));
|
||
GContext.Publish(new EndTransition());
|
||
return await base.StartAsync();
|
||
}
|
||
|
||
var main = data.MainConfig;
|
||
_uiPanelPath = main.UIPanel;
|
||
_packPanelPath = main.PackPanel;
|
||
_battlePassPanelPath = main.BattlePassPanel;
|
||
|
||
await UIManager.Instance.ShowUILoad(new UIType(_uiPanelPath));
|
||
GContext.Publish(new EndTransition());
|
||
return await base.StartAsync();
|
||
}
|
||
|
||
public override async Task StopAsync()
|
||
{
|
||
if (!string.IsNullOrEmpty(_uiPanelPath))
|
||
UIManager.Instance.DestroyUI(new UIType(_uiPanelPath));
|
||
if (!string.IsNullOrEmpty(_packPanelPath))
|
||
UIManager.Instance.DestroyUI(new UIType(_packPanelPath));
|
||
if (!string.IsNullOrEmpty(_battlePassPanelPath))
|
||
UIManager.Instance.DestroyUI(new UIType(_battlePassPanelPath));
|
||
await base.StopAsync();
|
||
}
|
||
|
||
protected override void OnDestroy()
|
||
{
|
||
}
|
||
}
|
||
}
|