[Fix] Code visual
This commit is contained in:
@@ -4,9 +4,8 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YachtDice.Dice
|
namespace YachtDice.Dice
|
||||||
{
|
{
|
||||||
|
public class Dice : MonoBehaviour
|
||||||
public sealed class Dice : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct Entry : IEquatable<Entry>
|
public struct Entry : IEquatable<Entry>
|
||||||
{
|
{
|
||||||
@@ -137,5 +136,5 @@ public sealed class Dice : MonoBehaviour
|
|||||||
var e = transform.localEulerAngles;
|
var e = transform.localEulerAngles;
|
||||||
transform.localEulerAngles = new Vector3(Norm180(e.x), Norm180(e.y), Norm180(e.z));
|
transform.localEulerAngles = new Vector3(Norm180(e.x), Norm180(e.y), Norm180(e.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,12 @@ using Random = UnityEngine.Random;
|
|||||||
|
|
||||||
namespace YachtDice.Dice
|
namespace YachtDice.Dice
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// Красиво подбрасывает и раскручивает кубик, ждёт пока он остановится,
|
||||||
/// Красиво подбрасывает и раскручивает кубик, ждёт пока он остановится,
|
/// плавно доворачивает до ровного положения и сообщает результат.
|
||||||
/// плавно доворачивает до ровного положения и сообщает результат.
|
/// </summary>
|
||||||
/// </summary>
|
public class DiceRoller : MonoBehaviour
|
||||||
public sealed class DiceRoller : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[Header("References")]
|
[Header("References")]
|
||||||
[SerializeField] private Dice dice;
|
[SerializeField] private Dice dice;
|
||||||
[SerializeField] private Rigidbody rb;
|
[SerializeField] private Rigidbody rb;
|
||||||
@@ -152,5 +151,5 @@ public sealed class DiceRoller : MonoBehaviour
|
|||||||
|
|
||||||
// Debug.Log($"{gameObject.name} | Выпало: <b>{topValue}</b>");
|
// Debug.Log($"{gameObject.name} | Выпало: <b>{topValue}</b>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YachtDice.Economy
|
namespace YachtDice.Economy
|
||||||
{
|
{
|
||||||
|
public class CurrencyBank : MonoBehaviour
|
||||||
public sealed class CurrencyBank : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[SerializeField] private int startingBalance = 500;
|
[SerializeField] private int startingBalance = 500;
|
||||||
|
|
||||||
private int balance;
|
private int balance;
|
||||||
@@ -44,5 +43,5 @@ public sealed class CurrencyBank : MonoBehaviour
|
|||||||
balance = Mathf.Max(0, value);
|
balance = Mathf.Max(0, value);
|
||||||
OnBalanceChanged?.Invoke(balance);
|
OnBalanceChanged?.Invoke(balance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using YachtDice.Scoring;
|
|
||||||
|
|
||||||
namespace YachtDice.Game
|
|
||||||
{
|
|
||||||
|
|
||||||
public sealed class DebugGameInput : MonoBehaviour
|
|
||||||
{
|
|
||||||
[SerializeField] private GameManager gameManager;
|
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
if (Input.GetKeyDown(KeyCode.Space))
|
|
||||||
gameManager.Roll();
|
|
||||||
|
|
||||||
// 1-5: toggle lock on dice 0-4
|
|
||||||
if (Input.GetKeyDown(KeyCode.Alpha1)) gameManager.ToggleDiceLock(0);
|
|
||||||
if (Input.GetKeyDown(KeyCode.Alpha2)) gameManager.ToggleDiceLock(1);
|
|
||||||
if (Input.GetKeyDown(KeyCode.Alpha3)) gameManager.ToggleDiceLock(2);
|
|
||||||
if (Input.GetKeyDown(KeyCode.Alpha4)) gameManager.ToggleDiceLock(3);
|
|
||||||
if (Input.GetKeyDown(KeyCode.Alpha5)) gameManager.ToggleDiceLock(4);
|
|
||||||
|
|
||||||
// Score categories
|
|
||||||
if (Input.GetKeyDown(KeyCode.F1)) gameManager.ScoreInCategory(YachtCategory.Ones);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F2)) gameManager.ScoreInCategory(YachtCategory.Twos);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F3)) gameManager.ScoreInCategory(YachtCategory.Threes);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F4)) gameManager.ScoreInCategory(YachtCategory.Fours);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F5)) gameManager.ScoreInCategory(YachtCategory.Fives);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F6)) gameManager.ScoreInCategory(YachtCategory.Sixes);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F7)) gameManager.ScoreInCategory(YachtCategory.ThreeOfAKind);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F8)) gameManager.ScoreInCategory(YachtCategory.FourOfAKind);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F9)) gameManager.ScoreInCategory(YachtCategory.FullHouse);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F10)) gameManager.ScoreInCategory(YachtCategory.SmallStraight);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F11)) gameManager.ScoreInCategory(YachtCategory.LargeStraight);
|
|
||||||
if (Input.GetKeyDown(KeyCode.F12)) gameManager.ScoreInCategory(YachtCategory.Yacht);
|
|
||||||
if (Input.GetKeyDown(KeyCode.C)) gameManager.ScoreInCategory(YachtCategory.Chance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 982f0996b85edfe419b07ddb36d6e235
|
|
||||||
@@ -5,9 +5,8 @@ using YachtDice.Dice;
|
|||||||
|
|
||||||
namespace YachtDice.Game
|
namespace YachtDice.Game
|
||||||
{
|
{
|
||||||
|
public class DiceManager : MonoBehaviour
|
||||||
public sealed class DiceManager : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[SerializeField] private List<DiceRoller> diceRollers = new();
|
[SerializeField] private List<DiceRoller> diceRollers = new();
|
||||||
|
|
||||||
public event Action OnAllDiceSettled;
|
public event Action OnAllDiceSettled;
|
||||||
@@ -99,10 +98,10 @@ public sealed class DiceManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < diceRollers.Count; i++)
|
for (int i = 0; i < diceRollers.Count; i++)
|
||||||
{
|
{
|
||||||
var diceComponent = diceRollers[i].GetComponent<Dice>();
|
var diceComponent = diceRollers[i].GetComponent<Dice.Dice>();
|
||||||
if (diceComponent != null && diceComponent.TryGetTopValue(out int val))
|
if (diceComponent != null && diceComponent.TryGetTopValue(out int val))
|
||||||
currentValues[i] = val;
|
currentValues[i] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.Game
|
namespace YachtDice.Game
|
||||||
{
|
{
|
||||||
|
public class GameManager : MonoBehaviour
|
||||||
public sealed class GameManager : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[Header("References")]
|
[Header("References")]
|
||||||
[SerializeField] private DiceManager diceManager;
|
[SerializeField] private DiceManager diceManager;
|
||||||
[SerializeField] private ScoringSystem scoringSystem;
|
[SerializeField] private ScoringSystem scoringSystem;
|
||||||
@@ -101,5 +100,5 @@ public sealed class GameManager : MonoBehaviour
|
|||||||
StartNewTurn();
|
StartNewTurn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.Inventory
|
namespace YachtDice.Inventory
|
||||||
{
|
{
|
||||||
|
public class InventoryController : MonoBehaviour
|
||||||
public sealed class InventoryController : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[SerializeField] private InventoryView inventoryView;
|
[SerializeField] private InventoryView inventoryView;
|
||||||
[SerializeField] private ScoringSystem scoringSystem;
|
[SerializeField] private ScoringSystem scoringSystem;
|
||||||
[SerializeField] private CurrencyBank currencyBank;
|
[SerializeField] private CurrencyBank currencyBank;
|
||||||
@@ -94,5 +93,5 @@ public sealed class InventoryController : MonoBehaviour
|
|||||||
if (inventoryView != null && model != null)
|
if (inventoryView != null && model != null)
|
||||||
inventoryView.Refresh(model.OwnedModifiers, model.MaxActiveSlots);
|
inventoryView.Refresh(model.OwnedModifiers, model.MaxActiveSlots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Inventory
|
namespace YachtDice.Inventory
|
||||||
{
|
{
|
||||||
|
public class InventoryModel
|
||||||
public sealed class InventoryModel
|
{
|
||||||
{
|
|
||||||
private readonly List<ModifierRuntime> ownedModifiers = new();
|
private readonly List<ModifierRuntime> ownedModifiers = new();
|
||||||
private int maxActiveSlots;
|
private int maxActiveSlots;
|
||||||
|
|
||||||
@@ -128,5 +127,5 @@ public sealed class InventoryModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ModifierRuntime> GetAllForSave() => new(ownedModifiers);
|
public List<ModifierRuntime> GetAllForSave() => new(ownedModifiers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Inventory
|
namespace YachtDice.Inventory
|
||||||
{
|
{
|
||||||
|
public class InventorySlotView : MonoBehaviour
|
||||||
public sealed class InventorySlotView : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[SerializeField] private Image iconImage;
|
[SerializeField] private Image iconImage;
|
||||||
[SerializeField] private TMP_Text nameText;
|
[SerializeField] private TMP_Text nameText;
|
||||||
[SerializeField] private TMP_Text descriptionText;
|
[SerializeField] private TMP_Text descriptionText;
|
||||||
@@ -79,5 +78,5 @@ public sealed class InventorySlotView : MonoBehaviour
|
|||||||
if (background != null)
|
if (background != null)
|
||||||
background.color = isActive ? activeColor : inactiveColor;
|
background.color = isActive ? activeColor : inactiveColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Inventory
|
namespace YachtDice.Inventory
|
||||||
{
|
{
|
||||||
|
public class InventoryView : MonoBehaviour
|
||||||
public sealed class InventoryView : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[SerializeField] private Transform slotContainer;
|
[SerializeField] private Transform slotContainer;
|
||||||
[SerializeField] private InventorySlotView slotPrefab;
|
[SerializeField] private InventorySlotView slotPrefab;
|
||||||
[SerializeField] private TMP_Text slotCountText;
|
[SerializeField] private TMP_Text slotCountText;
|
||||||
@@ -75,5 +74,5 @@ public sealed class InventoryView : MonoBehaviour
|
|||||||
private void HandleActivate(ModifierRuntime runtime) => OnActivateClicked?.Invoke(runtime);
|
private void HandleActivate(ModifierRuntime runtime) => OnActivateClicked?.Invoke(runtime);
|
||||||
private void HandleDeactivate(ModifierRuntime runtime) => OnDeactivateClicked?.Invoke(runtime);
|
private void HandleDeactivate(ModifierRuntime runtime) => OnDeactivateClicked?.Invoke(runtime);
|
||||||
private void HandleSell(ModifierRuntime runtime) => OnSellClicked?.Invoke(runtime);
|
private void HandleSell(ModifierRuntime runtime) => OnSellClicked?.Invoke(runtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.Modifiers
|
namespace YachtDice.Modifiers
|
||||||
{
|
{
|
||||||
|
[CreateAssetMenu(fileName = "NewModifier", menuName = "YachtDice/Modifier Data")]
|
||||||
[CreateAssetMenu(fileName = "NewModifier", menuName = "YachtDice/Modifier Data")]
|
public sealed class ModifierData : ScriptableObject
|
||||||
public sealed class ModifierData : ScriptableObject
|
{
|
||||||
{
|
|
||||||
[SerializeField] private string id;
|
[SerializeField] private string id;
|
||||||
[SerializeField] private string displayName;
|
[SerializeField] private string displayName;
|
||||||
[SerializeField] [TextArea] private string description;
|
[SerializeField] [TextArea] private string description;
|
||||||
@@ -55,7 +54,7 @@ public sealed class ModifierData : ScriptableObject
|
|||||||
effectType == ModifierEffectType.AddFlatToFinalScore ||
|
effectType == ModifierEffectType.AddFlatToFinalScore ||
|
||||||
effectType == ModifierEffectType.MultiplyFinalScore;
|
effectType == ModifierEffectType.MultiplyFinalScore;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
public static ModifierData CreateForTest(
|
public static ModifierData CreateForTest(
|
||||||
string id,
|
string id,
|
||||||
ModifierScope scope,
|
ModifierScope scope,
|
||||||
@@ -88,6 +87,6 @@ public sealed class ModifierData : ScriptableObject
|
|||||||
data.sellPrice = sellPrice;
|
data.sellPrice = sellPrice;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.Modifiers
|
namespace YachtDice.Modifiers
|
||||||
{
|
{
|
||||||
|
public delegate void ModifierHandler(ModifierData data, ref ScoreResult result);
|
||||||
|
|
||||||
public delegate void ModifierHandler(ModifierData data, ref ScoreResult result);
|
public static class ModifierEffect
|
||||||
|
{
|
||||||
public static class ModifierEffect
|
|
||||||
{
|
|
||||||
private static readonly Dictionary<ModifierEffectType, ModifierHandler> Handlers = new()
|
private static readonly Dictionary<ModifierEffectType, ModifierHandler> Handlers = new()
|
||||||
{
|
{
|
||||||
{ ModifierEffectType.AddPerDieValue, ApplyAddPerDieValue },
|
{ ModifierEffectType.AddPerDieValue, ApplyAddPerDieValue },
|
||||||
@@ -56,5 +55,5 @@ public static class ModifierEffect
|
|||||||
{
|
{
|
||||||
result.Multiplier *= data.EffectValue;
|
result.Multiplier *= data.EffectValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
namespace YachtDice.Modifiers
|
namespace YachtDice.Modifiers
|
||||||
{
|
{
|
||||||
public enum ModifierScope
|
public enum ModifierScope
|
||||||
{
|
{
|
||||||
SelectedCategory,
|
SelectedCategory,
|
||||||
AnyCategoryClosed
|
AnyCategoryClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ModifierEffectType
|
public enum ModifierEffectType
|
||||||
{
|
{
|
||||||
AddPerDieValue,
|
AddPerDieValue,
|
||||||
AddFlatToFinalScore,
|
AddFlatToFinalScore,
|
||||||
MultiplyPerDieValue,
|
MultiplyPerDieValue,
|
||||||
MultiplyFinalScore
|
MultiplyFinalScore
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ModifierDurability
|
public enum ModifierDurability
|
||||||
{
|
{
|
||||||
Permanent,
|
Permanent,
|
||||||
LimitedUses
|
LimitedUses
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ModifierRarity
|
public enum ModifierRarity
|
||||||
{
|
{
|
||||||
Common,
|
Common,
|
||||||
Uncommon,
|
Uncommon,
|
||||||
Rare,
|
Rare,
|
||||||
Epic
|
Epic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.Modifiers
|
namespace YachtDice.Modifiers
|
||||||
{
|
{
|
||||||
|
public static class ModifierPipeline
|
||||||
public static class ModifierPipeline
|
{
|
||||||
{
|
|
||||||
// Application order (explicit):
|
// Application order (explicit):
|
||||||
// 1. Category-level additive (AddPerDieValue)
|
// 1. Category-level additive (AddPerDieValue)
|
||||||
// 2. Category-level multiplicative (MultiplyPerDieValue)
|
// 2. Category-level multiplicative (MultiplyPerDieValue)
|
||||||
@@ -63,5 +62,5 @@ public static class ModifierPipeline
|
|||||||
if (mod.Target.HasCategoryFilter && mod.Target.TargetCategory != result.Category) return false;
|
if (mod.Target.HasCategoryFilter && mod.Target.TargetCategory != result.Category) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ using System;
|
|||||||
|
|
||||||
namespace YachtDice.Modifiers
|
namespace YachtDice.Modifiers
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
[Serializable]
|
public class ModifierRuntime
|
||||||
public sealed class ModifierRuntime
|
{
|
||||||
{
|
|
||||||
public string ModifierId;
|
public string ModifierId;
|
||||||
public bool IsActive;
|
public bool IsActive;
|
||||||
public int RemainingUses;
|
public int RemainingUses;
|
||||||
@@ -34,5 +33,5 @@ public sealed class ModifierRuntime
|
|||||||
Data = data
|
Data = data
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.Modifiers
|
namespace YachtDice.Modifiers
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
[Serializable]
|
public struct ModifierTarget
|
||||||
public struct ModifierTarget
|
{
|
||||||
{
|
|
||||||
[Tooltip("Die face value (1-6). 0 = any/all dice.")]
|
[Tooltip("Die face value (1-6). 0 = any/all dice.")]
|
||||||
[Range(0, 6)]
|
[Range(0, 6)]
|
||||||
public int DieValue;
|
public int DieValue;
|
||||||
@@ -17,5 +16,5 @@ public struct ModifierTarget
|
|||||||
|
|
||||||
[Tooltip("If true, TargetCategory is used as a filter.")]
|
[Tooltip("If true, TargetCategory is used as a filter.")]
|
||||||
public bool HasCategoryFilter;
|
public bool HasCategoryFilter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,19 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace YachtDice.Persistence
|
namespace YachtDice.Persistence
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
[Serializable]
|
public sealed class SaveData
|
||||||
public sealed class SaveData
|
{
|
||||||
{
|
|
||||||
public int Version = 1;
|
public int Version = 1;
|
||||||
public int Currency;
|
public int Currency;
|
||||||
public List<ModifierSaveEntry> OwnedModifiers = new();
|
public List<ModifierSaveEntry> OwnedModifiers = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class ModifierSaveEntry
|
public sealed class ModifierSaveEntry
|
||||||
{
|
{
|
||||||
public string ModifierId;
|
public string ModifierId;
|
||||||
public bool IsActive;
|
public bool IsActive;
|
||||||
public int RemainingUses;
|
public int RemainingUses;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YachtDice.Persistence
|
namespace YachtDice.Persistence
|
||||||
{
|
{
|
||||||
|
public static class SaveSystem
|
||||||
public static class SaveSystem
|
{
|
||||||
{
|
|
||||||
private const string SaveKey = "YachtDice_SaveData";
|
private const string SaveKey = "YachtDice_SaveData";
|
||||||
|
|
||||||
public static void Save(SaveData data)
|
public static void Save(SaveData data)
|
||||||
@@ -42,5 +41,5 @@ public static class SaveSystem
|
|||||||
{
|
{
|
||||||
return PlayerPrefs.HasKey(SaveKey);
|
return PlayerPrefs.HasKey(SaveKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ using System;
|
|||||||
|
|
||||||
namespace YachtDice.Scoring
|
namespace YachtDice.Scoring
|
||||||
{
|
{
|
||||||
|
public static class CategoryScorer
|
||||||
public static class CategoryScorer
|
{
|
||||||
{
|
|
||||||
public static int Calculate(int[] dice, YachtCategory category)
|
public static int Calculate(int[] dice, YachtCategory category)
|
||||||
{
|
{
|
||||||
if (dice == null || dice.Length != 5)
|
if (dice == null || dice.Length != 5)
|
||||||
@@ -79,5 +78,5 @@ public static class CategoryScorer
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YachtDice.Scoring
|
namespace YachtDice.Scoring
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
[Serializable]
|
public struct ScoreResult
|
||||||
public struct ScoreResult
|
{
|
||||||
{
|
|
||||||
public int BaseScore;
|
public int BaseScore;
|
||||||
public int FlatBonus;
|
public int FlatBonus;
|
||||||
public float Multiplier;
|
public float Multiplier;
|
||||||
@@ -26,5 +25,5 @@ public struct ScoreResult
|
|||||||
Category = category
|
Category = category
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Scoring
|
namespace YachtDice.Scoring
|
||||||
{
|
{
|
||||||
|
public class ScoringSystem : MonoBehaviour
|
||||||
public sealed class ScoringSystem : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
public event Action<YachtCategory, int> OnCategoryScored;
|
public event Action<YachtCategory, int> OnCategoryScored;
|
||||||
public event Action<int> OnAllCategoriesScored;
|
public event Action<int> OnAllCategoriesScored;
|
||||||
public event Action<YachtCategory, ScoreResult> OnCategoryConfirmed;
|
public event Action<YachtCategory, ScoreResult> OnCategoryConfirmed;
|
||||||
@@ -85,5 +84,5 @@ public sealed class ScoringSystem : MonoBehaviour
|
|||||||
scorecard.Clear();
|
scorecard.Clear();
|
||||||
usedCategories.Clear();
|
usedCategories.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace YachtDice.Scoring
|
namespace YachtDice.Scoring
|
||||||
{
|
{
|
||||||
public enum YachtCategory
|
public enum YachtCategory
|
||||||
{
|
{
|
||||||
// Upper Section
|
// Upper Section
|
||||||
Ones,
|
Ones,
|
||||||
Twos,
|
Twos,
|
||||||
@@ -18,5 +18,5 @@ public enum YachtCategory
|
|||||||
LargeStraight,
|
LargeStraight,
|
||||||
Yacht,
|
Yacht,
|
||||||
Chance
|
Chance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Shop
|
namespace YachtDice.Shop
|
||||||
{
|
{
|
||||||
|
[CreateAssetMenu(fileName = "ShopCatalog", menuName = "YachtDice/Shop Catalog")]
|
||||||
[CreateAssetMenu(fileName = "ShopCatalog", menuName = "YachtDice/Shop Catalog")]
|
public sealed class ShopCatalog : ScriptableObject
|
||||||
public sealed class ShopCatalog : ScriptableObject
|
{
|
||||||
{
|
|
||||||
[SerializeField] private List<ModifierData> availableModifiers = new();
|
[SerializeField] private List<ModifierData> availableModifiers = new();
|
||||||
|
|
||||||
public IReadOnlyList<ModifierData> AvailableModifiers => availableModifiers;
|
public IReadOnlyList<ModifierData> AvailableModifiers => availableModifiers;
|
||||||
@@ -21,5 +20,5 @@ public sealed class ShopCatalog : ScriptableObject
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Shop
|
namespace YachtDice.Shop
|
||||||
{
|
{
|
||||||
|
public class ShopController : MonoBehaviour
|
||||||
public sealed class ShopController : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[SerializeField] private ShopCatalog catalog;
|
[SerializeField] private ShopCatalog catalog;
|
||||||
[SerializeField] private ShopView shopView;
|
[SerializeField] private ShopView shopView;
|
||||||
[SerializeField] private CurrencyBank currencyBank;
|
[SerializeField] private CurrencyBank currencyBank;
|
||||||
@@ -57,5 +56,5 @@ public sealed class ShopController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
shopView.RefreshStates(catalog.AvailableModifiers, model);
|
shopView.RefreshStates(catalog.AvailableModifiers, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Shop
|
namespace YachtDice.Shop
|
||||||
{
|
{
|
||||||
|
public class ShopItemView : MonoBehaviour
|
||||||
public sealed class ShopItemView : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[SerializeField] private Image iconImage;
|
[SerializeField] private Image iconImage;
|
||||||
[SerializeField] private TMP_Text nameText;
|
[SerializeField] private TMP_Text nameText;
|
||||||
[SerializeField] private TMP_Text descriptionText;
|
[SerializeField] private TMP_Text descriptionText;
|
||||||
@@ -88,5 +87,5 @@ public sealed class ShopItemView : MonoBehaviour
|
|||||||
_ => commonColor
|
_ => commonColor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Shop
|
namespace YachtDice.Shop
|
||||||
{
|
{
|
||||||
|
public class ShopModel
|
||||||
public sealed class ShopModel
|
{
|
||||||
{
|
|
||||||
private readonly CurrencyBank currencyBank;
|
private readonly CurrencyBank currencyBank;
|
||||||
private readonly InventoryModel inventoryModel;
|
private readonly InventoryModel inventoryModel;
|
||||||
private readonly HashSet<string> purchasedPermanentIds = new();
|
private readonly HashSet<string> purchasedPermanentIds = new();
|
||||||
@@ -73,13 +72,13 @@ public sealed class ShopModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<string> GetPurchasedPermanentIds() => new(purchasedPermanentIds);
|
public HashSet<string> GetPurchasedPermanentIds() => new(purchasedPermanentIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ShopItemState
|
public enum ShopItemState
|
||||||
{
|
{
|
||||||
Available,
|
Available,
|
||||||
TooExpensive,
|
TooExpensive,
|
||||||
Owned,
|
Owned,
|
||||||
RepurchaseAvailable
|
RepurchaseAvailable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Shop
|
namespace YachtDice.Shop
|
||||||
{
|
{
|
||||||
|
public class ShopView : MonoBehaviour
|
||||||
public sealed class ShopView : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[SerializeField] private Transform itemContainer;
|
[SerializeField] private Transform itemContainer;
|
||||||
[SerializeField] private ShopItemView itemPrefab;
|
[SerializeField] private ShopItemView itemPrefab;
|
||||||
[SerializeField] private TMP_Text currencyText;
|
[SerializeField] private TMP_Text currencyText;
|
||||||
@@ -78,5 +77,5 @@ public sealed class ShopView : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void HandleBuy(ModifierData data) => OnBuyClicked?.Invoke(data);
|
private void HandleBuy(ModifierData data) => OnBuyClicked?.Invoke(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Tests
|
namespace YachtDice.Tests
|
||||||
{
|
{
|
||||||
|
public class InventoryModelTests
|
||||||
public sealed class InventoryModelTests
|
{
|
||||||
{
|
|
||||||
private InventoryModel inventory;
|
private InventoryModel inventory;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
@@ -157,5 +156,5 @@ public sealed class InventoryModelTests
|
|||||||
|
|
||||||
Assert.IsTrue(fired);
|
Assert.IsTrue(fired);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.Tests
|
namespace YachtDice.Tests
|
||||||
{
|
{
|
||||||
|
public class ModifierEffectTests
|
||||||
public sealed class ModifierEffectTests
|
{
|
||||||
{
|
|
||||||
private static ModifierData CreateData(
|
private static ModifierData CreateData(
|
||||||
ModifierEffectType effectType, float effectValue,
|
ModifierEffectType effectType, float effectValue,
|
||||||
int dieValue = 0, ModifierScope scope = ModifierScope.SelectedCategory)
|
int dieValue = 0, ModifierScope scope = ModifierScope.SelectedCategory)
|
||||||
@@ -91,5 +90,5 @@ public sealed class ModifierEffectTests
|
|||||||
|
|
||||||
Assert.AreEqual(1.5f, result.Multiplier, 0.001f);
|
Assert.AreEqual(1.5f, result.Multiplier, 0.001f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.Tests
|
namespace YachtDice.Tests
|
||||||
{
|
{
|
||||||
|
public class ModifierPipelineTests
|
||||||
public sealed class ModifierPipelineTests
|
{
|
||||||
{
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Apply_AdditiveBeforeMultiplicative()
|
public void Apply_AdditiveBeforeMultiplicative()
|
||||||
{
|
{
|
||||||
@@ -138,5 +137,5 @@ public sealed class ModifierPipelineTests
|
|||||||
|
|
||||||
Assert.AreEqual(10, result.FinalScore);
|
Assert.AreEqual(10, result.FinalScore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ using YachtDice.Persistence;
|
|||||||
|
|
||||||
namespace YachtDice.Tests
|
namespace YachtDice.Tests
|
||||||
{
|
{
|
||||||
|
public class SaveSystemTests
|
||||||
public sealed class SaveSystemTests
|
{
|
||||||
{
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
@@ -89,5 +88,5 @@ public sealed class SaveSystemTests
|
|||||||
Assert.IsNotNull(loaded);
|
Assert.IsNotNull(loaded);
|
||||||
Assert.AreEqual(0, loaded.Currency);
|
Assert.AreEqual(0, loaded.Currency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Tests
|
namespace YachtDice.Tests
|
||||||
{
|
{
|
||||||
|
public class ScoringSystemTests
|
||||||
public sealed class ScoringSystemTests
|
{
|
||||||
{
|
|
||||||
private ScoringSystem CreateScoringSystem()
|
private ScoringSystem CreateScoringSystem()
|
||||||
{
|
{
|
||||||
var go = new GameObject("ScoringSystem");
|
var go = new GameObject("ScoringSystem");
|
||||||
@@ -100,5 +99,5 @@ public sealed class ScoringSystemTests
|
|||||||
Assert.AreEqual(1f, result.Multiplier);
|
Assert.AreEqual(1f, result.Multiplier);
|
||||||
Assert.AreEqual(50, result.FinalScore);
|
Assert.AreEqual(50, result.FinalScore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.Tests
|
namespace YachtDice.Tests
|
||||||
{
|
{
|
||||||
|
public sealed class ShopModelTests
|
||||||
public sealed class ShopModelTests
|
{
|
||||||
{
|
|
||||||
private CurrencyBank bank;
|
private CurrencyBank bank;
|
||||||
private InventoryModel inventory;
|
private InventoryModel inventory;
|
||||||
private ShopModel shop;
|
private ShopModel shop;
|
||||||
@@ -134,5 +133,5 @@ public sealed class ShopModelTests
|
|||||||
|
|
||||||
Assert.AreEqual(ShopItemState.Owned, shop.GetItemState(mod));
|
Assert.AreEqual(ShopItemState.Owned, shop.GetItemState(mod));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.UI
|
namespace YachtDice.UI
|
||||||
{
|
{
|
||||||
|
public class CategoryRowView : MonoBehaviour
|
||||||
public sealed class CategoryRowView : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[Header("UI Elements")]
|
[Header("UI Elements")]
|
||||||
[SerializeField] private TMP_Text categoryNameText;
|
[SerializeField] private TMP_Text categoryNameText;
|
||||||
[SerializeField] private TMP_Text previewText;
|
[SerializeField] private TMP_Text previewText;
|
||||||
@@ -90,5 +89,5 @@ public sealed class CategoryRowView : MonoBehaviour
|
|||||||
{
|
{
|
||||||
selectButton.onClick.RemoveListener(HandleClick);
|
selectButton.onClick.RemoveListener(HandleClick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ using TMPro;
|
|||||||
|
|
||||||
namespace YachtDice.UI
|
namespace YachtDice.UI
|
||||||
{
|
{
|
||||||
|
public class DicePanelView : MonoBehaviour
|
||||||
public sealed class DicePanelView : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[Header("Dice Display")]
|
[Header("Dice Display")]
|
||||||
[SerializeField] private Button[] diceButtons = new Button[5];
|
[SerializeField] private Button[] diceButtons = new Button[5];
|
||||||
[SerializeField] private TMP_Text[] diceValueTexts = new TMP_Text[5];
|
[SerializeField] private TMP_Text[] diceValueTexts = new TMP_Text[5];
|
||||||
@@ -101,5 +100,5 @@ public sealed class DicePanelView : MonoBehaviour
|
|||||||
|
|
||||||
rollButton.onClick.RemoveAllListeners();
|
rollButton.onClick.RemoveAllListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ using YachtDice.Modifiers;
|
|||||||
|
|
||||||
namespace YachtDice.UI
|
namespace YachtDice.UI
|
||||||
{
|
{
|
||||||
|
public class GameController : MonoBehaviour
|
||||||
public sealed class GameController : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[Header("Model")]
|
[Header("Model")]
|
||||||
[SerializeField] private GameManager gameManager;
|
[SerializeField] private GameManager gameManager;
|
||||||
[SerializeField] private ScoringSystem scoringSystem;
|
[SerializeField] private ScoringSystem scoringSystem;
|
||||||
@@ -354,5 +353,5 @@ public sealed class GameController : MonoBehaviour
|
|||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ using TMPro;
|
|||||||
|
|
||||||
namespace YachtDice.UI
|
namespace YachtDice.UI
|
||||||
{
|
{
|
||||||
|
public class GameInfoView : MonoBehaviour
|
||||||
public sealed class GameInfoView : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[Header("Turn Info")]
|
[Header("Turn Info")]
|
||||||
[SerializeField] private TMP_Text turnText;
|
[SerializeField] private TMP_Text turnText;
|
||||||
|
|
||||||
@@ -69,5 +68,5 @@ public sealed class GameInfoView : MonoBehaviour
|
|||||||
if (inventoryButton != null)
|
if (inventoryButton != null)
|
||||||
inventoryButton.onClick.RemoveAllListeners();
|
inventoryButton.onClick.RemoveAllListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ using YachtDice.Scoring;
|
|||||||
|
|
||||||
namespace YachtDice.UI
|
namespace YachtDice.UI
|
||||||
{
|
{
|
||||||
|
public class ScoreCardView : MonoBehaviour
|
||||||
public sealed class ScoreCardView : MonoBehaviour
|
{
|
||||||
{
|
|
||||||
[Header("Category Rows (in YachtCategory enum order)")]
|
[Header("Category Rows (in YachtCategory enum order)")]
|
||||||
[SerializeField] private List<CategoryRowView> categoryRows = new();
|
[SerializeField] private List<CategoryRowView> categoryRows = new();
|
||||||
|
|
||||||
@@ -110,5 +109,5 @@ public sealed class ScoreCardView : MonoBehaviour
|
|||||||
for (int i = 0; i < categoryRows.Count; i++)
|
for (int i = 0; i < categoryRows.Count; i++)
|
||||||
categoryRows[i].OnCategorySelected -= HandleCategorySelected;
|
categoryRows[i].OnCategorySelected -= HandleCategorySelected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user