How srslykail/turn-the-tides works
Main Components
• Assets & Scenes: Visual and audio assets, scenes (e.g., LowerMainland, TestingGrounds) that form the visual game world.
• Code Modules: Organized into functional areas via subdirectories under Assets/Code/Scripts. Notable modules include:
– Camera: Contains the CameraController and its assembly definition.
– ElevationAndLandCover: Includes components for API polling (both Python and C#), JSON parsing, and handling external data.
– Terrain: Contains definitions of various terrain types as well as tiles (e.g., UrbanTile, Lake, Forest, etc.).
– Managers: Contains GridManager and WorldManager used to control game state, grid creation, etc.
– UI: Contains UI scripts and prefabs (GameUI, NextTurnButton, PollutionMeter, WaterLevelIndicator) to drive user interactions.
– Helper: Utility scripts supporting common functionality.
• Resources & Data: JSON map data (lowerMainland.json, test maps, land use and elevation data) and prefabs that combine assets with logic.
• External Assets & Plugins: KenneyHexKit for models/textures and Newtonsoft.Json as an external dependency.
• Tests: Organized into EditMode and PlayMode tests to ensure the integrity of core functionalities in various modules.
• Project Settings: Unity project settings (audio, graphics, input, URP, etc.) which affect the overall runtime behavior.
Relationships & Interactions
• Game World Layer:
– Scenes in Assets/Level/Scenes serve as the high-level containers that bring together environments, managers, and UI.
• Domain/Logic Layer:
– Managers (GridManager and WorldManager) largely coordinate the state of the game world. They interact with Terrain components to create and update the grid and tiles.
– Terrain scripts define the different types of landforms; these are used by managers to assemble the game map.
– The ElevationAndLandCover components interact with external APIs (see APIPinger scripts in both Python and C#) to fetch and process environmental data, feeding into the terrain and landscape simulation.
• Presentation/Interaction Layer:
– The UI modules and camera scripts manage how the player sees and interacts with the world, often by communicating with the managers.
• Data Access & Resource Layer:
– JSON files in Assets/Resources/Maps and land use data provide initial configuration and state which are loaded by game managers or during scene initialization.
• Testing & Quality Assurance:
– PlayMode and EditMode tests help validate interactions among these components.
Architectural Patterns
• Modularity: The use of assembly definitions (.asmdef) in different subdirectories suggests a modular architecture, enabling encapsulation and separation of concerns.
• MVC-ish Flow: Though not strictly MVC, you have distinct layers where:
– “Model” is represented by map data, scriptable objects (like MapData.cs), and terrain definitions.
– “View” is essentially the scenes, UI, and the camera rendering.
– “Controller” are the managers that tie everything together.
• Data Flow: External API calls in ElevationAndLandCover fetch and parse JSON data (using Newtonsoft.Json) that is then transmitted to managers and terrain modules.