引入 UISerializationRoot 和 Item

- 完成 MenuForm 和 SelectRoleForm 的迁移
This commit is contained in:
2026-09-13 22:18:29 +08:00
parent e2fdb660ab
commit 091a29db63
101 changed files with 5281 additions and 5753 deletions
@@ -12,7 +12,6 @@ namespace SepCore.UI
{
public class LevelUpUseCase : IUIUseCase
{
private const int BaseRefreshPrice = 2;
private readonly Action _onCompleted;
private readonly LevelUpRewardConfig[] _allRewards;
private readonly Dictionary<Rarity, List<LevelUpRewardConfig>> _rewardsByRarity = new();
@@ -32,28 +31,28 @@ namespace SepCore.UI
BuildRewardRarityPools();
}
public LevelUpRawData CreateInitialModel(int count = 4)
public LevelUpRawData CreateInitialModel()
{
_refreshCount = 0;
if (_player == null || _player.PendingLevelPoints <= 0)
if (_player.PendingLevelPoints <= 0)
{
_currentModel = null;
return null;
}
_currentModel = BuildModel(BaseRefreshPrice, count);
_currentModel = BuildModel(GameEntry.Luban.Global.LevelUpRefreshPriceBase);
return _currentModel;
}
public LevelUpRawData TryRefresh(int refreshCost, int count = 4)
public LevelUpRawData TryRefresh(int refreshCost)
{
if (_currentModel == null)
{
return null;
}
if (_player == null || _player.Coin < refreshCost)
if (_player.Coin < refreshCost)
{
return null;
}
@@ -61,11 +60,11 @@ namespace SepCore.UI
_player.Coin -= refreshCost;
_refreshCount++;
_currentModel = BuildModel((_refreshCount + 1) * BaseRefreshPrice, count);
_currentModel = BuildModel((_refreshCount + 1) * GameEntry.Luban.Global.LevelUpRefreshPriceBase);
return _currentModel;
}
public LevelUpRawData SelectReward(int selectedIndex, int count = 4)
public LevelUpRawData SelectReward(int selectedIndex)
{
if (_currentModel?.Rewards == null)
{
@@ -74,7 +73,7 @@ namespace SepCore.UI
if (selectedIndex < 0 || selectedIndex >= _currentModel.Rewards.Count)
{
Log.Warning("LevelUpFormUseCase::SelectReward: Invalid index");
Log.Error("LevelUpFormUseCase::SelectReward: Invalid index");
return null;
}
@@ -83,7 +82,7 @@ namespace SepCore.UI
if (--_player.PendingLevelPoints > 0)
{
_refreshCount = 0;
_currentModel = BuildModel(BaseRefreshPrice, count);
_currentModel = BuildModel(GameEntry.Luban.Global.LevelUpRefreshPriceBase);
return _currentModel;
}
@@ -92,25 +91,25 @@ namespace SepCore.UI
return null;
}
private LevelUpRawData BuildModel(int refreshPrice, int count)
private LevelUpRawData BuildModel(int refreshPrice)
{
if (_allRewards == null || _allRewards.Length == 0)
if (_allRewards.Length == 0)
{
Log.Error("LevelUpFormUseCase::BuildModel(): _allRewards is empty");
return null;
}
int finalCount = count > 0 ? Mathf.Min(count, _allRewards.Length) : _allRewards.Length;
int finalCount = Mathf.Min(GameEntry.Luban.Global.LevelUpRewardCount, _allRewards.Length);
List<LevelUpRewardConfig> selections = new List<LevelUpRewardConfig>(finalCount);
int currentLevel = _player != null ? _player.CurrentLevel : 1;
int currentLevel = _player.CurrentLevel;
for (int i = 0; i < finalCount; i++)
{
Rarity rarity = RarityUtility.SelectRarityForLevel(currentLevel);
LevelUpRewardConfig reward = PickRewardByRarity(rarity);
if (reward == null)
{
Log.Warning("LevelUpFormUseCase::BuildModel(): No available reward for selection.");
Log.Error("LevelUpFormUseCase::BuildModel(): No available reward for selection.");
break;
}
@@ -126,23 +125,6 @@ namespace SepCore.UI
private void ApplyReward(LevelUpRewardConfig reward)
{
if (reward == null)
{
return;
}
if (_player == null)
{
Log.Warning("LevelUpFormUseCase::ApplyReward: Player is null");
return;
}
if (reward.Modifiers == null || reward.Modifiers.Count == 0)
{
Log.Warning("LevelUpFormUseCase::ApplyReward: Reward modifiers are empty");
return;
}
_player.AddProp(new PropItem(reward.Modifiers, reward.Rarity, reward.Title, reward.Sprite));
}
@@ -151,15 +133,8 @@ namespace SepCore.UI
_rewardsByRarity.Clear();
_validRewards.Clear();
if (_allRewards == null) return;
foreach (LevelUpRewardConfig reward in _allRewards)
{
if (reward == null)
{
continue;
}
Rarity rarity = reward.Rarity;
_validRewards.Add(reward);