diff --git a/core/src/com/saltosion/gladiator/level/EntityFactory.java b/core/src/com/saltosion/gladiator/level/EntityFactory.java index 0d994b2..b7531da 100644 --- a/core/src/com/saltosion/gladiator/level/EntityFactory.java +++ b/core/src/com/saltosion/gladiator/level/EntityFactory.java @@ -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); diff --git a/core/src/com/saltosion/gladiator/level/premade/Round1Level.java b/core/src/com/saltosion/gladiator/level/premade/Round1Level.java index bd3f86a..5badf4a 100644 --- a/core/src/com/saltosion/gladiator/level/premade/Round1Level.java +++ b/core/src/com/saltosion/gladiator/level/premade/Round1Level.java @@ -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()))); } } diff --git a/core/src/com/saltosion/gladiator/level/premade/Round2Level.java b/core/src/com/saltosion/gladiator/level/premade/Round2Level.java index fe2d5c2..a4fef3f 100644 --- a/core/src/com/saltosion/gladiator/level/premade/Round2Level.java +++ b/core/src/com/saltosion/gladiator/level/premade/Round2Level.java @@ -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()))); } } diff --git a/core/src/com/saltosion/gladiator/level/premade/Round3Level.java b/core/src/com/saltosion/gladiator/level/premade/Round3Level.java new file mode 100644 index 0000000..a5c184e --- /dev/null +++ b/core/src/com/saltosion/gladiator/level/premade/Round3Level.java @@ -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 enemies = new ArrayList(); + + @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()))); + } + +} diff --git a/core/src/com/saltosion/gladiator/level/premade/Round4Level.java b/core/src/com/saltosion/gladiator/level/premade/Round4Level.java new file mode 100644 index 0000000..409be2b --- /dev/null +++ b/core/src/com/saltosion/gladiator/level/premade/Round4Level.java @@ -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 enemies = new ArrayList(); + + @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()))); + } + +} diff --git a/core/src/com/saltosion/gladiator/listeners/ai/HeavenWorshiperAI.java b/core/src/com/saltosion/gladiator/listeners/ai/HeavenWorshiperAI.java new file mode 100644 index 0000000..ba8cbc1 --- /dev/null +++ b/core/src/com/saltosion/gladiator/listeners/ai/HeavenWorshiperAI.java @@ -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 closeEntities, Entity host) { + CCombat co = host.getComponent(CCombat.class); + co.inputs.put(Direction.UP, true); + } + +} diff --git a/core/src/com/saltosion/gladiator/listeners/ai/PanicAI.java b/core/src/com/saltosion/gladiator/listeners/ai/PanicAI.java index 47ae9c5..c4de3c2 100644 --- a/core/src/com/saltosion/gladiator/listeners/ai/PanicAI.java +++ b/core/src/com/saltosion/gladiator/listeners/ai/PanicAI.java @@ -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 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; + } } } diff --git a/core/src/com/saltosion/gladiator/state/InGameState.java b/core/src/com/saltosion/gladiator/state/InGameState.java index 1e7a44a..5c20461 100644 --- a/core/src/com/saltosion/gladiator/state/InGameState.java +++ b/core/src/com/saltosion/gladiator/state/InGameState.java @@ -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; diff --git a/core/src/com/saltosion/gladiator/systems/CombatSystem.java b/core/src/com/saltosion/gladiator/systems/CombatSystem.java index 0c77494..a3d4734 100644 --- a/core/src/com/saltosion/gladiator/systems/CombatSystem.java +++ b/core/src/com/saltosion/gladiator/systems/CombatSystem.java @@ -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; }