迁移数据表到 Luban,移除 JsonNet、EnumUtility
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class LevelUpRawData
|
||||
{
|
||||
public List<DRLevelUpReward> Rewards;
|
||||
public List<LevelUpRewardConfig> Rewards;
|
||||
public int RefreshPrice;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using Random = UnityEngine.Random;
|
||||
using UnityGameFramework.Runtime;
|
||||
using SepCore.CustomUtility;
|
||||
using GameFramework.DataTable;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.UI
|
||||
@@ -16,10 +14,9 @@ namespace SepCore.UI
|
||||
{
|
||||
private const int BaseRefreshPrice = 2;
|
||||
private readonly Action _onCompleted;
|
||||
private readonly DRLevelUpReward[] _allRewards;
|
||||
private readonly IDataTable<DRLevelRarity> _levelRarityTable;
|
||||
private readonly Dictionary<ItemRarity, List<DRLevelUpReward>> _rewardsByRarity = new();
|
||||
private readonly List<DRLevelUpReward> _validRewards = new();
|
||||
private readonly LevelUpRewardConfig[] _allRewards;
|
||||
private readonly Dictionary<Rarity, List<LevelUpRewardConfig>> _rewardsByRarity = new();
|
||||
private readonly List<LevelUpRewardConfig> _validRewards = new();
|
||||
|
||||
private int _refreshCount;
|
||||
private LevelUpRawData _currentModel;
|
||||
@@ -30,8 +27,7 @@ namespace SepCore.UI
|
||||
{
|
||||
_player = player;
|
||||
_onCompleted = onCompleted;
|
||||
_allRewards = GameEntry.DataTable.GetDataTable<DRLevelUpReward>().ToArray();
|
||||
_levelRarityTable = GameEntry.DataTable.GetDataTable<DRLevelRarity>();
|
||||
_allRewards = GameEntry.Luban.GetTable<LevelUpRewardConfig>().ToArray();
|
||||
|
||||
BuildRewardRarityPools();
|
||||
}
|
||||
@@ -105,13 +101,13 @@ namespace SepCore.UI
|
||||
}
|
||||
|
||||
int finalCount = count > 0 ? Mathf.Min(count, _allRewards.Length) : _allRewards.Length;
|
||||
List<DRLevelUpReward> selections = new List<DRLevelUpReward>(finalCount);
|
||||
List<LevelUpRewardConfig> selections = new List<LevelUpRewardConfig>(finalCount);
|
||||
|
||||
int currentLevel = _player != null ? _player.CurrentLevel : 1;
|
||||
for (int i = 0; i < finalCount; i++)
|
||||
{
|
||||
ItemRarity rarity = RarityUtility.SelectRarityForLevel(_levelRarityTable, currentLevel);
|
||||
DRLevelUpReward reward = PickRewardByRarity(rarity);
|
||||
Rarity rarity = RarityUtility.SelectRarityForLevel(currentLevel);
|
||||
LevelUpRewardConfig reward = PickRewardByRarity(rarity);
|
||||
if (reward == null)
|
||||
{
|
||||
Log.Warning("LevelUpFormUseCase::BuildModel(): No available reward for selection.");
|
||||
@@ -128,7 +124,7 @@ namespace SepCore.UI
|
||||
};
|
||||
}
|
||||
|
||||
private void ApplyReward(DRLevelUpReward reward)
|
||||
private void ApplyReward(LevelUpRewardConfig reward)
|
||||
{
|
||||
if (reward == null)
|
||||
{
|
||||
@@ -141,7 +137,7 @@ namespace SepCore.UI
|
||||
return;
|
||||
}
|
||||
|
||||
if (reward.Modifiers == null || reward.Modifiers.Length == 0)
|
||||
if (reward.Modifiers == null || reward.Modifiers.Count == 0)
|
||||
{
|
||||
Log.Warning("LevelUpFormUseCase::ApplyReward: Reward modifiers are empty");
|
||||
return;
|
||||
@@ -157,19 +153,19 @@ namespace SepCore.UI
|
||||
|
||||
if (_allRewards == null) return;
|
||||
|
||||
foreach (DRLevelUpReward reward in _allRewards)
|
||||
foreach (LevelUpRewardConfig reward in _allRewards)
|
||||
{
|
||||
if (reward == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemRarity rarity = reward.Rarity;
|
||||
Rarity rarity = reward.Rarity;
|
||||
_validRewards.Add(reward);
|
||||
|
||||
if (!_rewardsByRarity.TryGetValue(rarity, out List<DRLevelUpReward> list))
|
||||
if (!_rewardsByRarity.TryGetValue(rarity, out List<LevelUpRewardConfig> list))
|
||||
{
|
||||
list = new List<DRLevelUpReward>();
|
||||
list = new List<LevelUpRewardConfig>();
|
||||
_rewardsByRarity.Add(rarity, list);
|
||||
}
|
||||
|
||||
@@ -177,9 +173,9 @@ namespace SepCore.UI
|
||||
}
|
||||
}
|
||||
|
||||
private DRLevelUpReward PickRewardByRarity(ItemRarity rarity)
|
||||
private LevelUpRewardConfig PickRewardByRarity(Rarity rarity)
|
||||
{
|
||||
if (_rewardsByRarity.TryGetValue(rarity, out List<DRLevelUpReward> list) && list.Count > 0)
|
||||
if (_rewardsByRarity.TryGetValue(rarity, out List<LevelUpRewardConfig> list) && list.Count > 0)
|
||||
{
|
||||
return list[Random.Range(0, list.Count)];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user