-
Notifications
You must be signed in to change notification settings - Fork 9
Healing Tool
The Healing Tool is a component of the game that allows players to interact with entities and heal them. To heal any entity such as turret or wall after damage, we need to press 3 and then T-Key on keyboard respectively. A toolbox opens where we can see the heal icon. We click on the heal icon to activate the healing component and then click on either wall or turret to heal the health to maximum.
- Overview
- Code Structure
- Usage
- UML Diagram
- Purpose
- [Testing)(#testing)
- Future Work
The Healing Tool is a subclass of the Tool
class and is responsible for healing entities in the game. Below, we'll dive into the details of the code.
The Healing
class is the main component responsible for healing entities. It is a subclass of the Tool
class.
The Healing
class has a constructor that accepts a map of costs. The cost map is used to specify the resource cost of using this healing tool.
public Healing(ObjectMap<String, Integer> cost) {
super(cost);
}
The interact
method allows the player to interact with entities in the game world. It checks if the player has clicked on an entity, and if so, it attempts to heal the entity by setting its health to its maximum health value.
@Override
public boolean interact(Entity player, GridPoint2 position) {
Entity clickedEntity = determineSelectedEntity(position);
if (clickedEntity == null) {
return false;
}
CombatStatsComponent combatStats = clickedEntity.getComponent(CombatStatsComponent.class);
if (combatStats == null) {
return false;
}
combatStats.setHealth(combatStats.getMaxHealth());
return true;
}
The determineSelectedEntity
method is a private helper function that determines which entity the player has clicked on. It uses the ServiceLocator
to access the StructurePlacementService
and retrieve the entity at the specified position.
private Entity determineSelectedEntity(GridPoint2 position) {
return ServiceLocator.getStructurePlacementService().getStructureAt(position);
}
The purpose of adding healing feature in the game is to basically enable players to strengthen their defence during gameplay. Be it preventing the walls from collapsing or the turrets from getting damaged, the healing tool handles it all.
The healing feature was tested by placing the gates and turrets near enemies and luring them to attack those. Since enemies' attack reduced the health of both of these entities, we were able to heal these entities to maximum by clicking 3 and T-Key respectively, then clicking on the heal icon, and finally clicking on the entity that we wanted to heal.
In coming weeks, we will develop the healing feature to heal as per our requirement in accordance with the resources collected. We might assign a cost per percent of healing. This will enable us to figure the resources (having specific costs allocated to themselves) that are needed for a specific percent of healing of desired entity.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files