Skip to content

Day Night Cycle

Calvin John edited this page Sep 12, 2024 · 16 revisions

Introduction

The DayNightService class manages the day/night cycle in the game. It uses GameTime to track the time on a predefined variable (5 minutes) and handles the transition from day and night by triggering events, which other components respond to.

Functionality

The main functionality of this feature is to;

  • Track time to the interval of 5 minutes which then triggers the end of day cycle.
  • Once the end of day condition is met, the game time is paused and certain events are triggered to ultimately dispose game components, transition to the enddaydisplay then moraldecisiondisplay and finally back to the maingamescreen as a newday
  • Event Handling by triggering events, allowing for other components such as displays to listen and repsond.

Key Attributes and Fields

  • logger (Logger): Used to log events and activities
  • FIVE_MINUTES (long): Constant representing 5 minutes
  • lastCheckTime(long): Stores last time check interval
  • gameTime (GameTime): checks and manipulates the time in game
  • endOfDayTriggered (boolean): flag which defines whether the end of day sequence has been triggered.
  • enddayEventHandler (EventHandler): Manages events and listens to events within this cycle.

Methods

  • create(): Sets up event listeners for handling the new day. Listens for "decisionDone" event.
  • update(): Constantly checks the game time and compares the last interval to the variable containing 5 minutes of elapsed time, triggering the end of day cycle.
  • startNewDay(): Starts the new day. Resumes game time and clears endOfDayTriggered flag.
  • getEvents(): Access to the event handler to listen and trigger events.

Events

  • Dispose: Triggered during end of day sequence to inform MainGameOrderTicketDisplay to reset.
  • endOfDay: Indicates end of day, related to updating necessary affected displays and transitioning to enddaydisplay then moraldecisiondisplay.
  • decisionDone: Used in the startNewDay() method to trigger the start of a new day.
  • newday: Start of a new day, facilitating components to update necessary actions such as updating the current day display.
  • callpastsecond: used in update as a trigger for every second in the game, to update and matc for the displayed timer

UML

![Screen Shot 2024-09-12 at 12 39 12 pm](https://github.com/user-attachments/assets/af4627ee-13bb-4573-a495-1936fa2c9772)

IMG_6661

Sequence Diagram

Untitled Diagram

Table of Contents

Home

Team Design Document

Game Features

Inventory System
Scoring System
Food Recipes
Level System
Player Actions
Ordering System
Stations
Items
Map Design
Customers
Pause Menu
Upgrades
End of Day Display
Day Night Cycle
Moral System
Debug Terminal
Game Interactions Tutorial
Backstory Cutscenes

Game

Getting Started

Entities and Components

World Backstory

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Map Design

Test Plans

Sensor Component

Customer Sensor Component

Interaction Component

Inventory Component

Inventory Display

Station Meal Component

Station Progress Display

Keyboard Input Component

Fire Extinguisher Handler Component

Score System

HoverBox Component

MainGameActions Create Docket Triggers

End Day Display Component

Cutscene Area

Docket

Docket Line Display

Docket Meal Display

Main Game Order Button Display

Order Actions

Recipe

Ticket Details Component

BackstoryCutscene Test Plan

BackstoryCutsceneDisplay Test Plan

Test Plan for Tutorial

Keybinds

Keybinds Test Plan

Test Plan for MainGameOrderTicketDisplay

Test Plan for MainGameOrderBtnDisplay

Test Plan for Docket

Test Plan for DocketLineDisplay

Test Plan for OrderActions

Ticket Details

Test plan for RandomComboService

Test plan for LoanUpgrade

Test plan for UpgradesDisplay

Test plan for RageUpgrade

Test plan for SpeedBoostUpgrade

Test plan for DancePartyUpgrade

Test plan for ExtortionUpgrade

Troubleshooting

MacOS Setup Guide

Clone this wiki locally