-
Notifications
You must be signed in to change notification settings - Fork 9
Gates
Gates are used to allow the player to travel through walls. It has a collision box by default so no other entity can pass through. When a player is near the gate, it will automatically open and disable its' collision, thus allowing the player to walk through. Once the player leaves a radius around the gate, it will once again close and the collision will be re-enabled.
A gate can be placed by holding left-control and left-clicking simultaneously.
A gate can be removed by pressing right-click on its position.
The Gate
class is a component of the game's entities. It is responsible for creating and managing gate entities which can be placed/opened/removed in the game environment. The gate uses the following components.
- PhysicsComponent - this is a requirement for collision.
- CollidorComponent - this allows for entities to collide with the gate.
- HealthBarComponent - this allows the player to see the health of the gate when nearby.
- CombatStatsComponent - this allows the gate to have a health.
- JoinableComponent - this allows the gate to join with other walls and gates.
- ProximityActivationComponent - this allows the gate to open and close when a player enters and exits its' radius.
This UML doesn't include any of the functions and properties of the other classes. It is mainly for the purpose of showing the relationship between each Class the Gate uses.
com.csse3200.game.entities.buildables.Gate
The purpose of the Gate
class is to spawn and manage individual Gate entities within the game world.
Gate are objects that occupy a single tile on the map and connect to walls when placed adjacent to each other.
The gate has different health based on level ie. 'gate_closed'-200, 'gate_open'-0
Health The health and gate textures can be changed in 'configs/gate.json'.
addComponent(new ProximityActivationComponent(1.5f, player, this::openGate, this::closeGate));
where openGate
opens the gate, and closeGate
closes the gate.
Gate opens using the ProximityActivationComponent
which opens the gate when player is near and closes it when the player moves away.
The gate was tested by placing it in the map and placing walls next to it to ensure that it was connecting properly. It was also tested by having the player walk close to the gate to see if it opened and leave the radius to ensure it closes. An enemy was also lured near the gate to see if they could travel through when the gate was open and couldn't if the gate was closed.
JUnit testing is planned to be implemented next sprint once we have a more solid understanding of using Mockito for testing.
Currently if the gate is placed with an incompatible cardinality (e.g. a connection left and up) it will revert to a dirt wall texture. This is a known restriction with the current implementation of the JoinableComponent and something which will be fixed as a priority in the next sprint.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files