Added a new AI & 2 rounds.
This commit is contained in:
parent
ea3efb2205
commit
cd115865a8
@ -65,7 +65,7 @@ public class EntityFactory {
|
||||
.setDirection(initialDirection).setMoveSpeed(14f));
|
||||
|
||||
// Combat
|
||||
enemy.add(new CCombat().setBaseDamage(100).setHealth(1000).setSwingCD(.5f)
|
||||
enemy.add(new CCombat().setBaseDamage(100).setHealth(1000)
|
||||
.setCombatListener(new BasicDeathListener()));
|
||||
enemy.add(cai);
|
||||
|
||||
|
@ -4,7 +4,7 @@ import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.saltosion.gladiator.components.CAI;
|
||||
import com.saltosion.gladiator.level.Level;
|
||||
import com.saltosion.gladiator.listeners.ai.PanicAI;
|
||||
import com.saltosion.gladiator.listeners.ai.HeavenWorshiperAI;
|
||||
import com.saltosion.gladiator.util.AppUtil;
|
||||
import com.saltosion.gladiator.util.Direction;
|
||||
import com.saltosion.gladiator.util.Global;
|
||||
@ -38,9 +38,11 @@ public class Round1Level implements Level {
|
||||
@Override
|
||||
public void generate() {
|
||||
AppUtil.levelFactory.createLevelBase();
|
||||
player = AppUtil.entityFactory.createPlayer(new Vector2(-10, 2), Direction.RIGHT);
|
||||
player = AppUtil.entityFactory.createPlayer(new Vector2(0, 2), Direction.RIGHT);
|
||||
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(10, 2), Direction.LEFT,
|
||||
new CAI().setReactDistance(12f).setAIListener(new PanicAI())));
|
||||
new CAI().setReactDistance(12f).setAIListener(new HeavenWorshiperAI())));
|
||||
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(-10, 2), Direction.RIGHT,
|
||||
new CAI().setReactDistance(12f).setAIListener(new HeavenWorshiperAI())));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.saltosion.gladiator.components.CAI;
|
||||
import com.saltosion.gladiator.level.Level;
|
||||
import com.saltosion.gladiator.listeners.ai.HunterAI;
|
||||
import com.saltosion.gladiator.listeners.ai.ScaredAI;
|
||||
import com.saltosion.gladiator.listeners.ai.PanicAI;
|
||||
import com.saltosion.gladiator.util.AppUtil;
|
||||
import com.saltosion.gladiator.util.Direction;
|
||||
import com.saltosion.gladiator.util.Global;
|
||||
@ -41,9 +40,9 @@ public class Round2Level implements Level {
|
||||
AppUtil.levelFactory.createLevelBase();
|
||||
player = AppUtil.entityFactory.createPlayer(new Vector2(0, 2), Direction.RIGHT);
|
||||
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(10, 2), Direction.LEFT,
|
||||
new CAI().setReactDistance(10f).setAIListener(new ScaredAI())));
|
||||
new CAI().setReactDistance(10f).setAIListener(new PanicAI())));
|
||||
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(-10, 2), Direction.RIGHT,
|
||||
new CAI().setReactDistance(10f).setAIListener(new HunterAI())));
|
||||
new CAI().setReactDistance(10f).setAIListener(new PanicAI())));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
package com.saltosion.gladiator.level.premade;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.saltosion.gladiator.components.CAI;
|
||||
import com.saltosion.gladiator.level.Level;
|
||||
import com.saltosion.gladiator.listeners.ai.ScaredAI;
|
||||
import com.saltosion.gladiator.util.AppUtil;
|
||||
import com.saltosion.gladiator.util.Direction;
|
||||
import com.saltosion.gladiator.util.Global;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Round3Level implements Level {
|
||||
|
||||
public Entity player;
|
||||
public ArrayList<Entity> enemies = new ArrayList<Entity>();
|
||||
|
||||
@Override
|
||||
public String getLevelName() {
|
||||
return "Round 1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean levelCleared() {
|
||||
for (Entity enemy : enemies) {
|
||||
if ((enemy.flags & Global.FLAG_ALIVE) == Global.FLAG_ALIVE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean levelFailed() {
|
||||
return (player.flags & Global.FLAG_ALIVE) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
AppUtil.levelFactory.createLevelBase();
|
||||
player = AppUtil.entityFactory.createPlayer(new Vector2(0, 2), Direction.RIGHT);
|
||||
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(10, 2), Direction.LEFT,
|
||||
new CAI().setReactDistance(12f).setAIListener(new ScaredAI())));
|
||||
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(-10, 2), Direction.RIGHT,
|
||||
new CAI().setReactDistance(12f).setAIListener(new ScaredAI())));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.saltosion.gladiator.level.premade;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.saltosion.gladiator.components.CAI;
|
||||
import com.saltosion.gladiator.level.Level;
|
||||
import com.saltosion.gladiator.listeners.ai.HunterAI;
|
||||
import com.saltosion.gladiator.util.AppUtil;
|
||||
import com.saltosion.gladiator.util.Direction;
|
||||
import com.saltosion.gladiator.util.Global;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Round4Level implements Level {
|
||||
|
||||
public Entity player;
|
||||
public ArrayList<Entity> enemies = new ArrayList<Entity>();
|
||||
|
||||
@Override
|
||||
public String getLevelName() {
|
||||
return "Round 1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean levelCleared() {
|
||||
for (Entity enemy : enemies) {
|
||||
if ((enemy.flags & Global.FLAG_ALIVE) == Global.FLAG_ALIVE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean levelFailed() {
|
||||
return (player.flags & Global.FLAG_ALIVE) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
AppUtil.levelFactory.createLevelBase();
|
||||
player = AppUtil.entityFactory.createPlayer(new Vector2(0, 2), Direction.RIGHT);
|
||||
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(10, 2), Direction.LEFT,
|
||||
new CAI().setReactDistance(12f).setAIListener(new HunterAI())));
|
||||
enemies.add(AppUtil.entityFactory.createEnemy(new Vector2(-10, 2), Direction.RIGHT,
|
||||
new CAI().setReactDistance(12f).setAIListener(new HunterAI())));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.saltosion.gladiator.listeners.ai;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.saltosion.gladiator.components.CCombat;
|
||||
import com.saltosion.gladiator.listeners.AIListener;
|
||||
import com.saltosion.gladiator.util.Direction;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HeavenWorshiperAI implements AIListener {
|
||||
|
||||
@Override
|
||||
public void react(ArrayList<Entity> closeEntities, Entity host) {
|
||||
CCombat co = host.getComponent(CCombat.class);
|
||||
co.inputs.put(Direction.UP, true);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.saltosion.gladiator.listeners.ai;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.saltosion.gladiator.components.CCombat;
|
||||
import com.saltosion.gladiator.components.CPhysics;
|
||||
import com.saltosion.gladiator.listeners.AIListener;
|
||||
@ -9,6 +10,17 @@ import java.util.ArrayList;
|
||||
|
||||
public class PanicAI implements AIListener {
|
||||
|
||||
private float swingCd = 0;
|
||||
private final float swingInterval;
|
||||
|
||||
public PanicAI() {
|
||||
swingInterval = 0.75f;
|
||||
}
|
||||
|
||||
public PanicAI(float swingInterval) {
|
||||
this.swingInterval = swingInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void react(ArrayList<Entity> closeEntities, Entity host) {
|
||||
CPhysics po = host.getComponent(CPhysics.class);
|
||||
@ -26,20 +38,24 @@ public class PanicAI implements AIListener {
|
||||
po.jumping = true;
|
||||
}
|
||||
|
||||
switch ((int) Math.ceil(Math.random() * 4)) {
|
||||
default:
|
||||
case 1:
|
||||
co.inputs.put(Direction.LEFT, true);
|
||||
break;
|
||||
case 2:
|
||||
co.inputs.put(Direction.RIGHT, true);
|
||||
break;
|
||||
case 3:
|
||||
co.inputs.put(Direction.DOWN, true);
|
||||
break;
|
||||
case 4:
|
||||
co.inputs.put(Direction.UP, true);
|
||||
break;
|
||||
if (swingCd < swingInterval) {
|
||||
swingCd += Gdx.graphics.getDeltaTime();
|
||||
} else {
|
||||
swingCd = 0;
|
||||
switch ((int) Math.ceil(Math.random() * 6)) {
|
||||
case 1:
|
||||
co.inputs.put(Direction.LEFT, true);
|
||||
break;
|
||||
case 2:
|
||||
co.inputs.put(Direction.RIGHT, true);
|
||||
break;
|
||||
case 3:
|
||||
co.inputs.put(Direction.DOWN, true);
|
||||
break;
|
||||
case 4:
|
||||
co.inputs.put(Direction.UP, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import com.saltosion.gladiator.gui.creators.InGameGUICreator;
|
||||
import com.saltosion.gladiator.level.Level;
|
||||
import com.saltosion.gladiator.level.premade.Round1Level;
|
||||
import com.saltosion.gladiator.level.premade.Round2Level;
|
||||
import com.saltosion.gladiator.level.premade.Round3Level;
|
||||
import com.saltosion.gladiator.level.premade.Round4Level;
|
||||
import com.saltosion.gladiator.util.AppUtil;
|
||||
|
||||
public class InGameState extends BaseState {
|
||||
@ -11,7 +13,8 @@ public class InGameState extends BaseState {
|
||||
/**
|
||||
* Add new levels to this list
|
||||
*/
|
||||
private static final Level[] levels = {new Round1Level(), new Round2Level()};
|
||||
private static final Level[] levels = {new Round1Level(), new Round2Level(),
|
||||
new Round3Level(), new Round4Level()};
|
||||
|
||||
private Level level;
|
||||
private InGameGUICreator guiCreator;
|
||||
|
@ -6,18 +6,14 @@ import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.ashley.core.EntitySystem;
|
||||
import com.badlogic.ashley.core.Family;
|
||||
import com.badlogic.ashley.utils.ImmutableArray;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.saltosion.gladiator.components.CCombat;
|
||||
import com.saltosion.gladiator.components.CDestructive;
|
||||
import com.saltosion.gladiator.components.CPhysics;
|
||||
import com.saltosion.gladiator.components.CRenderedObject;
|
||||
import com.saltosion.gladiator.listeners.CombatListener;
|
||||
import com.saltosion.gladiator.listeners.SwingHitboxListener;
|
||||
import com.saltosion.gladiator.util.AppUtil;
|
||||
import com.saltosion.gladiator.util.Direction;
|
||||
import com.saltosion.gladiator.util.Name;
|
||||
import com.saltosion.gladiator.util.SpriteLoader;
|
||||
|
||||
public class CombatSystem extends EntitySystem {
|
||||
|
||||
@ -39,8 +35,6 @@ public class CombatSystem extends EntitySystem {
|
||||
|
||||
if (combat.swingCdCounter > 0) {
|
||||
combat.swingCdCounter -= deltaTime;
|
||||
}
|
||||
if (combat.swingCdCounter > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user