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

62 lines
2.5 KiB
C#
Raw Permalink 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.Collections.Generic;
using System.Threading.Tasks;
using asap.core;
using game;
using Game;
using GameCore;
using UnityEngine;
namespace EventBossFight
{
/// <summary>
/// Boss 战场景 Act进入时从 <see cref="FishingAct"/> 切换过来,关闭主界面时 <see cref="game.UnloadActToNextAct"/> 切回钓鱼。
/// 需在 Addressables 中注册与 <see cref="ActAddress"/> 同名的预制体(可仅挂本组件的空物体)。
/// </summary>
public class EventBossFightAct : AGameAct
{
public const string ActAddress = nameof(EventBossFightAct);
public override async Task<bool> StartAsync()
{
var manager = GContext.container.Resolve<EventBossFightManager>();
var data = manager?.Data;
if (data?.InitConfig == null)
{
Debug.LogError("[EventBossFightAct] InitConfig 为空,无法打开 Boss 战,切回 FishingAct。");
GContext.Publish(new UnloadActToNextAct("FishingAct"));
GContext.Publish(new EndTransition());
return await base.StartAsync();
}
var bossKey = EventBossFightBossBundleKeys.GetAddressableKey(data.InitConfig, data.StageCountFrom1);
if (!string.IsNullOrEmpty(bossKey))
{
var loadResourceService = GContext.container.Resolve<ILoadResourceService>();
var queueKey = EventBossFightBossBundleKeys.GetBossResourceLoadQueueKey(bossKey);
await loadResourceService.CheckResourceLoadQueue(queueKey, new List<string> { bossKey });
}
UITypes.EventBossFightPanel.SetType(data.InitConfig.UIPanel);
await UIManager.Instance.ShowUILoad(UITypes.EventBossFightPanel);
GContext.Publish(new EndTransition());
return await base.StartAsync();
}
public override async Task StopAsync()
{
UIManager.Instance.DestroyUI(UITypes.EventBossFightPanel);
UIManager.Instance.DestroyUI(UITypes.EventBossFightInfoPanel);
UIManager.Instance.DestroyUI(UITypes.EventBossFightFestPackPanel);
UIManager.Instance.DestroyUI(UITypes.EventBossFightReviewPopupPanel);
UIManager.Instance.DestroyUI(UITypes.EventBossFightEndingPopupPanel);
UIManager.Instance.DestroyUI(UITypes.EventBossFightRewardPopupPanel);
await base.StopAsync();
}
protected override void OnDestroy()
{
}
}
}