200 lines
6.2 KiB
C#
200 lines
6.2 KiB
C#
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<JumpFuncType, Delegate> _jumpDic = new()
|
|
{
|
|
[JumpFuncType.Cultivate_Character] = (Action<int>)JumpToCultivateCharacter,
|
|
[JumpFuncType.Level_Select] = (Action<int>)JumpToLevelSelect,
|
|
[JumpFuncType.Level_Detail] = (Action<int>)JumpToLevelDetail,
|
|
[JumpFuncType.Item_Shop] = (Action<int>)JumpToShopDetail,
|
|
[JumpFuncType.PVP_Main] = (Action)JumpToPvpMain,
|
|
[JumpFuncType.Gacha] = (Action<int>)JumpToGacha,
|
|
};
|
|
|
|
private static readonly Dictionary<JumpFuncType, Delegate> _jumpDicFunc = new()
|
|
{
|
|
[JumpFuncType.Level_Select] = (Func<int, UniTask>)JumpToLevelSelectAsync,
|
|
[JumpFuncType.PVP_Main] = (Func<UniTask>)JumpToPvpMainAsync,
|
|
[JumpFuncType.TeamSelect] = (Func<int, UniTask>)JumpToTeamSelectAsync,
|
|
};
|
|
|
|
private static void _DoJumpFunc(JumpFuncType key)
|
|
{
|
|
var action = _jumpDic[key];
|
|
if (action is Action act)
|
|
{
|
|
act();
|
|
}
|
|
}
|
|
|
|
private static void _DoJumpFunc<T>(JumpFuncType key, T param)
|
|
{
|
|
var action = _jumpDic[key];
|
|
if (action is Action<T> act)
|
|
{
|
|
act(param);
|
|
}
|
|
}
|
|
|
|
private static async UniTask _DoJumpFuncAsync(JumpFuncType key)
|
|
{
|
|
var action = _jumpDicFunc[key];
|
|
if (action is Func<UniTask> act)
|
|
{
|
|
await act();
|
|
}
|
|
}
|
|
|
|
private static async UniTask _DoJumpFuncAsync<T>(JumpFuncType key, T param)
|
|
{
|
|
var action = _jumpDicFunc[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 async UniTask JumpFuncAsync(JumpFuncType key)
|
|
{
|
|
await _DoJumpFuncAsync(key);
|
|
}
|
|
|
|
public static async UniTask JumpFuncAsync<T>(JumpFuncType key, T param)
|
|
{
|
|
await _DoJumpFuncAsync(key, param);
|
|
}
|
|
|
|
public static async void JumpToCultivateCharacter(int uid)
|
|
{
|
|
DebugUtil.Log("跳转至培养角色界面,传入角色参数:" + uid + "\n逻辑请在此处实现");
|
|
await UISelectCharacterController.Open();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转关卡选择
|
|
/// </summary>
|
|
/// <param name="levelId"></param>
|
|
public static async void 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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转关卡选择
|
|
/// </summary>
|
|
/// <param name="levelId"></param>
|
|
public static async UniTask 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 void JumpToLevelDetail(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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 跳转到编队选择
|
|
/// </summary>
|
|
/// <param name="levelId"></param>
|
|
public static async UniTask JumpToTeamSelectAsync(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);
|
|
await UI_TeamAndSkillSelectController.Open(levelInfo, false, 1);
|
|
}
|
|
|
|
public static async void JumpToShopDetail(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 JumpToPvpMain()
|
|
{
|
|
await UI_PVPMainController.Open();
|
|
}
|
|
|
|
public static async UniTask JumpToPvpMainAsync()
|
|
{
|
|
await UI_PVPMainController.Open();
|
|
}
|
|
|
|
public static async void JumpToGacha(int GachaID)
|
|
{
|
|
await UI_DrawMainPanelController.Open();
|
|
}
|
|
}
|
|
} |