358 lines
12 KiB
C#
358 lines
12 KiB
C#
using cfg;
|
|
using cfg.LevelCfg;
|
|
using Cysharp.Threading.Tasks;
|
|
using Framework;
|
|
using Gameplay.LegionBattle;
|
|
using Gameplay.Level;
|
|
using NLDPB;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using cfg.FunctionLockCfg;
|
|
using Gameplay.FunctionLock;
|
|
|
|
namespace Gameplay
|
|
{
|
|
public class JumpToManager
|
|
{
|
|
/// <summary>
|
|
/// 异步跳转方法字典,带回调
|
|
/// </summary>
|
|
private static readonly Dictionary<JumpFuncType, Delegate> _jumpDicAsync = new()
|
|
{
|
|
[JumpFuncType.Cultivate_Character] = (Action<int, Action>)JumpToCultivateCharacterAsync,
|
|
[JumpFuncType.Level_Select] = (Action<int, Action>)JumpToLevelSelectAsync,
|
|
[JumpFuncType.Level_Detail] = (Action<int, Action>)JumpToLevelDetailAsync,
|
|
[JumpFuncType.Item_Shop] = (Action<int, Action>)JumpToShopDetailAsync,
|
|
[JumpFuncType.PVP_Main] = (Action<Action>)JumpToPvpMainAsync,
|
|
[JumpFuncType.Gacha] = (Action<int, Action>)JumpToGachaAsync,
|
|
[JumpFuncType.Camp] = (Action<E_CampBuilding, Action>)JumpToCamp,
|
|
[JumpFuncType.Legion_main] = (Action<Action>)JumpToLegionMain,
|
|
[JumpFuncType.Main] = (Action)JumpToMain,
|
|
};
|
|
|
|
private static readonly Dictionary<JumpFuncType, Delegate> _jumpDic = new()
|
|
{
|
|
[JumpFuncType.Level_Select] = (Func<int, UniTask>)JumpToLevelSelect,
|
|
[JumpFuncType.PVP_Main] = (Func<UniTask>)JumpToPvpMain,
|
|
[JumpFuncType.TeamInfoByGuide] = (Func<int, UniTask>)JumpToTeamInfoByGuide,
|
|
[JumpFuncType.TeamSelect] = (Func<int, UniTask>)JumpToTeamSelectByGuide,
|
|
};
|
|
|
|
private static void _DoJumpFunc(JumpFuncType key)
|
|
{
|
|
var action = _jumpDicAsync[key];
|
|
if (action is Action act)
|
|
{
|
|
act();
|
|
}
|
|
}
|
|
|
|
private static void _DoJumpFunc<T>(JumpFuncType key, T param)
|
|
{
|
|
var action = _jumpDicAsync[key];
|
|
if (action is Action<T> act)
|
|
{
|
|
act(param);
|
|
}
|
|
}
|
|
|
|
private static void _DoJumpFunc<T, Action>(JumpFuncType key, T param, Action callback)
|
|
{
|
|
var action = _jumpDicAsync[key];
|
|
if (action is Action<T, Action> act)
|
|
{
|
|
act(param, callback);
|
|
}
|
|
}
|
|
|
|
private static async UniTask _DoJumpFuncAsync(JumpFuncType key)
|
|
{
|
|
var action = _jumpDic[key];
|
|
if (action is Func<UniTask> act)
|
|
{
|
|
await act();
|
|
}
|
|
}
|
|
|
|
private static async UniTask _DoJumpFuncAsync<T>(JumpFuncType key, T param)
|
|
{
|
|
var action = _jumpDic[key];
|
|
if (action is Func<T, UniTask> act)
|
|
{
|
|
await act(param);
|
|
}
|
|
}
|
|
|
|
public static void JumpFunc(JumpFuncType key)
|
|
{
|
|
_DoJumpFunc(key);
|
|
}
|
|
|
|
public static void JumpFunc<T>(JumpFuncType key, T param)
|
|
{
|
|
_DoJumpFunc(key, param);
|
|
}
|
|
|
|
public static void JumpFunc<T, Action>(JumpFuncType key, T param, Action callback)
|
|
{
|
|
_DoJumpFunc(key, param, callback);
|
|
}
|
|
|
|
public static async UniTask JumpFuncAsync(JumpFuncType key)
|
|
{
|
|
await _DoJumpFuncAsync(key);
|
|
}
|
|
|
|
public static async UniTask JumpFuncAsync<T>(JumpFuncType key, T param)
|
|
{
|
|
await _DoJumpFuncAsync(key, param);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 跳转至培养角色界面
|
|
/// </summary>
|
|
/// <param name="uid"></param>
|
|
/// <param name="onLoadWindowCallback"></param>
|
|
public static async void JumpToCultivateCharacterAsync(int uid, Action onLoadWindowCallback)
|
|
{
|
|
DebugUtil.Log("跳转至培养角色界面,传入角色参数:" + uid + "\n逻辑请在此处实现");
|
|
await UISelectCharacterController.Open();
|
|
onLoadWindowCallback?.Invoke();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转关卡选择
|
|
/// </summary>
|
|
/// <param name="levelId"></param>
|
|
public static async void JumpToLevelSelectAsync(int levelId, Action onLoadWindowCallback)
|
|
{
|
|
DebugUtil.Log("Jump to : " + levelId);
|
|
DataLevel data = TableManager.Instance.Tables.Level.Get(levelId);
|
|
if (data == null)
|
|
{
|
|
await UI_LevelSelectController.Open();
|
|
return;
|
|
}
|
|
|
|
LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo);
|
|
|
|
await UI_LevelSelectController.Open(levelInfo);
|
|
onLoadWindowCallback?.Invoke();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转关卡选择
|
|
/// </summary>
|
|
/// <param name="levelId"></param>
|
|
public static async UniTask JumpToLevelSelect(int levelId)
|
|
{
|
|
DebugUtil.Log("Jump to : " + levelId);
|
|
DataLevel data = TableManager.Instance.Tables.Level.Get(levelId);
|
|
if (data == null)
|
|
{
|
|
await UI_LevelSelectController.Open();
|
|
return;
|
|
}
|
|
|
|
LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo);
|
|
|
|
await UI_LevelSelectController.Open(levelInfo);
|
|
}
|
|
|
|
public static async void JumpToLevelDetailAsync(int levelId, Action onLoadWindowCallback)
|
|
{
|
|
DebugUtil.Log("Jump to : " + levelId);
|
|
DataLevel data = TableManager.Instance.Tables.Level.Get(levelId);
|
|
if (data == null)
|
|
{
|
|
DebugUtil.Log("Jump to level detail failed, level id not found: " + levelId);
|
|
return;
|
|
}
|
|
|
|
|
|
LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo);
|
|
|
|
await UI_LevelSelectController.Open(levelInfo);
|
|
await UniTask.Yield();
|
|
UIManager.Instance.Hide(UINameConst.UI_LevelSelect);
|
|
await UI_LevelDetailController.Open(levelInfo);
|
|
onLoadWindowCallback?.Invoke();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转到队伍信息(引导用)
|
|
/// </summary>
|
|
/// <param name="levelId"></param>
|
|
public static async UniTask JumpToTeamInfoByGuide(int levelId)
|
|
{
|
|
DebugUtil.Log("Jump to : " + levelId);
|
|
DataLevel data = TableManager.Instance.Tables.Level.Get(levelId);
|
|
if (data == null)
|
|
{
|
|
DebugUtil.Log("Jump to team info failed, level id not found: " + levelId);
|
|
return;
|
|
}
|
|
|
|
|
|
LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo);
|
|
|
|
//await UI_LevelSelectController.Open(levelInfo);
|
|
//await UI_LevelDetailController.Open(levelInfo);
|
|
await UI_TeamAndSkillSelectController.Open(levelInfo, false, 1);
|
|
Team team = TeamEditManager.Instance.GetSelectTeam();
|
|
await UI_TeamInfoController.Open(team);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转队伍选择(引导用)
|
|
/// </summary>
|
|
/// <param name="levelId"></param>
|
|
/// <returns></returns>
|
|
public static async UniTask JumpToTeamSelectByGuide(int levelId)
|
|
{
|
|
DebugUtil.Log("Jump to : " + levelId);
|
|
DataLevel data = TableManager.Instance.Tables.Level.Get(levelId);
|
|
if (data == null)
|
|
{
|
|
DebugUtil.Log("Jump to team select failed, level id not found: " + levelId);
|
|
return;
|
|
}
|
|
|
|
|
|
LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo);
|
|
|
|
//await UI_LevelSelectController.Open(levelInfo);
|
|
//await UI_LevelDetailController.Open(levelInfo);
|
|
await UI_TeamAndSkillSelectController.Open(levelInfo, false, 1);
|
|
}
|
|
|
|
public static async void JumpToShopDetailAsync(int shopID, Action onLoadWindowCallback)
|
|
{
|
|
if(!FunctionLockManager.Instance.IsUnlock(E_Function.Store))
|
|
{
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("ui_functionLockTip"));
|
|
return;
|
|
}
|
|
DebugUtil.Log("Jump to Shop : " + shopID);
|
|
var shopCfg = TableManager.Instance.Tables.Shop;
|
|
if (!shopCfg.DataMap.TryGetValue(shopID, out var shop))
|
|
{
|
|
DebugUtil.Log("Jump to shop detail failed, shop id not found: " + shopID);
|
|
return;
|
|
}
|
|
|
|
await UI_ShopNewController.Open(shopID);
|
|
onLoadWindowCallback?.Invoke();
|
|
}
|
|
|
|
public static async void JumpToPvpMainAsync(Action onLoadWindowCallback)
|
|
{
|
|
await UI_PVPMainController.Open();
|
|
onLoadWindowCallback?.Invoke();
|
|
}
|
|
|
|
public static async UniTask JumpToPvpMain()
|
|
{
|
|
await UI_PVPMainController.Open();
|
|
}
|
|
|
|
public static async void JumpToGachaAsync(int GachaID, Action onLoadWindowCallback)
|
|
{
|
|
await UI_DrawMainPanelController.Open();
|
|
onLoadWindowCallback?.Invoke();
|
|
}
|
|
|
|
public static async void JumpToCamp(E_CampBuilding campBuilding, Action onLoadWindowCallback)
|
|
{
|
|
await UI_CampController.Open();
|
|
await UI_Camp_SecondController.Open(campBuilding);
|
|
onLoadWindowCallback?.Invoke();
|
|
|
|
if (campBuilding == E_CampBuilding.BattleMap)
|
|
{
|
|
|
|
// 军团战入口
|
|
if (LegionBattleManager.Instance.CurBattleStatus == LegionBattleStatus.LbsNone)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (LegionBattleManager.Instance.CurBattleStatus == LegionBattleStatus.Start)
|
|
{
|
|
CommonUtils.CaptureScreenshot();
|
|
await UI_LegionBattleApplyController.Open();
|
|
return;
|
|
}
|
|
|
|
if (LegionBattleManager.Instance.CurBattleLegionBattleSignStatus != LegionBattleSignStatus.Signed)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (LegionBattleManager.Instance.CurBattleStatus == LegionBattleStatus.Team || LegionBattleManager.Instance.CurBattleStatus == LegionBattleStatus.TeamLock)
|
|
{
|
|
LegionBattleManager.Instance.ReqLegionBattleMemberInfos();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转到军团主页面
|
|
/// </summary>
|
|
/// <param name="onLoadWindowCallback"></param>
|
|
public static async void JumpToLegionMain(Action onLoadWindowCallback)
|
|
{
|
|
await UI_CampController.Open();
|
|
await UI_Camp_SecondController.Open(E_CampBuilding.LegionCommunicate);
|
|
if (LegionManager.Instance.MyLegion != null)
|
|
{
|
|
if (UIManager.Instance.CheckWindowCreated(UINameConst.UI_LegionInfoPanel))
|
|
return;
|
|
|
|
await UI_LegionInfoPanelController.Open();
|
|
return;
|
|
}
|
|
|
|
if (!UIManager.Instance.CheckWindowCreated(UINameConst.UI_LegionSquarePanel))
|
|
LegionManager.Instance.ReqLegionListByPage(0);
|
|
onLoadWindowCallback?.Invoke();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转到军团战战场
|
|
/// </summary>
|
|
public static void JumToLegionBattle(Action onLoadWindowCallback)
|
|
{
|
|
if (LegionBattleManager.Instance.CurBattleStatus == LegionBattleStatus.LbsNone)
|
|
{
|
|
UITipsManager.ShowTips("军团战未开始!");
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// (功能锁)跳转到主界面
|
|
/// </summary>
|
|
public static async void JumpToMain()
|
|
{
|
|
if (GameStateManager.Instance.GetCurState() is GameStateLevel)
|
|
{
|
|
LevelManager.Instance.ExitLevelDirectly(() =>
|
|
{
|
|
GameStateManager.Instance.ChangeState(new GameStateMainScene());
|
|
});
|
|
}
|
|
else if (GameStateManager.Instance.GetCurState() is not GameStateMainScene)
|
|
GameStateManager.Instance.ChangeState(new GameStateMainScene());
|
|
else
|
|
{
|
|
CommonUtils.ChangeUIScene(Constants.MAIN_SCENE_PATH);
|
|
UIManager.Instance.CloseAllNormalExcept(UINameConst.UI_MainPanel);
|
|
await UI_MainPanelController.Open();
|
|
}
|
|
}
|
|
}
|
|
} |