Merge branch 'claude/vibrant-tereshkova'
# Conflicts: # Assets/Scripts/Dice/DiceRoller.cs
This commit is contained in:
@@ -10,20 +10,14 @@ namespace YachtDice.Categories
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class CategoryDefinition : ScriptableObject
|
public abstract class CategoryDefinition : ScriptableObject
|
||||||
{
|
{
|
||||||
[Header("Identity")]
|
[field: Header("Identity")]
|
||||||
[SerializeField] private string id;
|
[field: SerializeField] public string Id { get; private set; }
|
||||||
[SerializeField] private string displayName;
|
[field: SerializeField] public string DisplayName { get; private set; }
|
||||||
[SerializeField, TextArea] private string description;
|
[field: SerializeField, TextArea] public string Description { get; private set; }
|
||||||
[SerializeField] private Sprite icon;
|
[field: SerializeField] public Sprite Icon { get; private set; }
|
||||||
|
|
||||||
[Header("Section")]
|
[field: Header("Section")]
|
||||||
[SerializeField] private bool isUpperSection;
|
[field: SerializeField] public bool IsUpperSection { get; private set; }
|
||||||
|
|
||||||
public string Id => id;
|
|
||||||
public string DisplayName => displayName;
|
|
||||||
public string Description => description;
|
|
||||||
public Sprite Icon => icon;
|
|
||||||
public bool IsUpperSection => isUpperSection;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вычисляет очки для данного набора дайсов.
|
/// Вычисляет очки для данного набора дайсов.
|
||||||
@@ -33,9 +27,9 @@ namespace YachtDice.Categories
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
public void SetTestData(string testId, string testDisplayName, bool upperSection = false)
|
public void SetTestData(string testId, string testDisplayName, bool upperSection = false)
|
||||||
{
|
{
|
||||||
id = testId;
|
Id = testId;
|
||||||
displayName = testDisplayName;
|
DisplayName = testDisplayName;
|
||||||
isUpperSection = upperSection;
|
IsUpperSection = upperSection;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,17 +11,15 @@ namespace YachtDice.Categories
|
|||||||
[CreateAssetMenu(fileName = "SumOfValueCategory", menuName = "YachtDice/Categories/Sum Of Value")]
|
[CreateAssetMenu(fileName = "SumOfValueCategory", menuName = "YachtDice/Categories/Sum Of Value")]
|
||||||
public class SumOfValueCategory : CategoryDefinition
|
public class SumOfValueCategory : CategoryDefinition
|
||||||
{
|
{
|
||||||
[Header("Scoring")]
|
[field: Header("Scoring")]
|
||||||
[Tooltip("Значение грани для суммирования (1-6)")]
|
[field: Tooltip("Значение грани для суммирования (1-6)")]
|
||||||
[SerializeField, Range(1, 6)] private int targetValue = 1;
|
[field: SerializeField, Range(1, 6)] public int TargetValue { get; private set; } = 1;
|
||||||
|
|
||||||
public int TargetValue => targetValue;
|
|
||||||
|
|
||||||
public override int Calculate(IReadOnlyList<IDie> dice)
|
public override int Calculate(IReadOnlyList<IDie> dice)
|
||||||
{
|
{
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int i = 0; i < dice.Count; i++)
|
for (int i = 0; i < dice.Count; i++)
|
||||||
if (dice[i].Value == targetValue) sum += targetValue;
|
if (dice[i].Value == TargetValue) sum += TargetValue;
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +28,7 @@ namespace YachtDice.Categories
|
|||||||
{
|
{
|
||||||
var so = CreateInstance<SumOfValueCategory>();
|
var so = CreateInstance<SumOfValueCategory>();
|
||||||
so.SetTestData(id, displayName, upperSection: true);
|
so.SetTestData(id, displayName, upperSection: true);
|
||||||
so.targetValue = target;
|
so.TargetValue = target;
|
||||||
return so;
|
return so;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,15 +9,12 @@ namespace YachtDice.Dice
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public struct Entry : IEquatable<Entry>
|
public struct Entry : IEquatable<Entry>
|
||||||
{
|
{
|
||||||
[SerializeField] private int value;
|
[field: SerializeField] public int Value { get; private set; }
|
||||||
[SerializeField] private Transform point;
|
[field: SerializeField] public Transform Point { get; private set; }
|
||||||
|
|
||||||
public int Value => value;
|
public bool Equals(Entry other) => Point == other.Point;
|
||||||
public Transform Point => point;
|
|
||||||
|
|
||||||
public bool Equals(Entry other) => point == other.point;
|
|
||||||
public override bool Equals(object obj) => obj is Entry other && Equals(other);
|
public override bool Equals(object obj) => obj is Entry other && Equals(other);
|
||||||
public override int GetHashCode() => point != null ? point.GetHashCode() : 0;
|
public override int GetHashCode() => Point != null ? Point.GetHashCode() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializeField] private List<Entry> entries = new();
|
[SerializeField] private List<Entry> entries = new();
|
||||||
|
|||||||
@@ -9,20 +9,15 @@ namespace YachtDice.Dice
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class DiсeDefinition : ScriptableObject, IShopItem
|
public abstract class DiсeDefinition : ScriptableObject, IShopItem
|
||||||
{
|
{
|
||||||
[Header("Identity")]
|
[field: Header("Identity")]
|
||||||
[SerializeField] private string id;
|
[field: SerializeField] public string Id { get; private set; }
|
||||||
[SerializeField] private string displayName;
|
[field: SerializeField] public string DisplayName { get; private set; }
|
||||||
[SerializeField, TextArea] private string description;
|
[field: SerializeField, TextArea] public string Description { get; private set; }
|
||||||
[SerializeField] private Sprite icon;
|
[field: SerializeField] public Sprite Icon { get; private set; }
|
||||||
|
|
||||||
[Header("Economy")]
|
[field: Header("Economy")]
|
||||||
[SerializeField] private int shopPrice;
|
[field: SerializeField] public int ShopPrice { get; private set; }
|
||||||
|
|
||||||
public string Id => id;
|
|
||||||
public string DisplayName => displayName;
|
|
||||||
public string Description => description;
|
|
||||||
public Sprite Icon => icon;
|
|
||||||
public int ShopPrice => shopPrice;
|
|
||||||
public bool IsRepurchasable => false;
|
public bool IsRepurchasable => false;
|
||||||
|
|
||||||
/// <summary>Количество граней.</summary>
|
/// <summary>Количество граней.</summary>
|
||||||
@@ -36,10 +31,10 @@ namespace YachtDice.Dice
|
|||||||
int shopPrice = 0, string description = null) where T : DiсeDefinition
|
int shopPrice = 0, string description = null) where T : DiсeDefinition
|
||||||
{
|
{
|
||||||
var so = CreateInstance<T>();
|
var so = CreateInstance<T>();
|
||||||
so.id = id;
|
so.Id = id;
|
||||||
so.displayName = displayName ?? id;
|
so.DisplayName = displayName ?? id;
|
||||||
so.description = description ?? id;
|
so.Description = description ?? id;
|
||||||
so.shopPrice = shopPrice;
|
so.ShopPrice = shopPrice;
|
||||||
return so;
|
return so;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,17 +7,14 @@ namespace YachtDice.Modifiers.Definition
|
|||||||
{
|
{
|
||||||
public abstract class Effect : ScriptableObject, IEffect
|
public abstract class Effect : ScriptableObject, IEffect
|
||||||
{
|
{
|
||||||
[SerializeField] private ModifierPhase phase = ModifierPhase.Additive;
|
[field: SerializeField] public ModifierPhase Phase { get; private set; } = ModifierPhase.Additive;
|
||||||
[SerializeField] private int priority;
|
[field: SerializeField] public int Priority { get; private set; }
|
||||||
|
|
||||||
public ModifierPhase Phase => phase;
|
|
||||||
public int Priority => priority;
|
|
||||||
|
|
||||||
public abstract UniTask Apply(ModifierContext context, ModifierInstance instance);
|
public abstract UniTask Apply(ModifierContext context, ModifierInstance instance);
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
public void SetPhaseForTest(ModifierPhase p) => phase = p;
|
public void SetPhaseForTest(ModifierPhase p) => Phase = p;
|
||||||
public void SetPriorityForTest(int p) => priority = p;
|
public void SetPriorityForTest(int p) => Priority = p;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ namespace YachtDice.Modifiers.Definition
|
|||||||
[CreateAssetMenu(fileName = "NewBehavior", menuName = "YachtDice/Modifiers/Behavior")]
|
[CreateAssetMenu(fileName = "NewBehavior", menuName = "YachtDice/Modifiers/Behavior")]
|
||||||
public class ModifierBehavior : ScriptableObject
|
public class ModifierBehavior : ScriptableObject
|
||||||
{
|
{
|
||||||
[SerializeField] private TriggerType trigger;
|
[field: SerializeField] public TriggerType Trigger { get; private set; }
|
||||||
[SerializeField] private List<Condition> conditions = new();
|
[SerializeField] private List<Condition> conditions = new();
|
||||||
[SerializeField] private List<Effect> effects = new();
|
[SerializeField] private List<Effect> effects = new();
|
||||||
|
|
||||||
public TriggerType Trigger => trigger;
|
|
||||||
public IReadOnlyList<Condition> Conditions => conditions;
|
public IReadOnlyList<Condition> Conditions => conditions;
|
||||||
public IReadOnlyList<Effect> Effects => effects;
|
public IReadOnlyList<Effect> Effects => effects;
|
||||||
|
|
||||||
@@ -33,7 +32,7 @@ namespace YachtDice.Modifiers.Definition
|
|||||||
List<Effect> effects)
|
List<Effect> effects)
|
||||||
{
|
{
|
||||||
var so = CreateInstance<ModifierBehavior>();
|
var so = CreateInstance<ModifierBehavior>();
|
||||||
so.trigger = trigger;
|
so.Trigger = trigger;
|
||||||
so.conditions = conditions ?? new List<Condition>();
|
so.conditions = conditions ?? new List<Condition>();
|
||||||
so.effects = effects ?? new List<Effect>();
|
so.effects = effects ?? new List<Effect>();
|
||||||
return so;
|
return so;
|
||||||
|
|||||||
@@ -8,36 +8,26 @@ namespace YachtDice.Modifiers.Definition
|
|||||||
[CreateAssetMenu(fileName = "NewModifier", menuName = "YachtDice/Modifiers/Definition")]
|
[CreateAssetMenu(fileName = "NewModifier", menuName = "YachtDice/Modifiers/Definition")]
|
||||||
public class ModifierDefinition : ScriptableObject, IShopItem
|
public class ModifierDefinition : ScriptableObject, IShopItem
|
||||||
{
|
{
|
||||||
[Header("Identity")]
|
[field: Header("Identity")]
|
||||||
[SerializeField] private string id;
|
[field: SerializeField] public string Id { get; private set; }
|
||||||
[SerializeField] private string displayName;
|
[field: SerializeField] public string DisplayName { get; private set; }
|
||||||
[SerializeField, TextArea] private string description;
|
[field: SerializeField, TextArea] public string Description { get; private set; }
|
||||||
[SerializeField] private Sprite icon;
|
[field: SerializeField] public Sprite Icon { get; private set; }
|
||||||
[SerializeField] private ModifierRarity rarity;
|
[field: SerializeField] public ModifierRarity Rarity { get; private set; }
|
||||||
|
|
||||||
[Header("Economy")]
|
[field: Header("Economy")]
|
||||||
[SerializeField] private int shopPrice;
|
[field: SerializeField] public int ShopPrice { get; private set; }
|
||||||
[SerializeField] private int sellPrice;
|
[field: SerializeField] public int SellPrice { get; private set; }
|
||||||
|
|
||||||
[Header("Durability")]
|
[field: Header("Durability")]
|
||||||
[SerializeField] private bool hasLimitedUses;
|
[field: SerializeField] public bool HasLimitedUses { get; private set; }
|
||||||
[SerializeField] private int maxUses;
|
[field: SerializeField] public int MaxUses { get; private set; }
|
||||||
[SerializeField] private int maxStacks = 1;
|
[field: SerializeField] public int MaxStacks { get; private set; } = 1;
|
||||||
|
|
||||||
[Header("Behaviors")]
|
[Header("Behaviors")]
|
||||||
[SerializeField] private List<ModifierBehavior> behaviors = new();
|
[SerializeField] private List<ModifierBehavior> behaviors = new();
|
||||||
|
|
||||||
public string Id => id;
|
public bool IsRepurchasable => HasLimitedUses;
|
||||||
public string DisplayName => displayName;
|
|
||||||
public string Description => description;
|
|
||||||
public Sprite Icon => icon;
|
|
||||||
public ModifierRarity Rarity => rarity;
|
|
||||||
public int ShopPrice => shopPrice;
|
|
||||||
public int SellPrice => sellPrice;
|
|
||||||
public bool HasLimitedUses => hasLimitedUses;
|
|
||||||
public int MaxUses => maxUses;
|
|
||||||
public int MaxStacks => maxStacks;
|
|
||||||
public bool IsRepurchasable => hasLimitedUses;
|
|
||||||
public IReadOnlyList<ModifierBehavior> Behaviors => behaviors;
|
public IReadOnlyList<ModifierBehavior> Behaviors => behaviors;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@@ -51,14 +41,14 @@ namespace YachtDice.Modifiers.Definition
|
|||||||
ModifierRarity rarity = ModifierRarity.Common)
|
ModifierRarity rarity = ModifierRarity.Common)
|
||||||
{
|
{
|
||||||
var so = CreateInstance<ModifierDefinition>();
|
var so = CreateInstance<ModifierDefinition>();
|
||||||
so.id = id;
|
so.Id = id;
|
||||||
so.displayName = id;
|
so.DisplayName = id;
|
||||||
so.description = id;
|
so.Description = id;
|
||||||
so.rarity = rarity;
|
so.Rarity = rarity;
|
||||||
so.shopPrice = shopPrice;
|
so.ShopPrice = shopPrice;
|
||||||
so.sellPrice = sellPrice;
|
so.SellPrice = sellPrice;
|
||||||
so.hasLimitedUses = hasLimitedUses;
|
so.HasLimitedUses = hasLimitedUses;
|
||||||
so.maxUses = maxUses;
|
so.MaxUses = maxUses;
|
||||||
so.behaviors = behaviors ?? new List<ModifierBehavior>();
|
so.behaviors = behaviors ?? new List<ModifierBehavior>();
|
||||||
return so;
|
return so;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user