Technisch Ontwerp - j5x/PvB2025 GitHub Wiki
Technical Design for Match-3 Fighting Game
This document outlines the technical implementation of the game, including algorithms, data structures, and system architecture.
Architecture Overview
Main Systems
The game is built on Unity (C#) using a modular, component-based structure:
1. Game Manager
- Controls the main game loop.
- Handles phase switching between Match-3 and Fighting.
flowchart TD
A[Start Game] --> B[Match-3 Phase]
B --> C{All moves collected?}
C -->|No| B
C -->|Yes| D[Fighting Phase]
D --> E{Enemy defeated?}
E -->|No| D
E -->|Yes| F[Check Rounds]
F -->|More rounds| B
F -->|Last round done| G[End Game]
2. Match-3 System
- Manages tile spawning, matching, clearing, and falling.
- Tiles stored as a 2D GameObject array.
- Smooth gravity movement using A* pathfinding logic.
graph LR
subgraph Match-3
GMGR[GridManager]
TSPN[TileSpawner]
MDTC[MatchDetector]
TCLR[TileClearer]
GRTL[GravityApplier]
end
GMGR --> TSPN
TSPN --> MDTC
MDTC --> TCLR
TCLR --> GRTL
GRTL --> GMGR
3. Fighting System
- Turn-based combat using collected moves.
- Enemy AI uses a predefined array of attacks, picked randomly at intervals.
- Behavior Tree architecture for logic.
- Special Attack system added (unlocked via 30 green tiles).
- Animation of splash art triggered upon activation.
graph LR
subgraph Fighting
PCHAR[Player]
ECHAR[Enemy]
ATTC[AttackComponent]
TMGR[TurnManager]
BTREE[BehaviorTree]
SPBAR[SpecialBarController]
end
PCHAR --> ATTC
ECHAR --> ATTC
TMGR --> ATTC
BTREE --> TMGR
PCHAR --> TMGR
PCHAR --> SPBAR
SPBAR --> ATTC
4. UI/UX System
- Manages grid interaction, battle transitions, player/enemy health bars.
- Custom player health bar, shared enemy health bar.
- Uses Unity Canvas with SafeArea handling for resolution scaling.
flowchart TD
A[Canvas Root]
A --> B[SafeAreaHandler]
B --> C[Dynamic UI Layouts]
5. Frame Rate Management
FrameRateHandlerlimits or locks FPS to avoid lag across devices.- Ensures consistent gameplay on both high-end and low-end hardware.
flowchart TD
A[Start Game] --> B[Check Device Capabilities]
B --> C[Set Target Frame Rate]
C --> D[Apply vsync / frame limiter]
Match Detection Logic
- Iterates the 2D grid for horizontal and vertical matches (≥3).
- Stores matches, clears tiles, applies gravity, and refills grid.
flowchart TD
A[Start Detection]
B[For each cell]
C{Horizontal run ≥ 3?}
D{Vertical run ≥ 3?}
E[Mark matched tiles]
F[Clear marked tiles]
G[Apply gravity]
H[Refill empty cells]
I[Done]
A --> B
B --> C
C -->|Yes| E
C -->|No| D
D -->|Yes| E
D -->|No| B
E --> B
B -->|all done| F --> G --> H --> I
Additional Notes
- All core systems are component-based (GameManager, EnemySpawner, RoundManager, FrameRateHandler, etc.).
- Visual FX managed through
VfxComponent. - Levels loaded via
LevelManager, progress stored per session. - Tested across multiple resolutions using Safe Area UI implementation.