[Refactor] Add folder-based namespaces to all C# scripts

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>
This commit is contained in:
2026-02-28 19:06:57 +07:00
parent d3594f23f9
commit bee20fd1f8
41 changed files with 204 additions and 3 deletions
+7
View File
@@ -1,6 +1,12 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using YachtDice.Modifiers;
using YachtDice.Scoring;
using YachtDice.Shop;
namespace YachtDice.Editor
{
public static class ModifierAssetCreator
{
@@ -120,4 +126,5 @@ public static class ModifierAssetCreator
}
}
}
}
#endif
+5 -1
View File
@@ -2,6 +2,9 @@ using System;
using System.Collections.Generic;
using UnityEngine;
namespace YachtDice.Dice
{
public sealed class Dice : MonoBehaviour
{
[Serializable]
@@ -134,4 +137,5 @@ public sealed class Dice : MonoBehaviour
var e = transform.localEulerAngles;
transform.localEulerAngles = new Vector3(Norm180(e.x), Norm180(e.y), Norm180(e.z));
}
}
}
}
+4
View File
@@ -3,6 +3,9 @@ using System.Collections;
using UnityEngine;
using Random = UnityEngine.Random;
namespace YachtDice.Dice
{
/// <summary>
/// Красиво подбрасывает и раскручивает кубик, ждёт пока он остановится,
/// плавно доворачивает до ровного положения и сообщает результат.
@@ -150,3 +153,4 @@ public sealed class DiceRoller : MonoBehaviour
// Debug.Log($"{gameObject.name} | Выпало: <b>{topValue}</b>");
}
}
}
+4
View File
@@ -1,6 +1,9 @@
using System;
using UnityEngine;
namespace YachtDice.Economy
{
public sealed class CurrencyBank : MonoBehaviour
{
[SerializeField] private int startingBalance = 500;
@@ -42,3 +45,4 @@ public sealed class CurrencyBank : MonoBehaviour
OnBalanceChanged?.Invoke(balance);
}
}
}
+5
View File
@@ -1,4 +1,8 @@
using UnityEngine;
using YachtDice.Scoring;
namespace YachtDice.Game
{
public sealed class DebugGameInput : MonoBehaviour
{
@@ -32,3 +36,4 @@ public sealed class DebugGameInput : MonoBehaviour
if (Input.GetKeyDown(KeyCode.C)) gameManager.ScoreInCategory(YachtCategory.Chance);
}
}
}
+5
View File
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using YachtDice.Dice;
namespace YachtDice.Game
{
public sealed class DiceManager : MonoBehaviour
{
@@ -101,3 +105,4 @@ public sealed class DiceManager : MonoBehaviour
}
}
}
}
+5
View File
@@ -1,5 +1,9 @@
using System;
using UnityEngine;
using YachtDice.Scoring;
namespace YachtDice.Game
{
public sealed class GameManager : MonoBehaviour
{
@@ -98,3 +102,4 @@ public sealed class GameManager : MonoBehaviour
}
}
}
}
@@ -1,4 +1,10 @@
using UnityEngine;
using YachtDice.Economy;
using YachtDice.Modifiers;
using YachtDice.Scoring;
namespace YachtDice.Inventory
{
public sealed class InventoryController : MonoBehaviour
{
@@ -89,3 +95,4 @@ public sealed class InventoryController : MonoBehaviour
inventoryView.Refresh(model.OwnedModifiers, model.MaxActiveSlots);
}
}
}
@@ -1,5 +1,9 @@
using System;
using System.Collections.Generic;
using YachtDice.Modifiers;
namespace YachtDice.Inventory
{
public sealed class InventoryModel
{
@@ -125,3 +129,4 @@ public sealed class InventoryModel
public List<ModifierRuntime> GetAllForSave() => new(ownedModifiers);
}
}
@@ -2,6 +2,10 @@ using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YachtDice.Modifiers;
namespace YachtDice.Inventory
{
public sealed class InventorySlotView : MonoBehaviour
{
@@ -76,3 +80,4 @@ public sealed class InventorySlotView : MonoBehaviour
background.color = isActive ? activeColor : inactiveColor;
}
}
}
@@ -3,6 +3,10 @@ using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YachtDice.Modifiers;
namespace YachtDice.Inventory
{
public sealed class InventoryView : MonoBehaviour
{
@@ -72,3 +76,4 @@ public sealed class InventoryView : MonoBehaviour
private void HandleDeactivate(ModifierRuntime runtime) => OnDeactivateClicked?.Invoke(runtime);
private void HandleSell(ModifierRuntime runtime) => OnSellClicked?.Invoke(runtime);
}
}
+5
View File
@@ -1,4 +1,8 @@
using UnityEngine;
using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
[CreateAssetMenu(fileName = "NewModifier", menuName = "YachtDice/Modifier Data")]
public sealed class ModifierData : ScriptableObject
@@ -86,3 +90,4 @@ public sealed class ModifierData : ScriptableObject
}
#endif
}
}
@@ -1,4 +1,8 @@
using System.Collections.Generic;
using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
public delegate void ModifierHandler(ModifierData data, ref ScoreResult result);
@@ -53,3 +57,4 @@ public static class ModifierEffect
result.Multiplier *= data.EffectValue;
}
}
}
@@ -1,3 +1,5 @@
namespace YachtDice.Modifiers
{
public enum ModifierScope
{
SelectedCategory,
@@ -25,3 +27,4 @@ public enum ModifierRarity
Rare,
Epic
}
}
@@ -1,4 +1,8 @@
using System.Collections.Generic;
using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
public static class ModifierPipeline
{
@@ -60,3 +64,4 @@ public static class ModifierPipeline
return true;
}
}
}
@@ -1,5 +1,8 @@
using System;
namespace YachtDice.Modifiers
{
[Serializable]
public sealed class ModifierRuntime
{
@@ -32,3 +35,4 @@ public sealed class ModifierRuntime
};
}
}
}
@@ -1,5 +1,9 @@
using System;
using UnityEngine;
using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
[Serializable]
public struct ModifierTarget
@@ -14,3 +18,4 @@ public struct ModifierTarget
[Tooltip("If true, TargetCategory is used as a filter.")]
public bool HasCategoryFilter;
}
}
+4
View File
@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
namespace YachtDice.Persistence
{
[Serializable]
public sealed class SaveData
{
@@ -16,3 +19,4 @@ public sealed class ModifierSaveEntry
public bool IsActive;
public int RemainingUses;
}
}
+4
View File
@@ -1,6 +1,9 @@
using Newtonsoft.Json;
using UnityEngine;
namespace YachtDice.Persistence
{
public static class SaveSystem
{
private const string SaveKey = "YachtDice_SaveData";
@@ -40,3 +43,4 @@ public static class SaveSystem
return PlayerPrefs.HasKey(SaveKey);
}
}
}
+4
View File
@@ -1,5 +1,8 @@
using System;
namespace YachtDice.Scoring
{
public static class CategoryScorer
{
public static int Calculate(int[] dice, YachtCategory category)
@@ -77,3 +80,4 @@ public static class CategoryScorer
return false;
}
}
}
+4
View File
@@ -1,6 +1,9 @@
using System;
using UnityEngine;
namespace YachtDice.Scoring
{
[Serializable]
public struct ScoreResult
{
@@ -24,3 +27,4 @@ public struct ScoreResult
};
}
}
}
+5
View File
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using YachtDice.Modifiers;
namespace YachtDice.Scoring
{
public sealed class ScoringSystem : MonoBehaviour
{
@@ -82,3 +86,4 @@ public sealed class ScoringSystem : MonoBehaviour
usedCategories.Clear();
}
}
}
+3
View File
@@ -1,3 +1,5 @@
namespace YachtDice.Scoring
{
public enum YachtCategory
{
// Upper Section
@@ -17,3 +19,4 @@ public enum YachtCategory
Yacht,
Chance
}
}
+5
View File
@@ -1,5 +1,9 @@
using System.Collections.Generic;
using UnityEngine;
using YachtDice.Modifiers;
namespace YachtDice.Shop
{
[CreateAssetMenu(fileName = "ShopCatalog", menuName = "YachtDice/Shop Catalog")]
public sealed class ShopCatalog : ScriptableObject
@@ -18,3 +22,4 @@ public sealed class ShopCatalog : ScriptableObject
return null;
}
}
}
+6
View File
@@ -1,4 +1,9 @@
using UnityEngine;
using YachtDice.Economy;
using YachtDice.Modifiers;
namespace YachtDice.Shop
{
public sealed class ShopController : MonoBehaviour
{
@@ -53,3 +58,4 @@ public sealed class ShopController : MonoBehaviour
shopView.RefreshStates(catalog.AvailableModifiers, model);
}
}
}
+5
View File
@@ -2,6 +2,10 @@ using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YachtDice.Modifiers;
namespace YachtDice.Shop
{
public sealed class ShopItemView : MonoBehaviour
{
@@ -85,3 +89,4 @@ public sealed class ShopItemView : MonoBehaviour
};
}
}
}
+7
View File
@@ -1,5 +1,11 @@
using System;
using System.Collections.Generic;
using YachtDice.Economy;
using YachtDice.Inventory;
using YachtDice.Modifiers;
namespace YachtDice.Shop
{
public sealed class ShopModel
{
@@ -76,3 +82,4 @@ public enum ShopItemState
Owned,
RepurchaseAvailable
}
}
+5
View File
@@ -3,6 +3,10 @@ using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YachtDice.Modifiers;
namespace YachtDice.Shop
{
public sealed class ShopView : MonoBehaviour
{
@@ -75,3 +79,4 @@ public sealed class ShopView : MonoBehaviour
private void HandleBuy(ModifierData data) => OnBuyClicked?.Invoke(data);
}
}
@@ -1,5 +1,10 @@
using NUnit.Framework;
using UnityEngine;
using YachtDice.Inventory;
using YachtDice.Modifiers;
namespace YachtDice.Tests
{
public sealed class InventoryModelTests
{
@@ -153,3 +158,4 @@ public sealed class InventoryModelTests
Assert.IsTrue(fired);
}
}
}
@@ -1,5 +1,10 @@
using NUnit.Framework;
using UnityEngine;
using YachtDice.Modifiers;
using YachtDice.Scoring;
namespace YachtDice.Tests
{
public sealed class ModifierEffectTests
{
@@ -87,3 +92,4 @@ public sealed class ModifierEffectTests
Assert.AreEqual(1.5f, result.Multiplier, 0.001f);
}
}
}
@@ -1,6 +1,11 @@
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using YachtDice.Modifiers;
using YachtDice.Scoring;
namespace YachtDice.Tests
{
public sealed class ModifierPipelineTests
{
@@ -134,3 +139,4 @@ public sealed class ModifierPipelineTests
Assert.AreEqual(10, result.FinalScore);
}
}
}
@@ -1,6 +1,10 @@
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using YachtDice.Persistence;
namespace YachtDice.Tests
{
public sealed class SaveSystemTests
{
@@ -86,3 +90,4 @@ public sealed class SaveSystemTests
Assert.AreEqual(0, loaded.Currency);
}
}
}
@@ -1,6 +1,11 @@
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using YachtDice.Scoring;
using YachtDice.Modifiers;
namespace YachtDice.Tests
{
public sealed class ScoringSystemTests
{
@@ -96,3 +101,4 @@ public sealed class ScoringSystemTests
Assert.AreEqual(50, result.FinalScore);
}
}
}
@@ -1,5 +1,12 @@
using NUnit.Framework;
using UnityEngine;
using YachtDice.Economy;
using YachtDice.Inventory;
using YachtDice.Shop;
using YachtDice.Modifiers;
namespace YachtDice.Tests
{
public sealed class ShopModelTests
{
@@ -128,3 +135,4 @@ public sealed class ShopModelTests
Assert.AreEqual(ShopItemState.Owned, shop.GetItemState(mod));
}
}
}
@@ -1,6 +1,6 @@
{
"name": "YachtDice.Tests.Editor",
"rootNamespace": "",
"rootNamespace": "YachtDice.Tests",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
+5
View File
@@ -2,6 +2,10 @@ using System;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using YachtDice.Scoring;
namespace YachtDice.UI
{
public sealed class CategoryRowView : MonoBehaviour
{
@@ -87,3 +91,4 @@ public sealed class CategoryRowView : MonoBehaviour
selectButton.onClick.RemoveListener(HandleClick);
}
}
}
+4
View File
@@ -3,6 +3,9 @@ using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace YachtDice.UI
{
public sealed class DicePanelView : MonoBehaviour
{
[Header("Dice Display")]
@@ -99,3 +102,4 @@ public sealed class DicePanelView : MonoBehaviour
rollButton.onClick.RemoveAllListeners();
}
}
}
+11
View File
@@ -1,6 +1,16 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using YachtDice.Game;
using YachtDice.Scoring;
using YachtDice.Economy;
using YachtDice.Shop;
using YachtDice.Inventory;
using YachtDice.Persistence;
using YachtDice.Modifiers;
namespace YachtDice.UI
{
public sealed class GameController : MonoBehaviour
{
@@ -345,3 +355,4 @@ public sealed class GameController : MonoBehaviour
return total;
}
}
}
+4
View File
@@ -3,6 +3,9 @@ using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace YachtDice.UI
{
public sealed class GameInfoView : MonoBehaviour
{
[Header("Turn Info")]
@@ -67,3 +70,4 @@ public sealed class GameInfoView : MonoBehaviour
inventoryButton.onClick.RemoveAllListeners();
}
}
}
+5
View File
@@ -2,6 +2,10 @@ using System;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using YachtDice.Scoring;
namespace YachtDice.UI
{
public sealed class ScoreCardView : MonoBehaviour
{
@@ -107,3 +111,4 @@ public sealed class ScoreCardView : MonoBehaviour
categoryRows[i].OnCategorySelected -= HandleCategorySelected;
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "YachtDice.Runtime",
"rootNamespace": "",
"rootNamespace": "YachtDice",
"references": [
"Unity.TextMeshPro",
"Unity.InputSystem",