A Unity-based block puzzle game featuring an intelligent block suggestion system and modular architecture.
BlockPuzzle is an 8×8 grid puzzle game where player drags and drops blocks to clear rows and columns. The game features a unique algorithm that intelligently suggests blocks based on the current field state, making each playthrough strategic and engaging.
- Intelligent Block Selection - Smart algorithm suggests optimal blocks for the current field state
- Customizable Themes - Multiple color themes using ScriptableObjects
- Interactive Tutorial - Step-by-step guidance for new players
- iOS Haptic Feedback - Native haptics integration written in Objective-C
- Automatic Save System - Progress saved after every move
- Adaptive Camera - Automatically fits all screen resolutions with safe area support
- Custom Editor Tools - Built-in tools for creating blocks and tutorials
- Audio Manager - Centralized sound effects system
- Unity 6000.2.7f2 (download from Unity Hub)
-
Clone the repository:
git clone https://github.com/BabkenInants/BlockPuzzle.git
-
Open Unity Hub and click Add → select the cloned folder
-
Open the project with Unity 6000.2.7f2
-
Load the game scene:
Assets/Scenes/EndlessGame.unity -
Press Play
In Unity Editor: Assets → Open C# Project to launch your IDE
The game uses a sophisticated algorithm to suggest blocks that fit well with the current field state:
- Field Simulation - Creates a temporary copy of the field for testing
- Block Evaluation - Tests each block in all possible positions
- Position Scoring - Rates each position based on:
- Number of cells the block occupies
- Connectivity to adjacent free cells
- Potential for clearing rows/columns
- Intelligent Selection - Chooses blocks that maximize field utility
Key Functions:
GenerateNextBlocks()- Main entry point for block generationFindBlockForField()- Selects best block from available optionsGetBestPositionForBlock()- Evaluates all possible placementsFieldUtils.RateField()- Scoring function for field states
Scoring Formula:
Score = Σ(cellGrade²) × clearMultiplier
where cellGrade = 0 (occupied) or 1 + adjacentFreeCells (free)
- Duplicate an existing block prefab in
Assets/Prefabs/Blocks - Double-click the prefab to edit
- Arrange cells in your desired pattern
- Ensure BoxCollider2D is square (minimum 2×2) and fits the block perfectly
- Update the
cellsarray in the Block script - Adjust Matrix SizeX and SizeY
- Draw your block pattern (green = occupied, gray = empty)
- Add the block to the Settings ScriptableObject
- Duplicate a theme in
Assets/Themesor create new: Right-click → Create → NewTheme - Configure your colors
- Add the theme to Theme Manager (in Managers on the scene) in the
themesarray
using Themes;
public class MyComponent : MonoBehaviour, IThemeReceiver
{
public void ReceiveThemeOnGameStart(Theme theme)
{
// Apply theme without animations
// Called once when game loads
}
public void ReceiveTheme(Theme theme)
{
// Apply theme with animations
// Called when theme changes during gameplay
}
}Tip: Use ThemeTools for color animation coroutines.
- Duplicate an existing example in
Assets/Tutorialsor create new: Right-click → Create → Tutorial Example - Draw the field (leave space for one block)
- Assign a Block Prefab from
Assets/Prefabs/Blocks - Duplicate that prefab into
Assets/Tutorials/TutorialBlocks - Remove BoxCollider2D and Block components, add TutorialBlock instead
- Open the prefab and move cells so the pivot is at the top-left corner
Examples:

- Assign the modified prefab to Preview Block Prefab field
- Click Show and set Target Pos (row, column) to the pivot cell position
- Add the example to Managers/Tutorial Manager in the scene
GameEvents.RaisePlayHaptics(HapticManager.HapticType); //Plays haptics of desired HapticType
GameEvents.RaisePlayHapticsInARow(HapticManager.HapticType); //Plays haptics of desired HapticType for n timesHaptic Types:
- Light
- Medium
- Heavy
Haptic Types Used:
- Block placement (no clear): Light
- Block placement (with clear): Heavy × lines cleared
- UI buttons: Light
using Saves;
public class MyComponent : MonoBehaviour, ISavable
{
public void Save(SaveData saveData)
{
// Save your data
}
public void Load(SaveData saveData)
{
// Load your data
}
}Note: Only use serializable types in SaveData (primitives, strings, arrays, serializable structs). Tip: Use SerializableColor for saving colors
To preview:
- Enable the SafeZonePreview object in the scene
- Adjust Screen Width and Height in the Settings ScriptableObject → Camera Section
- Change Game window resolution or enter Play mode to see camera updates
- Disable SafeZonePreview when done
RaisePlaySfx(clip);Note: For UI actions that trigger scene loads, wait for clip.length + 0.1f before loading to ensure sound completes. I had audio files but deleted them because I didn't have a license for all of them. Anyway there are fields for basic sound effects in settings ScriptableObject.
- Game Development: Reference implementation for block puzzle mechanics
- Algorithm Study: Example of intelligent content suggestion
- Unity Learning: Demonstrates editor tools, ScriptableObjects, and interfaces
- Mobile Development: Shows iOS native plugin integration
Issues and pull requests are welcome! Please open an issue to discuss major changes.
Please open an issue.