niu-gdo / IGDO-Fall-2023-Project

IGDO's Fall 2023 game project.
7 stars 0 forks source link

Create Room & Level Framework #33

Closed ExplosiveEggshells closed 8 months ago

ExplosiveEggshells commented 1 year ago

Brief

Completion of this issue will introduce the concept of rooms and levels to our game, allowing the player to transition across rooms within the same level. This will require creating a "Level Manager", capable of disabling inactive rooms, and handling & verifying Transition Endpoints.

Detail

Rooms (Component)

Rooms will need to exist as a MonoBehavior on a parent GameObject for each room in a level.

The room's ID will be used by the Level Manager to access specific rooms within the level. Each room in a level should have a level-unique ID.

The dictionary of Transition Endpoints (Keyed ID numbers and Valued at Transition Endpoint objects), allows the room's transition endpoints to be accessed easily by other scripts, and allows the level managers to make connections between two room's transitions.

Whenever the player is not in a room, the entire root GameObject for the room should become inactive (but not unloaded / destroyed). The Room Component should thusly have a public method for Loading and Unloading the room.

Transition Endpoint (Component)

A transition endpoint will serve as a point in which the player can enter the room the endpoint exists in. Each endpoint should have a room-unique ID.

When the player transitions to this endpoint, they will be placed at the endpoint's world position.

Collision Transition (Component)

This component will store a path to a transition endpoint (accessed via the Level Manager) and will send the player to that endpoint when the player collides with it's hitbox.

These should have a flag which allows their behavior to be temporarily disabled, and the transition should be validated to make sure the endpoint exists before attempting the load.

Further, since we may have different types of transition activators, it would be useful to create an ITransitionActivator interface for later serialization.

Level Manager (Component)

Each scene will contain a Level Manager singleton, which acts as a wrapper around all rooms in the level. It will handle loading the currently active level, as well as globally resolving room-ID/endpoint-ID paths to allow scripts to find rooms and endpoints easily.

Remarks

The "room" Component will very likely be expanded to hold significantly more data about the room and it's contents, such as what needs to be repaired, items collected, etc. Further, it is also worth noting that our game will eventually consist of multiple Level Managers to separate our game into different levels on different scenes.

One thing to avoid would be the temptation to use the inspector window to handle Transition Endpoint connections. We ideally want to minimize coupling between rooms and use a Manager object to handle these connections, and doing so will make validation significantly more robust.

In a further issue, we will look into adding a bunch of validation and autofilling to this framework via editor scripting to improve robustness. Things like transition paths should be automatically validated, and Level Managers should be able to automatically fill in all rooms in the level.

Tasks

Transition Endpoints

Room

Level Manager

Collision Tranisition

ExplosiveEggshells commented 1 year ago

Going to hold this one for a public workshop later this week.