This document provides an overview of the C# codebase structure for the Fighter Game.
The architecture enforces a clear separation of concerns between:
- Game Logic - Core gameplay mechanics, state management, and business logic.
- Unity Behaviors - MonoBehaviour components that connect game logic to Unity's rendering and input systems.
This separation allows for:
- Better testability of game logic independent of Unity.
- Cleaner code organization and maintenance.
- Potential reuse of game logic across different implementations, for example in a hypothetical backend.
The heart of the game is in the custom package Packages/com.terallite.gamelogic/Runtime/:
- Start with World.cs - The central orchestrator that manages the game state, entities, and win/loss conditions
- Examine the entity infrastructure in Entity.cs - The abstract base class for all game objects
- See how collisions work in CollisionSystem.cs - The system for detecting and resolving entity interactions
- Check out Fighter.cs and Laser.cs - Concrete implementations of entities that make up the gameplay
Then examine how the game logic is connected to Unity in Assets/Scripts/:
- GameManager.cs - The main MonoBehaviour that bridges game logic to Unity
- EntityView.cs - Renders game entities and syncs their state with Unity objects
- UserInteractionManager.cs - Handles player input via a state machine pattern
The game logic layer contains the core mechanics and is organized into:
- World - Orchestrates the updates and spawning of Entities.
- Entity System - Provides a unified interface for all objects in the game world, including Fighters and projectiles.
- Collision System - Implements simple bounding-box collision between game entities.
Unity MonoBehaviours serve as the view/controller layer:
- Connect game logic to Unity's rendering pipeline.
- Handle Unity-specific lifecycle events.
- Process input through Unity's Input System.
The codebase implements several design patterns:
- Model-View-Controller (MVC) - Separating game logic (model) from Unity behaviors (view/controller).
- State Pattern - For game flow management.
- Observer Pattern - For event handling and communication between systems.
- Open
FighterGame.slnin your preferred IDE. - Explore the
Assetsfolder for Unity MonoBehaviours. - The
com.terallite.gamelogicproject contains the core game systems.
- Further decoupling of systems for better modularity.
- More data-driven design for game entity properties.
This is a personal educational project subject to the terms in the LICENSE file. Personal use is permitted, but redistribution is prohibited. All original content is copyrighted by Terallite Kaihatsu, with derivative works used under fair use principles.