62 lines
2.5 KiB
C#
62 lines
2.5 KiB
C#
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()
|
||
{
|
||
}
|
||
}
|
||
}
|