NewManager - Game Manager
What is it?
NewManager is the main brain of the game. It:
- 🎮 Starts the entire game
- 🔄 Coordinates all components
- 📊 Tracks game state
- 🎯 Responds to player actions
Analogy: Like an orchestra conductor - doesn't play itself, but makes everyone play together.
Where to find it?
In Scene Hierarchy → NewManager (GameObject)
Inspector Settings
Basic References
┌─ NewManager ────────────────────┐
│ Matrix: [NewMatrix] │ ← Board
│ Shape Spawner: [NewShapeSpawner] │ ← Block generator
│ Score Manager: [NewScoreManager] │ ← Points
│ Brain: [NewBrain] │ ← AI difficulty
│ Draggable Prefab: [Prefab] │ ← Block template
│ Shape Data Assets: [List] │ ← Available shapes
└──────────────────────────────────┘
What do fields mean?
| Field | What is it? | Why? |
|---|---|---|
| Matrix | Reference to board | Manager needs to know where the board is |
| Shape Spawner | Block generator | Creates new blocks on screen |
| Score Manager | Scoring system | Counts points, combos, highscore |
| Brain | Artificial intelligence | Selects block difficulty |
| Draggable Prefab | Block prefab | Template for creating new blocks |
| Shape Data Assets | Shape list | All possible blocks in the game |
How does it work?
Game Start
1. NewManager.Awake()
↓
2. Initialize all components
↓
3. NewManager.Start()
↓
4. Generate first 3 blocks
↓
5. Wait for player input
Game Loop
Player places block
↓
NewManager.OnShapePlaced()
↓
Check if lines are full
↓
Clear full lines (if any)
↓
Update score
↓
Check if all 3 blocks used
↓ Yes
Generate new 3 blocks
↓
Check if any block can be placed
↓ No
GAME OVER
Key Methods (for programmers)
If you want to modify code, these are the most important:
OnShapePlaced(shape)
Called when player places a block on board.
// What it does:
1. Tells Matrix to add the shape
2. Checks for full lines
3. Clears lines if found
4. Updates score
5. Checks for game over
GenerateNewShapes()
Creates 3 new random blocks.
// How it works:
1. Asks Brain for 3 shapes (based on difficulty)
2. Tells ShapeSpawner to create them
3. Displays them on screen
CheckGameOver()
Checks if game should end.
// Checks if:
- Any of 3 blocks can fit anywhere on board
- If none fit → Game Over
- If at least one fits → Game continues
Events You Can Listen To
NewManager sends events that other scripts can listen to:
| Event | When | Use for |
|---|---|---|
OnGameStart |
Game starts | Reset UI, animations |
OnShapePlaced |
Block placed | Sound effects |
OnLinesCleared |
Lines cleared | Visual effects |
OnScoreUpdated |
Score changes | Update UI |
OnGameOver |
Game ends | Show popup |
Common Modifications
Change number of blocks per turn
Default is 3. To change:
// In NewManager.cs find:
private const int SHAPES_PER_TURN = 3;
// Change to whatever you want:
private const int SHAPES_PER_TURN = 5;
Change when game is over
Default: game over when NO blocks fit.
Want game over when only 1 block fits?
// In CheckGameOver() change:
if (CountPlayable(currentShapes) >= 1) // was: >= 1
return false; // game continues
// To:
if (CountPlayable(currentShapes) >= 2) // now requires 2
return false;
Singleton Pattern
NewManager uses Singleton pattern - only ONE instance exists:
This means you can access it from anywhere:
Important
Never create multiple NewManager instances! Always use Instance.
What's Next?
Learn about components NewManager controls:
- 🎲 Board (Matrix) - how the board works
- 🧩 Shapes - block system
- 🧠 AI & Difficulty - how difficulty adapts
For Beginners
You don't need to understand all the code! Most settings can be changed in Inspector without touching scripts.