How levi0309/unity- works
The project is a Unity-based, turn-based, card-driven roguelike game (类杀戮尖塔回合制卡牌肉鸽游戏) similar in design to “Slay the Spire.” The file tree highly emphasizes Unity’s folder structure with extensive organization of assets, scenes, scripts, and external libraries (for example, DOTween, Spine, and TextMesh Pro). There is also a clear emphasis on card data, character logic, turn-based management, UI, and event handling.
Main Components
• Game Managers: Central control modules are visible under Assets/Scripts/Manager. These include modules like GameManager, CardManager, SceneLoadManager, TurnBaseManager, UIManager, and CardLayoutManager. They orchestrate the game flow, transitions, and core logic.
• Card System: Organize components like CardDataSO, CardLibrarySO, Card logic (in Assets/Scripts/Card/Logic), and card effects (Assets/Scripts/CardEffect). This represents the core deck-building mechanics.
• Characters and Enemies: The folders under Assets/Scripts/Character (Player.cs, Enemy.cs, BOSS.cs) show dedicated logic for various characters with animations, event-based interactions, and controllers.
• Room/Map and Turn Modules: Assets/Scripts/Room and Assets/GameData/RoomData define the “dungeon” or map generation aspects, which together with turn-based logic (Assets/Scripts/Manager/TurnBaseManager) control the game’s progression.
• Event System: A clearly modular event system is present in Assets/Scripts/Event with Data_SO, Listener classes, and editors. This system manages game events (like character death or new room loading) using the observer pattern.
• UI and Visual Effects: The UI components (under Assets/UI and Assets/Scripts/UI) and the VFX modules (Assets/Scripts/VFX) control the game interface and animations. Also note integration with TextMesh Pro and Unity’s UI Toolkit.
• External Tools and Middleware: Integration of external libraries such as DOTween (in Assets/Plugins/Demigiant/DOTween) for tweening animations and Spine (under Assets/Spine) for skeletal animation is critical to the project’s visual presentation.
Relationships and Interactions
• The GameManager sits at the heart of the architecture, coordinating gameplay by invoking calls to the CardManager (for drawing and managing cards) and TurnBaseManager (for controlling game phases).
• SceneLoadManager transitions between different game scenes (Menu, Map, Combat, etc.), while UIManager renders panels like game menus, gameplay HUD, and results screens.
• The Card System interacts with both the player’s strategic choices and the event system. Card effects (such as DamageEffect or HealEffect) trigger events that are captured by the Event System to update character states.
• The Room/Map logic manages level generation (using MapGenerator and Room logic) and ties into the turn-based cycle to set up combat and exploration scenarios.
• The Event System is integrated throughout – managers, UI components, and game logic all communicate type-safe events ensuring synchronized state changes.
Architectural Patterns
• MVC / Component-based Design: The separation between visual assets (UI/Art/Scenes), game logic (Scripts/), and configuration (GameData, ScriptableObjects) is clear. This separation is influenced by Unity’s component-based design.
• Observer Pattern: The event system uses this pattern to decouple event producers and consumers.
• ScriptableObject Pattern: Extensive use of SO files in data (e.g., CardDataSO, RoomData_SO, various Event SOs) encapsulates configuration and shared assets.
• Manager / Director Pattern: Managers orchestrate overall game flow across different aspects (UI, scenes, turns, deck-handling).
Including Relevant Technologies, Frameworks, and Libraries
• Unity Engine: Core engine with its scene management and component system.
• DOTween: For tweening and smooth animations.
• Spine: For advanced skeletal animations (used in character and enemy animations).
• TextMesh Pro and UI Toolkit: For rendering modern UI elements.
• Various Unity packages (e.g., Addressables, Shader Graph) used for asset tracking and rendering.
• Use Clear Labels: Each node should be titled exactly as the component (for example, GameManager, CardManager, TurnBaseManager, etc.).
– GameManager → CardManager, TurnBaseManager, SceneLoadManager
– CardManager → Event System (when a card is played, triggers relevant events)
– Event System → UIManager and Character modules (for state updates)
– UI interactions → GameManager (to signal player input)
– Scene transitions from SceneLoadManager → Various Scenes
– For instance, blue blocks for Managers; green blocks for data/models (ScriptableObject based configuration); orange blocks for UI components; and yellow blocks for external tool integrations.
• Notes: Annotate special patterns (e.g., “Observer Pattern for Event Handling” and “ScriptableObject based configuration”) where needed.
• Surround it with distinct modules for Card System, Character/Enemy System, Room/Map Generation, UI/VFX, and the Event System.
• Supporting layers for configuration and external tools.