102 lines
3.3 KiB
C#
102 lines
3.3 KiB
C#
using Cysharp.Threading.Tasks;
|
||
using Framework;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using Gameplay.Performance;
|
||
using PhxhSDK;
|
||
using PhxhSDK.Phxh;
|
||
using TGS;
|
||
using UnityEngine;
|
||
using static Gameplay.Level.LevelData;
|
||
using Constants = Framework.Constants;
|
||
|
||
namespace Gameplay.Level
|
||
{
|
||
public static class LevelUtils
|
||
{
|
||
private const string SCENE_ORIGIN_PATH = "Assets/Scenes/Maps";
|
||
private const string SCENE_POSTPROCESS_PATH = "Assets/Art/AutoGen/Maps";
|
||
private const string SCENE_POST_PROCESS_NAME = "PostProcess";
|
||
|
||
// public static bool CheckEnterLevel(int levelId)
|
||
// {
|
||
// var configFilePath = GetLevelFilePath(levelId);
|
||
// if (AssetManager.Instance.CanLocateAsset(configFilePath))
|
||
// {
|
||
// return true;
|
||
// }
|
||
//
|
||
// else
|
||
// {
|
||
// return false;
|
||
// }
|
||
// }
|
||
|
||
public static string GetLevelFilePath(int id)
|
||
{
|
||
var cfg = TableManager.Instance.Tables.Level.DataMap.GetValueOrDefault(id);
|
||
if (cfg == null)
|
||
{
|
||
DebugUtil.LogError($"找不到level配置,id:{id}");
|
||
return null;
|
||
}
|
||
return string.Format(Constants.LEVEL_CONFIG_FORMAT_PATH,cfg.LevelData);
|
||
}
|
||
|
||
public static LevelData LoadLevelData(int id)
|
||
{
|
||
var levelFilePath = GetLevelFilePath(id);
|
||
var levelData = JsonHelper.LoadFromAddressableSync<LevelData>(levelFilePath);
|
||
if (levelData == null)
|
||
{
|
||
DebugUtil.LogError("LoadData failed, can not find level data: {0}", levelFilePath);
|
||
}
|
||
return levelData;
|
||
}
|
||
|
||
public static float SetCharaterToward(CharacterToward npcToward)
|
||
{
|
||
switch (npcToward)
|
||
{
|
||
case CharacterToward.TopLeft:
|
||
{
|
||
return 0f;
|
||
|
||
}
|
||
case CharacterToward.TopRight:
|
||
{
|
||
return 60f;
|
||
}
|
||
case CharacterToward.Right:
|
||
{
|
||
return 120f;
|
||
}
|
||
case CharacterToward.BottomRight:
|
||
{
|
||
return 180f;
|
||
}
|
||
case CharacterToward.BottomLeft:
|
||
{
|
||
|
||
return -120f;
|
||
}
|
||
default:
|
||
{
|
||
return -60f;
|
||
}
|
||
}
|
||
}
|
||
|
||
// public static string GetPostProcessLevelScenePath(string scenePath)
|
||
// {
|
||
// var oldSceneDir = scenePath;
|
||
// var oldSceneName = Path.GetFileNameWithoutExtension(scenePath);
|
||
// var tempSceneDir = oldSceneDir.Replace( SCENE_ORIGIN_PATH, SCENE_POSTPROCESS_PATH);
|
||
// var subStr = tempSceneDir.Substring(SCENE_POSTPROCESS_PATH.Length + 1);
|
||
// var folderName = Path.GetFileNameWithoutExtension(subStr.Replace("/", "_"));
|
||
// var result = $"{SCENE_POSTPROCESS_PATH}/{folderName}/{oldSceneName}_{SCENE_POST_PROCESS_NAME}.unity";
|
||
// return result;
|
||
// }
|
||
}
|
||
|
||
} |