A fun and engaging Unity-based puzzle game where players assemble sandwiches by dragging ingredients across a grid. The goal is to collect all ingredients and arrange them in the correct order to create a complete sandwich.
Sandwich Puzzle Game is a 2D grid-based puzzle game that challenges players to think strategically about ingredient placement and movement. Players must drag ingredients from one cell to another, ensuring they end up with a properly structured sandwich (bread on top and bottom) containing all the required ingredients.
- Grid-based Movement: Drag ingredients between adjacent cells on a customizable grid
- Ingredient Collection: Gather various sandwich ingredients (bread, cheese, ham, bacon, etc.)
- Sandwich Assembly: Arrange ingredients to create a complete sandwich structure
- Win Conditions: Complete the sandwich with bread on top and bottom, containing all ingredients
- Adjacent Movement: Ingredients can only move to neighboring cells
- Stacking System: Multiple ingredients can be stacked in a single cell
- Flipping Animation: Smooth 3D flipping animations when moving ingredients
- Audio Feedback: Sound effects for ingredient movements and win conditions
- Difficulty Levels: Easy and Hard modes with different grid sizes and ingredient counts
- Random Generation: Procedurally generated levels with connected ingredient paths
- Level Configuration: ScriptableObject-based level design system
- Reset Functionality: Reset current level or generate new levels
- Score System: Time-based scoring with faster completion yielding higher scores
- Camera Control: Dynamic camera focusing on winning sandwich
- UI Panels: In-game and win screen interfaces
- Button Controls: Reset, generate new level, and next level options
- Clean Code Structure: Well-organized scripts with comprehensive commenting
- Modular Design: Separated concerns for grid management, game state, and input handling
- ScriptableObjects: Data-driven design for ingredients and level configuration
- Event System: Decoupled communication between game systems
- Cinemachine: Professional camera system for dynamic camera control
- DOTween: Smooth animations and transitions
- TextMesh Pro: High-quality text rendering
- Audio System: Integrated sound effects and music
- Unity 2022.3 LTS or later
- Basic knowledge of Unity Editor
-
Clone the Repository
git clone https://github.com/MahmoudAbousetta6/Sandwich-Game.git cd Sandwich-Game -
Open in Unity
- Launch Unity Hub
- Click "Open" and select the cloned project folder
- Wait for Unity to import all assets
-
Open the Main Scene
- Navigate to
Assets/Scenes/Main Scene.unity - Double-click to open the scene
- Navigate to
-
Run the Game
- Click the Play button in Unity Editor
- Or build the project for your target platform
- Mouse Click and Drag: Click on a cell with ingredients and drag to an adjacent empty cell
- Valid Moves: Only adjacent cells (horizontally or vertically) are valid destinations
- Ingredient Stacking: Multiple ingredients can be moved together
- Objective: Collect all ingredients and arrange them as a complete sandwich
- Sandwich Structure: Must have bread as the bottom and top layers
- Movement: Ingredients can only move to adjacent cells
- Completion: All ingredients must be in a single cell with proper sandwich structure
- Time-based: Faster completion yields higher scores
- Formula:
Score = (1 / completion_time) * 100 + 10 - Display: Score shown on win screen with 2 decimal places
Assets/
├── Scripts/
│ ├── Game/
│ │ ├── GameManager.cs # Main game controller
│ │ └── LevelConfig.cs # Level configuration system
│ ├── Cell/
│ │ ├── CellInfo.cs # Grid cell positioning
│ │ └── CellPrefabHandler.cs # Individual cell behavior
│ └── Ingredients/
│ ├── IngredientHandler.cs # Ingredient behavior and animations
│ └── IngredientsData.cs # Ingredient data structure
├── Prefabs/
│ ├── Cell Prefab.prefab # Grid cell template
│ ├── Ingredients/ # Ingredient prefabs
│ └── Tiles/ # Tile prefabs
├── Scenes/
│ └── Main Scene.unity # Main game scene
├── Data/
│ ├── SO/ # ScriptableObject assets
│ └── Audio/ # Music and sound effects
└── Art/
├── Models/ # 3D models for ingredients and tiles
├── Materials/ # Materials and shaders
└── Textures/ # Texture assets
- Create a 3D model for the new ingredient
- Add it to
Assets/Art/Models/ingredients/ - Create a prefab in
Assets/Prefabs/Ingredients/ - Add the prefab to the
IngredientsDataScriptableObject - Set the
isBreadflag appropriately
- Open the
LevelConfigScriptableObject - Adjust grid dimensions (
GridX,GridZ) - Modify spacing between cells
- Change difficulty level (Easy/Hard)
- Modify
flippingSpeedinCellPrefabHandler - Adjust animation curves in
IngredientHandler.FlipTo() - Update audio timing in
CellPrefabHandler.TranslateFrom()
Game doesn't start
- Ensure all required prefabs are assigned in the GameManager
- Check that the LevelConfig ScriptableObject is properly configured
Ingredients not moving
- Verify that cells have proper colliders
- Check that the camera is set up correctly for raycasting
Audio not playing
- Ensure AudioSource components are attached to cell prefabs
- Check audio file imports and settings
Performance issues
- Reduce grid size for better performance
- Optimize ingredient models and textures
- Consider using object pooling for large grids
- Unity Technologies for the amazing game engine
- DOTween for smooth animations
- Cinemachine for professional camera control
- TextMesh Pro for high-quality text rendering
If you encounter any issues or have questions:
- Create an issue in the GitHub repository
- Check the troubleshooting section above
- Review the code comments for implementation details
Enjoy building delicious sandwiches! 🥪✨
