2023-10-19 15:00:19 +08:00
|
|
|
|
using Framework;
|
|
|
|
|
|
using Gameplay.Net;
|
|
|
|
|
|
using System;
|
2024-01-30 15:10:12 +08:00
|
|
|
|
using System.Collections.Generic;
|
2023-11-22 15:05:43 +08:00
|
|
|
|
using Code.Scripts.Gameplay.Game;
|
2024-03-22 12:09:11 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
2024-07-24 17:33:23 +08:00
|
|
|
|
using Gameplay.Guide;
|
2024-08-14 15:00:35 +08:00
|
|
|
|
using NLDPB;
|
2024-01-19 19:20:05 +08:00
|
|
|
|
using UnityEngine;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using Debug = DebugUtil;
|
2024-09-23 17:40:22 +08:00
|
|
|
|
using cfg.LevelCfg;
|
2024-09-27 19:56:25 +08:00
|
|
|
|
using Gameplay.Effect;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Gameplay.Level
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class LevelManager
|
|
|
|
|
|
{
|
|
|
|
|
|
//todo 修改服务器回消息底层逻辑后处理进入关卡失败的逻辑
|
|
|
|
|
|
|
|
|
|
|
|
const int NO_LEVEL_FLAG = -1;
|
|
|
|
|
|
|
|
|
|
|
|
private int _levelIDTryToEnter = NO_LEVEL_FLAG;
|
2024-06-27 13:22:21 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 剧情加载完成后是否立即播放
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private bool isPlay;
|
2023-12-26 18:19:05 +08:00
|
|
|
|
private object _levelParam;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
private Action _enterLevelFinishCallBack;
|
|
|
|
|
|
private Action _exitLevelFinishCallBack;
|
2024-05-31 14:06:02 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 退出关卡是否切换主场景回调
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Func<bool> ExitLevelChangeMainFunc;
|
2023-11-22 15:05:43 +08:00
|
|
|
|
|
2024-04-11 19:02:11 +08:00
|
|
|
|
private int _bgmID;
|
|
|
|
|
|
|
2023-11-22 15:05:43 +08:00
|
|
|
|
public bool IsInLevel { get; private set; }
|
2023-10-19 15:00:19 +08:00
|
|
|
|
public bool IsSuccess { get; private set; }
|
2024-09-20 18:33:26 +08:00
|
|
|
|
public LevelInfo CurrLevel { get; set; }
|
2024-09-20 19:00:18 +08:00
|
|
|
|
public bool IsSweep { get; set; }
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
|
|
|
|
|
private void InitAction()
|
|
|
|
|
|
{
|
2023-11-22 15:05:43 +08:00
|
|
|
|
IsInLevel = false;
|
|
|
|
|
|
CurrLevel = null;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
RegisterEventAction();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ReleaseAction()
|
|
|
|
|
|
{
|
|
|
|
|
|
UnregisterEventAction();
|
|
|
|
|
|
_enterLevelFinishCallBack = null;
|
|
|
|
|
|
_exitLevelFinishCallBack = null;
|
2023-12-26 18:19:05 +08:00
|
|
|
|
_levelParam = null;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RegisterEventAction()
|
|
|
|
|
|
{
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.ServerResponseEnterLevel, OnServerResponseEnterLevel);
|
2023-11-22 15:05:43 +08:00
|
|
|
|
EventManager.Instance.Register<ItemList>(EventManager.EventName.ServerResponseExitLevel,
|
|
|
|
|
|
OnServerResponseExitLevel);
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UnregisterEventAction()
|
|
|
|
|
|
{
|
2023-11-22 15:05:43 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.ServerResponseEnterLevel,
|
|
|
|
|
|
OnServerResponseEnterLevel);
|
|
|
|
|
|
EventManager.Instance.Unregister<ItemList>(EventManager.EventName.ServerResponseExitLevel,
|
|
|
|
|
|
OnServerResponseExitLevel);
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//服务器回消息,进入关卡
|
|
|
|
|
|
private void OnServerResponseEnterLevel()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_levelIDTryToEnter != NO_LEVEL_FLAG)
|
|
|
|
|
|
{
|
2024-01-03 16:40:57 +08:00
|
|
|
|
_EnterLevelDirectly(_levelIDTryToEnter);
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
Debug.LogError($"levelID 不合法,无法进入关卡,levelID:{_levelIDTryToEnter}");
|
2023-11-22 15:05:43 +08:00
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
_levelIDTryToEnter = NO_LEVEL_FLAG;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 12:05:14 +08:00
|
|
|
|
private async void OnServerResponseExitLevel(ItemList itemList)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2023-11-22 15:05:43 +08:00
|
|
|
|
if (!IsInLevel)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("当前未处于关卡中");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-11-22 15:05:43 +08:00
|
|
|
|
|
|
|
|
|
|
if (CurrLevel.IsStory)
|
2024-01-03 16:40:57 +08:00
|
|
|
|
{
|
2024-08-14 15:00:35 +08:00
|
|
|
|
var filterItemList = CommonUtils.GetLevelRewardFilterItemList(itemList);
|
|
|
|
|
|
var listItem = new ListItem(filterItemList);
|
2024-07-31 16:52:31 +08:00
|
|
|
|
CommonUtils.FilterListItem(listItem);
|
2024-10-17 14:18:19 +08:00
|
|
|
|
|
|
|
|
|
|
if (GuideManager.Instance.IsGuiding && 300003 == CurrLevel.Cfg.Id) // 引导中不显示序章剧情3的奖励
|
|
|
|
|
|
{
|
|
|
|
|
|
ExitLevelDirectly(_exitLevelFinishCallBack);
|
|
|
|
|
|
_exitLevelFinishCallBack = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (listItem.Length > 0)
|
2024-07-25 19:27:59 +08:00
|
|
|
|
{
|
2024-07-31 17:10:02 +08:00
|
|
|
|
_EnterStorySettle(listItem);
|
2024-07-25 19:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ExitLevelDirectly(_exitLevelFinishCallBack);
|
|
|
|
|
|
_exitLevelFinishCallBack = null;
|
|
|
|
|
|
}
|
2024-08-14 15:00:35 +08:00
|
|
|
|
|
2024-01-03 16:40:57 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-04-11 19:02:11 +08:00
|
|
|
|
StopBGM();
|
2024-10-12 13:05:37 +08:00
|
|
|
|
//TeamManager.IsHideAllUI = true;
|
|
|
|
|
|
TeamManager.Instance.TeamUIClose();
|
2023-11-22 15:05:43 +08:00
|
|
|
|
if (IsSuccess)
|
|
|
|
|
|
{
|
2024-03-29 12:05:14 +08:00
|
|
|
|
// CommonUtils.CaptureScreenshot();
|
2024-04-08 18:58:23 +08:00
|
|
|
|
// UIManager.Instance.OpenWindow(UINameConst.UIMissionWin, itemList).Forget();
|
|
|
|
|
|
await ShowTransitionMgr.Instance.ShowLevelTransition(UI_LevelTransitionController.OpenType.Success);
|
2024-09-20 18:33:26 +08:00
|
|
|
|
await SettleSceneProcess(itemList, false);
|
2023-11-22 15:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-04-08 18:58:23 +08:00
|
|
|
|
await ShowTransitionMgr.Instance.ShowLevelTransition(UI_LevelTransitionController.OpenType.Fail);
|
2023-11-22 15:05:43 +08:00
|
|
|
|
if (!UIManager.Instance.IsWindowOpening(UINameConst.UIDefeatGame))
|
|
|
|
|
|
{
|
2024-04-03 12:52:49 +08:00
|
|
|
|
UIDefeatGameController.Open().Forget();
|
2023-11-22 15:05:43 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-01-19 19:20:05 +08:00
|
|
|
|
|
|
|
|
|
|
SaveFightLevel(CurrLevel);
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-03 16:40:57 +08:00
|
|
|
|
private void _EnterLevelDirectly(int levelID)
|
|
|
|
|
|
{
|
2024-09-05 13:41:39 +08:00
|
|
|
|
if (!Instance.TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
2024-01-03 16:40:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"关卡不存在,id:{levelID}");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (levelInfo.IsStory)
|
2024-09-02 15:32:25 +08:00
|
|
|
|
GameStateManager.Instance.ChangeState(new GameStateStory(levelInfo.Cfg.StoryID.ToString(), isPlay));
|
2024-01-03 16:40:57 +08:00
|
|
|
|
else
|
|
|
|
|
|
GameStateManager.Instance.ChangeState(new GameStateLevel(levelID));
|
|
|
|
|
|
CurrLevel = levelInfo;
|
|
|
|
|
|
IsInLevel = true;
|
|
|
|
|
|
_enterLevelFinishCallBack?.Invoke();
|
|
|
|
|
|
_enterLevelFinishCallBack = null;
|
2024-08-26 20:09:41 +08:00
|
|
|
|
// if (!levelInfo.IsStory)
|
|
|
|
|
|
// PlayBGM();
|
2024-01-03 16:40:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void _ExitLevelDirectly()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!CurrLevel.IsStory)
|
|
|
|
|
|
TeamManager.Instance.Release();
|
2024-05-31 14:06:02 +08:00
|
|
|
|
|
2024-09-02 14:55:43 +08:00
|
|
|
|
var levelID = CurrLevel.Cfg.Id;
|
2024-06-28 18:45:54 +08:00
|
|
|
|
var isPVP = false;
|
|
|
|
|
|
if (CurrentLevel != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
isPVP = CurrentLevel.IsPvPLevel;
|
|
|
|
|
|
}
|
2024-05-31 14:06:02 +08:00
|
|
|
|
|
|
|
|
|
|
if (null != ExitLevelChangeMainFunc && !ExitLevelChangeMainFunc.Invoke())
|
2024-09-06 14:06:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
CurrLevel = null;
|
|
|
|
|
|
IsInLevel = false;
|
2024-05-31 14:06:02 +08:00
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.GuideExitLevel);
|
2024-09-06 14:06:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2024-06-28 15:53:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (isPVP)
|
2024-09-02 13:29:23 +08:00
|
|
|
|
//GameStateManager.Instance.ChangeState(new GameStateMainScene());
|
|
|
|
|
|
GameStateManager.Instance.ChangeState(new GameStateMainScene(false,
|
2024-10-15 18:48:43 +08:00
|
|
|
|
async () =>
|
2024-09-05 19:59:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
CurrLevel = null;
|
|
|
|
|
|
IsInLevel = false;
|
2024-10-22 14:28:23 +08:00
|
|
|
|
if (!SignUpManager.Instance.NeedShowDailyAccumulate)
|
|
|
|
|
|
{
|
|
|
|
|
|
await JumpToManager.JumpFuncAsync(cfg.JumpFuncType.PVP_Main);
|
|
|
|
|
|
}
|
2024-09-05 19:59:32 +08:00
|
|
|
|
}));
|
2024-06-28 15:53:24 +08:00
|
|
|
|
else
|
2024-07-12 15:21:16 +08:00
|
|
|
|
GameStateManager.Instance.ChangeState(new GameStateMainScene(false,
|
2024-10-15 18:48:43 +08:00
|
|
|
|
async () =>
|
2024-09-05 19:59:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
CurrLevel = null;
|
|
|
|
|
|
IsInLevel = false;
|
2024-10-22 14:28:23 +08:00
|
|
|
|
if (!SignUpManager.Instance.NeedShowDailyAccumulate)
|
|
|
|
|
|
{
|
|
|
|
|
|
await JumpToManager.JumpFuncAsync(cfg.JumpFuncType.Level_Select, levelID);
|
|
|
|
|
|
}
|
2024-09-05 19:59:32 +08:00
|
|
|
|
}));
|
2024-06-28 15:53:24 +08:00
|
|
|
|
}
|
2024-05-31 14:06:02 +08:00
|
|
|
|
|
|
|
|
|
|
ExitLevelChangeMainFunc = null;
|
2024-01-03 16:40:57 +08:00
|
|
|
|
_exitLevelFinishCallBack?.Invoke();
|
|
|
|
|
|
_exitLevelFinishCallBack = null;
|
2024-01-17 12:57:07 +08:00
|
|
|
|
_cacheSettleData = null;
|
2024-01-03 16:40:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-10 20:01:31 +08:00
|
|
|
|
public void ExitLevelOnLogout()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsInLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!CurrLevel.IsStory)
|
|
|
|
|
|
TeamManager.Instance.Release();
|
|
|
|
|
|
|
|
|
|
|
|
var levelID = CurrLevel.Cfg.Id;
|
|
|
|
|
|
var isPVP = false;
|
|
|
|
|
|
if (CurrentLevel != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
isPVP = CurrentLevel.IsPvPLevel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != ExitLevelChangeMainFunc && !ExitLevelChangeMainFunc.Invoke())
|
|
|
|
|
|
{
|
|
|
|
|
|
CurrLevel = null;
|
|
|
|
|
|
IsInLevel = false;
|
|
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.GuideExitLevel);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
CurrLevel = null;
|
|
|
|
|
|
IsInLevel = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
ExitLevelChangeMainFunc = null;
|
|
|
|
|
|
_exitLevelFinishCallBack?.Invoke();
|
|
|
|
|
|
_exitLevelFinishCallBack = null;
|
|
|
|
|
|
_cacheSettleData = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-31 17:10:02 +08:00
|
|
|
|
private async void _EnterStorySettle(ListItem listItem)
|
|
|
|
|
|
{
|
2024-09-18 16:03:02 +08:00
|
|
|
|
CommonUtils.CaptureScreenshot();
|
2024-08-06 14:12:49 +08:00
|
|
|
|
await ShowTransitionMgr.Instance.EnterBlackTransition(true);
|
2024-07-31 17:10:02 +08:00
|
|
|
|
await ShowTransitionMgr.Instance.EnterBlack();
|
2024-08-14 15:00:35 +08:00
|
|
|
|
await UniTask.Delay(150);
|
2024-09-27 19:56:25 +08:00
|
|
|
|
await UI_GetItemWindowController.Open(listItem, UI_GetItemWindowController.EShowType.StorySettle, cb: () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
ExitFromLevel();//自己传入关闭奖励领取界面的后续操作
|
|
|
|
|
|
});
|
2024-08-14 15:00:35 +08:00
|
|
|
|
await UniTask.Delay(250);
|
2024-07-31 17:10:02 +08:00
|
|
|
|
await ShowTransitionMgr.Instance.ExitBlack();
|
|
|
|
|
|
ShowTransitionMgr.Instance.ExitTransition();
|
|
|
|
|
|
}
|
2024-09-27 19:56:25 +08:00
|
|
|
|
async void ExitFromLevel()
|
|
|
|
|
|
{
|
|
|
|
|
|
await GameSceneHelper.Instance.UnLoadSceneForRt();
|
|
|
|
|
|
AudioManager.Instance.StopAll();
|
|
|
|
|
|
LevelManager.Instance.ExitLevelDirectly();
|
|
|
|
|
|
EffectManager.instance.rootObj.SetActive(true);
|
|
|
|
|
|
UIManager.Instance.CloseWindow(UINameConst.UIMissionWin);
|
|
|
|
|
|
}
|
2024-07-31 17:10:02 +08:00
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
#region API
|
2023-11-22 15:05:43 +08:00
|
|
|
|
|
2024-06-27 13:22:21 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 向服务器发送消息准备进入关卡
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
|
/// <param name="finishCallback"></param>
|
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
|
/// <param name="isPlay">剧情加载完成后是否立即播放</param>
|
|
|
|
|
|
public void TryEnterLevel(int id, Action finishCallback = null, object param = null, bool isPlay = true)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-09-29 19:06:08 +08:00
|
|
|
|
IsSweep = false;
|
|
|
|
|
|
|
2023-11-22 15:05:43 +08:00
|
|
|
|
if (IsInLevel)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-09-02 14:55:43 +08:00
|
|
|
|
Debug.LogError($"进入关卡失败!当前正处于关卡中!当前关卡ID:{CurrLevel.Cfg.Id}");
|
2023-10-19 15:00:19 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-11-22 15:05:43 +08:00
|
|
|
|
|
2024-09-05 13:41:39 +08:00
|
|
|
|
if(!TryGetLevelInfoByID(id, out LevelInfo levelInfo))
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-01-03 16:40:57 +08:00
|
|
|
|
Debug.LogError($"关卡不存在,id:{id}");
|
2023-10-19 15:00:19 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-11-22 15:05:43 +08:00
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
if (!levelInfo.CanEnter)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"关卡无法进入,id:{id}");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-01-19 19:20:05 +08:00
|
|
|
|
|
2024-08-14 16:05:29 +08:00
|
|
|
|
//清掉上次的奖励
|
|
|
|
|
|
Actor.Instance.RewardItems.Clear();
|
|
|
|
|
|
|
2024-10-15 16:30:20 +08:00
|
|
|
|
var team = TeamEditManager.Instance.GetSelectTeam();
|
2024-01-15 13:53:01 +08:00
|
|
|
|
_cacheSettleData = new LevelSettleData(id, team);
|
2023-11-22 15:05:43 +08:00
|
|
|
|
|
2024-10-15 16:30:20 +08:00
|
|
|
|
var temIdx = TeamEditManager.Instance.SelectTeamIdx;
|
2024-10-12 15:09:07 +08:00
|
|
|
|
NetHelper.EnterLevel((uint)id, (uint)temIdx);
|
2024-09-30 13:16:30 +08:00
|
|
|
|
if (LevelManager.Instance.TryGetLevelInfoByID(id,out LevelInfo curLevelInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
BIManager.Instance.TrackEvent("level_event", new Dictionary<string, object>//关卡事件开始
|
|
|
|
|
|
{
|
|
|
|
|
|
{"level_id", curLevelInfo.Cfg.Id},
|
|
|
|
|
|
{"level_type" ,(int)curLevelInfo.ChapterInfo.Cfg.Type},
|
|
|
|
|
|
{"difficulty", (int)curLevelInfo.GroupInfo.Cfg.LevelDifficulty},
|
|
|
|
|
|
{"event", 0},
|
|
|
|
|
|
{"auto", 0}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
_enterLevelFinishCallBack = finishCallback;
|
2023-12-26 18:19:05 +08:00
|
|
|
|
_levelParam = param;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
_levelIDTryToEnter = id;
|
2024-06-27 13:22:21 +08:00
|
|
|
|
this.isPlay = isPlay;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//向服务器发送消息退出关卡
|
2024-09-30 13:16:30 +08:00
|
|
|
|
public void TryExitLevel(bool isSuccess, Action finishCallback = null, bool isGiveup = false)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2023-11-22 15:05:43 +08:00
|
|
|
|
if (!IsInLevel)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("当前未处于关卡中");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-11-08 15:05:19 +08:00
|
|
|
|
|
2024-09-23 19:33:59 +08:00
|
|
|
|
List<uint> starResult = new() { 0, 0, 0 };
|
2024-09-23 17:40:22 +08:00
|
|
|
|
if (E_ChapterType.War == CurrLevel.ChapterInfo.Cfg.Type)
|
2024-09-05 14:24:16 +08:00
|
|
|
|
{
|
2024-09-23 17:40:22 +08:00
|
|
|
|
if (CurrentLevel != null && CurrentLevel.StarResult != null)
|
2024-09-05 14:24:16 +08:00
|
|
|
|
{
|
2024-09-23 17:40:22 +08:00
|
|
|
|
starResult[0] = (uint)CurrentLevel.Score; // 第一位记录分数
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < CurrentLevel.StarResult.Count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
uint result = CurrentLevel.StarResult[i];
|
2024-09-23 19:33:59 +08:00
|
|
|
|
if (result > 0)
|
|
|
|
|
|
starResult[1] += 1u << i; // 按位存是否完成目标
|
2024-09-23 17:40:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CurrentLevel != null && CurrentLevel.StarResult != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < CurrentLevel.StarResult.Count; ++i)
|
2024-09-05 14:24:16 +08:00
|
|
|
|
{
|
2024-09-23 17:40:22 +08:00
|
|
|
|
uint result = CurrentLevel.StarResult[i];
|
|
|
|
|
|
if (result > 0 && result <= starResult.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
starResult[(int)result - 1] = 1;
|
|
|
|
|
|
}
|
2024-09-05 14:24:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
IsSuccess = isSuccess;
|
2024-09-30 13:16:30 +08:00
|
|
|
|
//由于pvp关卡结算不走这边流程所以这里不需要判断
|
2024-09-30 13:40:25 +08:00
|
|
|
|
if (CurrLevel != null)
|
2024-09-30 13:16:30 +08:00
|
|
|
|
{
|
2024-09-30 13:40:25 +08:00
|
|
|
|
var curLevelInfo = CurrLevel;
|
2024-09-30 13:16:30 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("level_event", new Dictionary<string, object>//关卡通关成功打点
|
|
|
|
|
|
{
|
|
|
|
|
|
{"level_id", curLevelInfo.Cfg.Id},
|
|
|
|
|
|
{"level_type" ,(int)curLevelInfo.ChapterInfo.Cfg.Type},
|
|
|
|
|
|
{"difficulty", (int)curLevelInfo.GroupInfo.Cfg.LevelDifficulty},
|
|
|
|
|
|
{"event", isSuccess? 1 : isGiveup ? 3 : 2 },//0:开始/1: 成功 / 2 :失败 / 3: 中途退出
|
|
|
|
|
|
{"auto", 0}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-23 17:40:22 +08:00
|
|
|
|
NetHelper.ExitLevel(isSuccess, starResult);
|
2023-10-19 15:00:19 +08:00
|
|
|
|
_exitLevelFinishCallBack = finishCallback;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-03 16:40:57 +08:00
|
|
|
|
//直接进入关卡,不通过服务器
|
|
|
|
|
|
public void EnterLevelDirectly(int levelID, Action enterLevelFinishCallBack = null, object param = null)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-01-03 16:40:57 +08:00
|
|
|
|
_enterLevelFinishCallBack = enterLevelFinishCallBack;
|
|
|
|
|
|
_levelParam = param;
|
|
|
|
|
|
_EnterLevelDirectly(levelID);
|
2024-09-05 13:41:39 +08:00
|
|
|
|
if (!TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-08-26 20:09:41 +08:00
|
|
|
|
if (!levelInfo.IsStory && GuideManager.Instance.IsGuiding)
|
2024-07-08 15:28:18 +08:00
|
|
|
|
PlayBGM();
|
2024-01-03 16:40:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//直接退出关卡,不走服务器
|
|
|
|
|
|
public void ExitLevelDirectly(Action exitLevelFinishCallBack = null)
|
|
|
|
|
|
{
|
2024-09-20 19:00:18 +08:00
|
|
|
|
if (IsSweep)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-01-03 16:40:57 +08:00
|
|
|
|
_exitLevelFinishCallBack = exitLevelFinishCallBack;
|
|
|
|
|
|
_ExitLevelDirectly();
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
2023-10-30 18:33:18 +08:00
|
|
|
|
|
2024-07-24 17:33:23 +08:00
|
|
|
|
public void PlayBGM()
|
2024-04-11 19:02:11 +08:00
|
|
|
|
{
|
2024-07-22 19:35:34 +08:00
|
|
|
|
//_bgmID = await AudioManager.Instance.PlayAudio("NLD_BGM_01");
|
2024-08-26 20:09:41 +08:00
|
|
|
|
AudioManager.Instance.StopAll();
|
2024-10-12 18:21:33 +08:00
|
|
|
|
_bgmID = AudioManager.Instance.PlayAudio("bgm_1", AudioCriManager.EPlayType.Music, null, true);
|
2024-04-11 19:02:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void StopBGM()
|
|
|
|
|
|
{
|
|
|
|
|
|
AudioManager.Instance.AudioMgrObj.StopMusicById(_bgmID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-05 16:06:48 +08:00
|
|
|
|
public async UniTask OnPVPSettle()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CurrentLevel.IsPvPLevel)
|
|
|
|
|
|
{
|
2024-09-26 19:25:46 +08:00
|
|
|
|
// ShowTransitionMgr.Instance.ExitTransition();
|
|
|
|
|
|
// await ShowTransitionMgr.Instance.EnterBlack();
|
|
|
|
|
|
// await UniTask.Delay(250);
|
|
|
|
|
|
// await UI_PVPSettlementController.Open(PVPManager.Instance.IsWin);
|
|
|
|
|
|
// await ShowTransitionMgr.Instance.ExitBlack();
|
2024-10-18 12:52:11 +08:00
|
|
|
|
// ShowTransitionMgr.Instance.ExitTruansition();
|
|
|
|
|
|
// if (PVPManager.Instance.RewardItemList == null || PVPManager.Instance.RewardItemList.Lists.Length <= 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// PVPManager.Instance.RewardItemList = Actor.Instance.RewardItems;
|
|
|
|
|
|
// }
|
2024-09-26 19:25:46 +08:00
|
|
|
|
await SettlePvPSceneProcess(PVPManager.Instance.RewardItemList, PVPManager.Instance.IsWin);
|
2024-08-05 16:06:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
#endregion API
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|