A feature-rich, single-player mini-clone of Clash Royale, developed in Unity. This project serves as a comprehensive case study in robust game architecture, clean code principles, and the practical application of design patterns. It was developed during a one-month internship at Zagrava Games.
- 🎮 Core Gameplay Features
- 🏗️ Architectural Deep Dive & Design Patterns
- 📦 Building the Project
- 👨💻 About the Authors
- 📄 License
- 💧 Mana Management: A dynamic mana regeneration system that dictates the pace of gameplay.
- 🃏 Card and Deck System: Draw, play, and recycle cards from a deck to summon units onto the battlefield.
- ⚔️ Unit Spawning & AI: Place units that automatically navigate towards the nearest enemy or tower. The game features a simple but effective AI opponent that strategically plays its own cards.
- 🌐 Grid-Based Battlefield & Pathfinding: All interactions, from unit placement to their intelligent movement across the map, are managed on a robust grid system utilizing efficient algorithms for pathfinding.
- 🤖 Diverse Unit Types: The architecture supports a wide variety of units with unique stats and behaviors (e.g., melee, ranged, ground, flying, static structures).
- ✨ Dynamic Animations: Units come to life with animations that respond to their movement direction, attacks, and idle states.
This project was built with a strong emphasis on clean, modular, and extensible code, heavily leveraging Unity's component-based architecture and Scriptable Objects for data management. Here are the key architectural patterns and decisions that power the game.
Manages the lifecycle and behavior of all units in a clean, organized way, making it easy to add or modify behaviors.
- Core:
UnitStateMachine - States:
IdleState,MoveState,AttackState
Dynamically attaches behaviors (like movement and attack types) to units at runtime. This promotes loose coupling and allows for creating new unit variations without touching the core Unit class.
- Factories:
MovementFactory,AttackFactory - Products:
IMovementStrategy:GroundMovement,FlyingMovement,StaticMovementIAttackStrategy:MeleeAttackStrategy,RangedAttackStrategy
Defines a family of interchangeable algorithms and encapsulates each one. This is used extensively to handle variations in core mechanics.
- Movement Strategies (
IMovementStrategy): Governs how different units navigate the world.GroundMovement: Critically, this strategy leverages the A* pathfinding algorithm within thePathfinderto intelligently navigate the grid, avoiding obstacles and finding optimal routes to targets.FlyingMovement: Uses direct linear interpolation, unconstrained by the ground grid.StaticMovement: Does not move, used for structures like towers.
- Attack Strategies (
IAttackStrategy): Abstracts the method of dealing damage.MeleeAttackStrategyRangedAttackStrategy
- Grid Region Strategies (
RegionStrategy): These Scriptable Object assets define various shapes (e.g.,CircleStrategy,RectangleStrategy) used for placement validation and other area-of-effect calculations on the grid.
Provides simplified, purpose-driven interfaces to a more complex subsystem. This makes the ManaManager easier and safer to use from different parts of the codebase.
- Facades:
ManaReadOnlyFacade(IManaReadOnly),ManaSpenderFacade(IManaSpender) - Complex Subsystem:
ManaManager
To promote decoupling and maintainability, the systems communicate primarily through C# events and centralized services. Components subscribe to events they care about instead of holding direct, rigid references to each other.
- Centralized Services:
CardPlayabilityService: Manages card usability based on mana, notifying UI via events.TargetRegistry: A static registry of all targetable entities (ITargetable) for efficient target acquisition.ParticleManager: Handles spawning and recycling of visual effects.GridManager&Pathfinder: The central hub for all grid queries and efficient pathfinding algorithms, providing optimal paths for ground units.
- Key Events:
OnCardDropped,OnManaChanged,OnHealthChanged,OnDied,OnDirectionChanged, and many more.
The project uses Unity's Animator component and Animation events to create responsive and dynamic character movements.
UnitAnimator: A dedicated component that controls unit animations based on their state (moving, attacking, idle) and direction.WaitBeforeLoopBehaviour: A custom StateMachineBehaviour used in animations to introduce delays before looping, often tied to attack speed.
Crucial game data is managed through Scriptable Objects, allowing for easy iteration and configuration without modifying code.
CardData: Defines properties for each playable card.UnitConfig: Configures all stats, prefabs, and strategy types for each unit.WeaponBase(and its derivationsMeleeWeaponData,RangedWeaponData): Defines weapon characteristics.GridSettingsData,ObstacleData,PlacementData: Configures the battlefield grid, obstacles, and valid placement zones.
If you want to create a standalone executable version of the game, follow these steps:
-
Open Build Settings:
- In the Unity Editor, navigate to the top menu bar and select
File>Build Settings....
- In the Unity Editor, navigate to the top menu bar and select
-
Configure Build Settings:
- Target Platform: Select your desired platform (e.g.,
Android, IOS). - Scenes In Build: Ensure that the main game scene is included. If the list is empty, click the "Add Open Scenes" button to add
Assets/Scenes/GameScene.unity. Make sure the checkbox next to it is ticked.
- Target Platform: Select your desired platform (e.g.,
-
Start the Build:
- Click the "Build" button. Unity will open a file dialog asking where you want to save the build.
-
Choose a Location:
- Pro Tip: It's good practice to create a new folder named
BuildsorReleasesin your project's root directory (and add it to your.gitignorefile). Save your build inside that folder.
- Pro Tip: It's good practice to create a new folder named
-
Run the Executable:
- Once the build is complete, navigate to the folder you selected. You will find an executable file and a corresponding
_Datafolder. - Run the executable file to play the game outside of the Unity Editor.
- Once the build is complete, navigate to the folder you selected. You will find an executable file and a corresponding
This project was created by Vladyslav Dzhuha and Vladyslav Yevkov.
Two passionate programmers and Computer Science students at the Czestochowa University of Technology😄.
This project is licensed under the MIT License. See the LICENSE file for details.
Also, big thanks to smlbiobot for the assets! Here's the repo

