47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Rewards
|
|
{
|
|
/// <summary>
|
|
/// Combat 节点奖励配置表。
|
|
/// 这里只定义“某类节点的基础奖励”,不处理装备被动、生成位置或领取状态。
|
|
/// </summary>
|
|
[CreateAssetMenu(fileName = "CombatRewardProfile", menuName = "Cielonos/Rewards/Combat Reward Profile")]
|
|
public class CombatRewardProfile : SerializedScriptableObject
|
|
{
|
|
[TitleGroup("Rules")]
|
|
[ListDrawerSettings(ShowIndexLabels = false, ListElementLabelName = nameof(CombatRewardRule.nodeType))]
|
|
public List<CombatRewardRule> rules = new();
|
|
|
|
public IReadOnlyList<CombatRewardInstruction> Resolve(MapNodeType nodeType)
|
|
{
|
|
CombatRewardRule rule = rules?.FirstOrDefault(item => item != null && item.nodeType == nodeType);
|
|
if (rule?.rewards == null || rule.rewards.Count == 0)
|
|
{
|
|
return Array.Empty<CombatRewardInstruction>();
|
|
}
|
|
|
|
return rule.rewards
|
|
.Where(reward => reward != null && reward.count > 0)
|
|
.Select(reward => reward.Clone())
|
|
.ToList();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单个 MapNodeType 对应的一组基础奖励。
|
|
/// </summary>
|
|
[Serializable]
|
|
public class CombatRewardRule
|
|
{
|
|
public MapNodeType nodeType = MapNodeType.MinorBattle;
|
|
|
|
[ListDrawerSettings(ShowIndexLabels = false)]
|
|
public List<CombatRewardInstruction> rewards = new();
|
|
}
|
|
}
|