77 lines
2.3 KiB
C#
77 lines
2.3 KiB
C#
|
|
using System;
|
|||
|
|
using Cielonos.MainGame.Inventory;
|
|||
|
|
using Cielonos.MainGame.Interactions;
|
|||
|
|
using Sirenix.OdinInspector;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Cielonos.MainGame.Rewards
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Combat 节点奖励的基础类型。
|
|||
|
|
/// RareMaterial 是即时奖励;SupplyPack/MechanicalTable 会生成交互物并阻塞节点完成。
|
|||
|
|
/// </summary>
|
|||
|
|
public enum CombatRewardInstructionType
|
|||
|
|
{
|
|||
|
|
RareMaterial,
|
|||
|
|
SupplyPack,
|
|||
|
|
MechanicalTable,
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 一条奖励指令。Profile 负责配置它,Resolver 会 Clone 后交给 Modifier 和 Dispatcher 使用。
|
|||
|
|
/// </summary>
|
|||
|
|
[Serializable]
|
|||
|
|
[InlineProperty]
|
|||
|
|
[HideReferenceObjectPicker]
|
|||
|
|
public class CombatRewardInstruction
|
|||
|
|
{
|
|||
|
|
[HorizontalGroup("Row", Width = 0.28f)]
|
|||
|
|
[HideLabel]
|
|||
|
|
public CombatRewardInstructionType type = CombatRewardInstructionType.RareMaterial;
|
|||
|
|
|
|||
|
|
[HorizontalGroup("Row", Width = 0.22f)]
|
|||
|
|
[LabelText("Count")]
|
|||
|
|
[MinValue(1)]
|
|||
|
|
public int count = 1;
|
|||
|
|
|
|||
|
|
[ShowIf(nameof(IsRareMaterial))]
|
|||
|
|
[LabelText("RareMaterial Range")]
|
|||
|
|
public Vector2Int rareMaterialRange = new(10, 20);
|
|||
|
|
|
|||
|
|
public bool IsRareMaterial => type == CombatRewardInstructionType.RareMaterial;
|
|||
|
|
public bool UsesInteractable => type == CombatRewardInstructionType.SupplyPack || type == CombatRewardInstructionType.MechanicalTable;
|
|||
|
|
|
|||
|
|
public string ResolveInteractablePrefabId()
|
|||
|
|
{
|
|||
|
|
return type switch
|
|||
|
|
{
|
|||
|
|
CombatRewardInstructionType.SupplyPack => nameof(SupplyPack),
|
|||
|
|
CombatRewardInstructionType.MechanicalTable => nameof(MechanicalTable),
|
|||
|
|
_ => string.Empty,
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int RollRareMaterial(System.Random rng)
|
|||
|
|
{
|
|||
|
|
if (rng == null)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int min = Mathf.Min(rareMaterialRange.x, rareMaterialRange.y);
|
|||
|
|
int max = Mathf.Max(rareMaterialRange.x, rareMaterialRange.y);
|
|||
|
|
return Mathf.Max(0, rng.Next(min, max + 1));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public CombatRewardInstruction Clone()
|
|||
|
|
{
|
|||
|
|
return new CombatRewardInstruction
|
|||
|
|
{
|
|||
|
|
type = type,
|
|||
|
|
count = count,
|
|||
|
|
rareMaterialRange = rareMaterialRange,
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|