- 调整项目结构以适应打包需求

- 添加控制台便于在游戏运行过程中调试各项功能
- 添加 LevelRarity 表,增加了随关卡数动态调整的商品道具品质刷新概率
This commit is contained in:
SepComet
2026-02-18 22:53:33 +08:00
parent e151619c69
commit b4bc8b0445
202 changed files with 5160 additions and 3393 deletions
@@ -0,0 +1,89 @@
using DataTable;
using Definition.Enum;
using GameFramework.DataTable;
using UnityEngine;
namespace Game.Utility
{
public static class RarityUtility
{
public static ItemRarity SelectRarityForLevel(IDataTable<DRLevelRarity> table, int level)
{
DRLevelRarity row = GetLevelRarityRow(table, level);
if (row == null)
{
return ItemRarity.White;
}
int white = Mathf.Max(0, row.WhiteWeight);
int green = Mathf.Max(0, row.GreenWeight);
int blue = Mathf.Max(0, row.BlueWeight);
int purple = Mathf.Max(0, row.PurpleWeight);
int red = Mathf.Max(0, row.RedWeight);
int total = white + green + blue + purple + red;
if (total <= 0)
{
return ItemRarity.White;
}
int roll = Random.Range(1, total + 1);
if (roll <= white) return ItemRarity.White;
roll -= white;
if (roll <= green) return ItemRarity.Green;
roll -= green;
if (roll <= blue) return ItemRarity.Blue;
roll -= blue;
if (roll <= purple) return ItemRarity.Purple;
return ItemRarity.Red;
}
private static DRLevelRarity GetLevelRarityRow(IDataTable<DRLevelRarity> table, int level)
{
if (table == null)
{
return null;
}
DRLevelRarity[] rows = table.GetAllDataRows();
if (rows == null || rows.Length == 0)
{
return null;
}
int safeLevel = Mathf.Max(1, level);
DRLevelRarity below = null;
DRLevelRarity above = null;
foreach (DRLevelRarity row in rows)
{
if (row == null)
{
continue;
}
if (safeLevel >= row.LevelMin && safeLevel <= row.LevelMax)
{
return row;
}
if (safeLevel < row.LevelMin)
{
if (above == null || row.LevelMin < above.LevelMin)
{
above = row;
}
}
else if (safeLevel > row.LevelMax)
{
if (below == null || row.LevelMax > below.LevelMax)
{
below = row;
}
}
}
return above ?? below;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d9186261c82d4f0b8270048f08158b0f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: