2025-01-04 23:00:19 +08:00

105 lines
3.1 KiB
Lua

LevelTable = {}
LevelTable.ELevelType = {
Random = 0, -- 随机地图
Level1 = 1,
Level2 = 2,
Level3 = 3,
}
--- 配置的地图数据
---@type table<ELevelType, LevelItem>
LevelTable.LevelInfo = {
[LevelTable.ELevelType.Random] = {
ShowName = "随机关卡",
},
[LevelTable.ELevelType.Level1] = {
ShowName = "G 港",
MapName = "Ggang",
Rate = 100;
MiniMapInfo = {
MapPath = UGCGameSystem.GetUGCResourcesFullPath('Asset/Levels/Minimap/T_Map_Ggang.T_Map_Ggang'),
MapCentre = { X = 205509.765625, Y = 279563.156250, Z = 1182.980469 },
MapSize = 30000.0,
MapScale = 30.,
}
},
[LevelTable.ELevelType.Level2] = {
ShowName = "新年广场",
MapName = "Map_XNGC",
Rate = 0;
MiniMapInfo = {
MapPath = UGCGameSystem.GetUGCResourcesFullPath('Asset/Levels/Minimap/T_Minimap_XNGC.T_Minimap_XNGC'),
--- (X=207721.187500,Y=281974.781250,Z=568.751587)
MapCentre = { X=-60.,Y=170.,Z=800. },
MapSize = 14000.0,
MapScale = 30.,
}
},
[LevelTable.ELevelType.Level3] = {
ShowName = "遗迹",
MapName = "Map_Ruins",
Rate = 0;
MiniMapInfo = {
MapPath = UGCGameSystem.GetUGCResourcesFullPath('Asset/Levels/Minimap/T_MiniRuins1.T_MiniRuins1'),
MapCentre = { X = 50., Y = -100., Z = 300. },
MapSize = 13000.0,
MapScale = 30.,
}
},
--[LevelTable.ELevelType.Level3] = {
-- Icon = UGCGameSystem.GetUGCResourcesFullPath('Asset/Texture/MapTex/T_Level3.T_Level3'),
-- IconSelect = UGCGameSystem.GetUGCResourcesFullPath('Asset/Texture/MapTex/T_Level1Select.T_Level1Select'),
-- ShowName = "沙漠兵工厂",
-- MapName = "Level3",
-- MiniMapInfo = {
-- MapPath = UGCGameSystem.GetUGCResourcesFullPath('T_Level3MiniMap.T_Level3MiniMap'),
-- MapCentre = {X=44500.000000,Y=13500.000000,Z=200.000000},
-- MapSize = 18000.0,
-- MapScale = 30.,
-- }
--},
}
--- 是否启用地图
---@type table<ELevelType, boolean>
LevelTable.LevelEnable = {
[LevelTable.ELevelType.Random] = true;
[LevelTable.ELevelType.Level1] = true;
[LevelTable.ELevelType.Level2] = true;
[LevelTable.ELevelType.Level3] = false;
}
---@param IsUseRate bool 是否使用比例进行随机
---@param MapNum int 需要地图的数量
---@return table<int32, int32> 获取随机地图的 index
function LevelTable.GetRandomLevel(IsUseRate)
if IsUseRate then
local Total = 0;
for i = 1, #LevelTable.LevelInfo do
local Info = LevelTable.LevelInfo[i]
if Info and Info.Rate then
Total = Total + Info.Rate;
end
end
local MapIndies = {};
local RandomNum = math.pop() * Total
UGCLogSystem.Log("[LevelTable.GetRandomLevel] RandomNum = %f", RandomNum)
for i = 1, #LevelTable.LevelInfo do
local Info = LevelTable.LevelInfo[i];
UGCLogSystem.Log("[LevelTable.GetRandomLevel] RandomNum = %f", RandomNum)
if Info and Info.Rate then
RandomNum = RandomNum - Info.Rate;
if RandomNum <= 0 then
table.insert(MapIndies, i);
break ;
end
end
end
return MapIndies;
end
local Count = table.getCount(LevelTable.LevelInfo);
-- 默认 Random 是 0;
if Count == 2 then return { 1 }; end
return math.random(Count);
end