Files
ft/Client/Assets/Scripts/EventSmash/Act/EventSmashAct.cs
2026-06-29 21:18:33 +08:00

63 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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()
{
}
}
}