-
Notifications
You must be signed in to change notification settings - Fork 0
Trebuchet
DLAmeng edited this page Oct 3, 2022
·
2 revisions
This page introduces the function of the trebuchet. The main function of the trebuchet is to launch the bullet to attack the ship. When the bullet contacts the ship, the bullet will disappear and the ship's HP will decrease.
- Spawn bullet at trebuchet location
- The bullet will move towards the target
- The bullet disappears when it touches the target
1. Create a bullet entity by listening to the trigger in the rangedAttackTask
through AttackListner
Component.
public void create() {
super.create();
entity.getEvents().addListener("attack", this::attack);
}
void attack() {
gameArea.spawnEntity(EnemyFactory.createBullet(this.entity, target, gameArea));
}
2. Create a BulletHitShip
Component, which can detect whether the bullet collides with the target. When the bullet collides with the target, the bullet will be destroyed and the target will be damaged.
public void create() {
super.create();
entity.getEvents().addListener("collisionStart", this::Hit);
}
private void Hit(Fixture attack, Fixture player) {
Entity bullet = ((BodyUserData) attack.getBody().getUserData()).entity;
Entity target = ((BodyUserData) player.getBody().getUserData()).entity;
if(target == this.target) {
bullet.getComponent(PhysicsComponent.class).getPhysics().addToDestroy(bullet);
target.getComponent(CombatStatsComponent.class).decreaseHealth(20);
}
}
Map
City
Buildings
Unit Selections
Game User Testing: Theme of Unit Selection & Spell System
Health Bars
In Game menu
- Feature
- User Testing:In Game Menu
Landscape Tile Design Feedback