Skip to content

Time System

Manav edited this page Aug 28, 2023 · 51 revisions

The time system serves as an integral part of Gardens of the Galaxy, providing dynamic updates and information to other dependent classes. Since this is a farming game, the core goals revolve around time as you build and expand your farm over time while growing plants that take time to harvest. Hence, it is essential that an intuitive yet easy-to-understand implementation of the time system is required so that other classes can interact easily with the time system and that valuable information is provided to these dependent classes.

This implementation of the time system provides working in-game time, where each day in the game lasts 12 minutes in real time. A visual implementation of the in-game time is also present at the top left of the screen, which has an indicator (sun or moon) as well as the current hour of the day (in 12-hour time). The time will dynamically update on the UI, and the indicator will update to match that time as well. For example, as the day turns into night, the sun will slowly set and the moon will eventually rise. This ensures that the player will always be informed of the current time through text and images, providing a much more visually appealing experience for the player. The implementation also provides a pause and unpause function as well as a function to set the time to aid in debugging and testing to improve workflow.

Display

UI Design

Implementation

Inspirations

(jsut atlk about pixel art theme or something lmao)

Functionality

The functionality is centred in GameTime, GameTimeDisplay and TimeController within services

Implementation

The TimeController class serves as the control centre for all things that are dependent on the time. It is initialised in the constructor for GameTime and is stored within the current instance of GameTime, so when a new GameTime service is created at the start of a new game, a TimeController service will be created automatically. This ensures that each new game will have its own TimeController.

It follows an observer design pattern, where TimeController is the observable sending updates to the observers that are registered within the class. The class contains a private variable List<Entity> entities, which can be any form of entity such as a plant and can be registered or removed from the TimeController class.

#Future Development

Clone this wiki locally