bee20fd1f8
Wrap all 39 scripts and 6 test files in namespaces matching their folder structure (e.g. Assets/Scripts/Dice/ → YachtDice.Dice). Add cross-namespace using directives where types are referenced across modules. Set rootNamespace in both .asmdef files (YachtDice, YachtDice.Tests). Namespace mapping: - YachtDice.Dice — Dice, DiceRoller - YachtDice.Economy — CurrencyBank - YachtDice.Game — GameManager, DiceManager, DebugGameInput - YachtDice.Inventory — InventoryController/Model/SlotView/View - YachtDice.Modifiers — ModifierData/Effect/Enums/Pipeline/Runtime/Target - YachtDice.Persistence — SaveData, SaveSystem - YachtDice.Scoring — CategoryScorer, ScoreResult, ScoringSystem, YachtCategory - YachtDice.Shop — ShopCatalog/Controller/ItemView/Model/View - YachtDice.UI — CategoryRowView, DicePanelView, GameController, GameInfoView, ScoreCardView - YachtDice.Editor — ModifierAssetCreator - YachtDice.Tests — all test files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
924 B
C#
49 lines
924 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace YachtDice.Economy
|
|
{
|
|
|
|
public sealed class CurrencyBank : MonoBehaviour
|
|
{
|
|
[SerializeField] private int startingBalance = 500;
|
|
|
|
private int balance;
|
|
|
|
public int Balance => balance;
|
|
|
|
public event Action<int> OnBalanceChanged;
|
|
|
|
private void Awake()
|
|
{
|
|
balance = startingBalance;
|
|
}
|
|
|
|
public void Add(int amount)
|
|
{
|
|
if (amount <= 0) return;
|
|
|
|
balance += amount;
|
|
OnBalanceChanged?.Invoke(balance);
|
|
}
|
|
|
|
public bool Spend(int amount)
|
|
{
|
|
if (amount <= 0) return false;
|
|
if (balance < amount) return false;
|
|
|
|
balance -= amount;
|
|
OnBalanceChanged?.Invoke(balance);
|
|
return true;
|
|
}
|
|
|
|
public bool CanAfford(int amount) => balance >= amount;
|
|
|
|
public void SetBalance(int value)
|
|
{
|
|
balance = Mathf.Max(0, value);
|
|
OnBalanceChanged?.Invoke(balance);
|
|
}
|
|
}
|
|
}
|