Added AI react distance debug rendering.
This commit is contained in:
parent
78b4204cd3
commit
4d074bee4a
@ -44,11 +44,15 @@ public class EntityFactory {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity createDummy(Vector2 pos) {
|
public Entity createEnemy(Vector2 pos) {
|
||||||
return createDummy(pos, Direction.RIGHT);
|
return createEnemy(pos, Direction.RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity createDummy(Vector2 pos, Direction initialDirection) {
|
public Entity createEnemy(Vector2 pos, Direction initialDirection) {
|
||||||
|
return createEnemy(pos, initialDirection, new CAI().setReactDistance(5).setAIListener(new DummyAI()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entity createEnemy(Vector2 pos, Direction initialDirection, CAI cai) {
|
||||||
Entity dummy = new Entity();
|
Entity dummy = new Entity();
|
||||||
dummy.flags |= Global.FLAG_ALIVE;
|
dummy.flags |= Global.FLAG_ALIVE;
|
||||||
|
|
||||||
@ -61,7 +65,7 @@ public class EntityFactory {
|
|||||||
// Combat
|
// Combat
|
||||||
dummy.add(new CCombat().setBaseDamage(100).setHealth(1000).setSwingCD(.5f)
|
dummy.add(new CCombat().setBaseDamage(100).setHealth(1000).setSwingCD(.5f)
|
||||||
.setCombatListener(new BasicDeathListener()));
|
.setCombatListener(new BasicDeathListener()));
|
||||||
dummy.add(new CAI().setReactDistance(5).setAIListener(new DummyAI()));
|
dummy.add(cai);
|
||||||
|
|
||||||
AppUtil.engine.addEntity(dummy);
|
AppUtil.engine.addEntity(dummy);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class Round1Level implements Level {
|
|||||||
public void generate() {
|
public void generate() {
|
||||||
AppUtil.levelFactory.createLevelBase();
|
AppUtil.levelFactory.createLevelBase();
|
||||||
player = AppUtil.entityFactory.createPlayer(new Vector2(-10, 2), Direction.RIGHT);
|
player = AppUtil.entityFactory.createPlayer(new Vector2(-10, 2), Direction.RIGHT);
|
||||||
enemies.add(AppUtil.entityFactory.createDummy(new Vector2(10, 2), Direction.LEFT));
|
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(10, 2), Direction.LEFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ public class Round2Level implements Level {
|
|||||||
public void generate() {
|
public void generate() {
|
||||||
AppUtil.levelFactory.createLevelBase();
|
AppUtil.levelFactory.createLevelBase();
|
||||||
player = AppUtil.entityFactory.createPlayer(new Vector2(0, 2), Direction.RIGHT);
|
player = AppUtil.entityFactory.createPlayer(new Vector2(0, 2), Direction.RIGHT);
|
||||||
enemies.add(AppUtil.entityFactory.createDummy(new Vector2(10, 2), Direction.LEFT));
|
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(10, 2), Direction.LEFT));
|
||||||
enemies.add(AppUtil.entityFactory.createDummy(new Vector2(-10, 2), Direction.RIGHT));
|
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(-10, 2), Direction.RIGHT));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import com.saltosion.gladiator.components.CAI;
|
||||||
import com.saltosion.gladiator.components.CCombat;
|
import com.saltosion.gladiator.components.CCombat;
|
||||||
import com.saltosion.gladiator.components.CParticle;
|
import com.saltosion.gladiator.components.CParticle;
|
||||||
import com.saltosion.gladiator.components.CPhysics;
|
import com.saltosion.gladiator.components.CPhysics;
|
||||||
@ -28,7 +29,6 @@ import com.saltosion.gladiator.gui.nodes.TextNode;
|
|||||||
import com.saltosion.gladiator.gui.properties.TextProperty;
|
import com.saltosion.gladiator.gui.properties.TextProperty;
|
||||||
import com.saltosion.gladiator.util.AppUtil;
|
import com.saltosion.gladiator.util.AppUtil;
|
||||||
import com.saltosion.gladiator.util.Global;
|
import com.saltosion.gladiator.util.Global;
|
||||||
import com.saltosion.gladiator.util.Log;
|
|
||||||
import com.saltosion.gladiator.util.Name;
|
import com.saltosion.gladiator.util.Name;
|
||||||
import com.saltosion.gladiator.util.SpriteLoader;
|
import com.saltosion.gladiator.util.SpriteLoader;
|
||||||
import com.saltosion.gladiator.util.SpriteSequence;
|
import com.saltosion.gladiator.util.SpriteSequence;
|
||||||
@ -40,6 +40,7 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
private final ComponentMapper<CRenderedObject> rom = ComponentMapper.getFor(CRenderedObject.class);
|
private final ComponentMapper<CRenderedObject> rom = ComponentMapper.getFor(CRenderedObject.class);
|
||||||
private final ComponentMapper<CPhysics> pm = ComponentMapper.getFor(CPhysics.class);
|
private final ComponentMapper<CPhysics> pm = ComponentMapper.getFor(CPhysics.class);
|
||||||
private final ComponentMapper<CCombat> cm = ComponentMapper.getFor(CCombat.class);
|
private final ComponentMapper<CCombat> cm = ComponentMapper.getFor(CCombat.class);
|
||||||
|
private final ComponentMapper<CAI> aim = ComponentMapper.getFor(CAI.class);
|
||||||
private final ComponentMapper<CParticle> pam = ComponentMapper.getFor(CParticle.class);
|
private final ComponentMapper<CParticle> pam = ComponentMapper.getFor(CParticle.class);
|
||||||
private ImmutableArray<Entity> entities;
|
private ImmutableArray<Entity> entities;
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
public int screenWidth = 0;
|
public int screenWidth = 0;
|
||||||
|
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
private final Color debugColor = new Color(0, 1, 0, 1);
|
private final Color debugColor = new Color(0, 1, 0, 1), debugAIColor = new Color(1, 0, 0, 1);
|
||||||
|
|
||||||
private float deltaDelay = 0;
|
private float deltaDelay = 0;
|
||||||
private double deltaAvgSum;
|
private double deltaAvgSum;
|
||||||
@ -326,6 +327,16 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
debugRenderer.line(x1, y0, x1, y1);
|
debugRenderer.line(x1, y0, x1, y1);
|
||||||
debugRenderer.line(x1, y1, x0, y1);
|
debugRenderer.line(x1, y1, x0, y1);
|
||||||
debugRenderer.line(x0, y1, x0, y0);
|
debugRenderer.line(x0, y1, x0, y0);
|
||||||
|
|
||||||
|
CAI ai = aim.get(entities.get(i));
|
||||||
|
if (ai == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
float x = physics.getPosition().x + getCameraOffset(playerPhys, physics).x;
|
||||||
|
float y = physics.getPosition().y + getCameraOffset(playerPhys, physics).y;
|
||||||
|
|
||||||
|
debugRenderer.setColor(debugAIColor);
|
||||||
|
debugRenderer.circle(x, y, ai.getReactDistance());
|
||||||
}
|
}
|
||||||
debugRenderer.end();
|
debugRenderer.end();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user