112 lines
4.4 KiB
C#
112 lines
4.4 KiB
C#
using System.Collections.Generic;
|
||
using Cielonos.MainGame.Characters;
|
||
using Cielonos.MainGame.Inventory;
|
||
using Cielonos.MainGame.Map;
|
||
using Sirenix.OdinInspector;
|
||
using SLSUtilities.General;
|
||
using UnityEngine;
|
||
|
||
namespace Cielonos.MainGame
|
||
{
|
||
/// <summary>
|
||
/// Run 系统的核心配置数据集合。集中管理地图参数、Zone 池、初始装备和货币范围配置。
|
||
/// 在 Resources 根目录下以 "MainGameConfig" 命名放置,供全局访问。
|
||
/// </summary>
|
||
[CreateAssetMenu(fileName = "MainGameConfig", menuName = "Cielonos/MainGameConfig")]
|
||
public class MainGameConfig : SerializedScriptableObject
|
||
{
|
||
// ----------------------------------------------------------------
|
||
// 地图配置
|
||
// ----------------------------------------------------------------
|
||
|
||
[TitleGroup("地图配置")]
|
||
[Tooltip("地图生成的默认参数配置")]
|
||
public MapGenerationConfig defaultMapConfig;
|
||
|
||
[TitleGroup("地图配置")]
|
||
[Tooltip("特定地图的生成参数配置,键为地图 ID。")]
|
||
public Dictionary<string, MapGenerationConfig> mapConfigs = new Dictionary<string, MapGenerationConfig>();
|
||
|
||
|
||
// ----------------------------------------------------------------
|
||
// 初始装备
|
||
// ----------------------------------------------------------------
|
||
|
||
[TitleGroup("初始装备")]
|
||
[Tooltip("每局开始时玩家携带的初始武器预制体列表")]
|
||
public List<GameObject> startingWeapons = new List<GameObject>();
|
||
|
||
// ----------------------------------------------------------------
|
||
// 货币
|
||
// ----------------------------------------------------------------
|
||
|
||
[TitleGroup("货币 - 击杀奖励")]
|
||
public Vector2Int normalEnemyCurrencyRange = new Vector2Int(5, 15);
|
||
|
||
[TitleGroup("货币 - 击杀奖励")]
|
||
public Vector2Int eliteEnemyCurrencyRange = new Vector2Int(20, 40);
|
||
|
||
[TitleGroup("货币 - 击杀奖励")]
|
||
public Vector2Int bossCurrencyRange = new Vector2Int(80, 120);
|
||
|
||
[TitleGroup("货币 - 装备价格")]
|
||
public Dictionary<ItemRarity, Vector2Int> itemPrices = new Dictionary<ItemRarity, Vector2Int>()
|
||
{
|
||
{ItemRarity.None, new Vector2Int(9999, 9999)},
|
||
{ItemRarity.Tera, new Vector2Int(200, 250)},
|
||
{ItemRarity.Moser, new Vector2Int(300, 350)},
|
||
{ItemRarity.Graham, new Vector2Int(500, 600)},
|
||
{ItemRarity.Epsilon, new Vector2Int(700, 800)},
|
||
{ItemRarity.Aleph, new Vector2Int(900, 1000)},
|
||
};
|
||
|
||
[TitleGroup("机械台 - 各稀有度概率")]
|
||
public Dictionary<ItemRarity, float> mechanicalTableRarityWeights = new Dictionary<ItemRarity, float>
|
||
{
|
||
{ ItemRarity.Tera, 50f },
|
||
{ ItemRarity.Moser, 30f },
|
||
{ ItemRarity.Graham, 15f },
|
||
{ ItemRarity.Epsilon, 4f },
|
||
{ ItemRarity.Aleph, 1f },
|
||
};
|
||
|
||
// ----------------------------------------------------------------
|
||
// 公共方法
|
||
// ----------------------------------------------------------------
|
||
|
||
/// <summary>
|
||
/// 根据敌人等级随机生成单个敌人的货币掉落数量。
|
||
/// </summary>
|
||
/// <param name="rank">敌人等级(Node / Nexus / Core)。</param>
|
||
/// <param name="rng">随机数实例。</param>
|
||
/// <returns>随机货币数量。</returns>
|
||
public int RollCurrency(EnemyRank rank, System.Random rng)
|
||
{
|
||
Vector2Int range = rank switch
|
||
{
|
||
EnemyRank.Nexus => eliteEnemyCurrencyRange,
|
||
EnemyRank.Core => bossCurrencyRange,
|
||
_ => normalEnemyCurrencyRange,
|
||
};
|
||
|
||
return rng.Next(range.x, range.y + 1);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据物品稀有度随机生成售价。
|
||
/// </summary>
|
||
/// <param name="rarity">物品稀有度。</param>
|
||
/// <param name="rng">随机数实例。</param>
|
||
/// <returns>随机售价;若该稀有度无配置则返回 0。</returns>
|
||
public int RollPrice(ItemRarity rarity, System.Random rng)
|
||
{
|
||
if (!itemPrices.TryGetValue(rarity, out Vector2Int range))
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
return rng.Next(range.x, range.y + 1);
|
||
}
|
||
}
|
||
}
|