Main Character Attack Mining Functionality - UQdeco2800/2022-studio-1 GitHub Wiki

Overview

Main Character Sprites and Animation

We took the four different images of the main character holding the axe (previously completed by team 2) and implemented them into the game to change as per 'w' 'a' 's' 'd' key input.

Resource Mining Feature

In addition to the enemies being damaged by the spacebar, we have implemented the player to be able to damage/mine environmental obstacles to gain an initial amount of resources at the beginning of the round. This implementation prioritises enemies over environmental obstacles so that while there're enemies on the map it will target them first, will move on to mine the closest obstacles to the player.

Attack Feature

Although implanted in the previous sprint by the main character, the attack feature was implemented so that when the play collided with the enemy, it automatically took damage. We then worked with their code and instead made a function to tell us what the closest enemy was and then on spacebar input the player would inflict damage to that enemy.

Range Service

Implemented in sprint 3, this service integrates team 7's UGS system and allows anyone the ability to get useful information regarding what's around players/entities in question. This is implemented to be used by enemies and buildings team so they can work out specifically the entities in the 8 tiles surrounding the entity in question and they can implement what said entity would do in this scenario.

Classes

KeyboardPlayerInputComponent.java

Once the event listener for "attack" is registered in PlayerActions.java, this class listens for the player's input from the keyboard and then runs events from the input. Primarily, we used the spacebar to call the event listener "attack" to then call the attack function setup in PlayerActions.java. It also uses the spacebar to call the animation listener to run the animation.

PlayerActions.java

Once the attack function is called by the event listener, it then runs the attack function. This will find the closest enemy to the player (priorities enemies) and then deal the base attack damage to the enemy or dispose of the obstacle if its an Environmental Obstacle.

EntityService.java

EntityService.java will be the primary storage of all entities that are mapped and will be used to access the closest enemy by name to then inflict the damage.

CombatStatsComponent.java

Once EntityService.java gets the closest entity, CombatStatsComponent.java will provide the entity's health, attack damage and relevant other attributes to then carry out the damage, update the health bar and update any relevant inventory items.

RangeService.java

This service is currently being utilised by the main character when its attacking something so the player can know what's closest to it, whether it's an enemy or an entity and how to prioritise that.

UGS.java

This class implemented by team 7 allows for one unified grid system so that entities can interact with each other on one specific hash map allowing for consistent entity interactions.

Player Actions UML Diagram

Range Service UML Diagram