using System; using System.Collections.Generic; using cfg; using cfg.ActorCfg; using cfg.LevelCfg; using Cysharp.Threading.Tasks; using Framework; using Gameplay; using Gameplay.Level; using PhxhSDK; namespace Gameplay { public class JumpToManager { private static readonly Dictionary _jumpDicAsync = new() { [JumpFuncType.Cultivate_Character] = (Action)JumpToCultivateCharacterAsync, [JumpFuncType.Level_Select] = (Action)JumpToLevelSelectAsync, [JumpFuncType.Level_Detail] = (Action)JumpToLevelDetailAsync, [JumpFuncType.Item_Shop] = (Action)JumpToShopDetailAsync, [JumpFuncType.PVP_Main] = (Action)JumpToPvpMainAsync, [JumpFuncType.Gacha] = (Action)JumpToGachaAsync, }; private static readonly Dictionary _jumpDic = new() { [JumpFuncType.Level_Select] = (Func)JumpToLevelSelect, [JumpFuncType.PVP_Main] = (Func)JumpToPvpMain, [JumpFuncType.TeamInfoByGuide] = (Func)JumpToTeamInfoByGuide, [JumpFuncType.TeamSelect] = (Func)JumpToTeamSelectByGuide, }; private static void _DoJumpFunc(JumpFuncType key) { var action = _jumpDicAsync[key]; if (action is Action act) { act(); } } private static void _DoJumpFunc(JumpFuncType key, T param) { var action = _jumpDicAsync[key]; if (action is Action act) { act(param); } } private static async UniTask _DoJumpFuncAsync(JumpFuncType key) { var action = _jumpDic[key]; if (action is Func act) { await act(); } } private static async UniTask _DoJumpFuncAsync(JumpFuncType key, T param) { var action = _jumpDic[key]; if (action is Func act) { await act(param); } } public static void JumpFunc(JumpFuncType key) { _DoJumpFunc(key); } public static void JumpFunc(JumpFuncType key, T param) { _DoJumpFunc(key, param); } public static async UniTask JumpFuncAsync(JumpFuncType key) { await _DoJumpFuncAsync(key); } public static async UniTask JumpFuncAsync(JumpFuncType key, T param) { await _DoJumpFuncAsync(key, param); } public static async void JumpToCultivateCharacterAsync(int uid) { DebugUtil.Log("跳转至培养角色界面,传入角色参数:" + uid + "\n逻辑请在此处实现"); await UISelectCharacterController.Open(); } /// /// 跳转关卡选择 /// /// public static async void JumpToLevelSelectAsync(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 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) { 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 UI_LevelDetailController.Open(levelInfo); } /// /// 跳转到队伍信息(引导用) /// /// 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); } /// /// 跳转队伍选择(引导用) /// /// /// 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) { 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_ShopController.Open(shopID); } public static async void JumpToPvpMainAsync() { await UI_PVPMainController.Open(); } public static async UniTask JumpToPvpMain() { await UI_PVPMainController.Open(); } public static async void JumpToGachaAsync(int GachaID) { await UI_DrawMainPanelController.Open(); } } }