-
Notifications
You must be signed in to change notification settings - Fork 0
Enemy AI
DLAmeng edited this page Aug 27, 2022
·
6 revisions
This page is creating for EnemyAI. EnemyAI sets the movement and attack mode of the enemy, for example, the enemy can attack other units remotely within a certain distance
- updown and leftright tasks
- change the entity speed
- Ranged Attack Task
1. Creating updown and leftright tasks, These tasks can move the entity horizontally or up and down.
public void update() {
float position_x = this.owner.getEntity().getPosition().x;
if (isMove) {
if(position_x <= p_x + x/2) {
this.owner.getEntity().getComponent(PhysicsComponent.class).getBody().setLinearVelocity(new Vector2(1,0));
} else {
isMove = false;
}
} else {
if(position_x >= p_x - x/2) {
this.owner.getEntity().getComponent(PhysicsComponent.class).getBody().setLinearVelocity(new Vector2(-1,0));
} else {
isMove = true;
}
}
}
2. Change the movement speed of the entity by adding a method to the PhysicsMovementComponent.java
file.
public PhysicsMovementComponent(Vector2 speed) {
maxSpeed = speed;
}
3. Creating rangedAttack task, this task can control the attack interval, distance, and target of the entity.
public void update() {
if (timeSource.getTime() >= endtime) {
this.owner.getEntity().getEvents().trigger("attack");
endtime = timeSource.getTime() + (int)(waitTime * 1000);
}
}
private float DistanceToTarget() {
return owner.getEntity().getPosition().dst(target.getPosition());
}
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