diff --git a/core/src/com/saltosion/gladiator/GladiatorBrawler.java b/core/src/com/saltosion/gladiator/GladiatorBrawler.java index a55e9a5..e04491b 100644 --- a/core/src/com/saltosion/gladiator/GladiatorBrawler.java +++ b/core/src/com/saltosion/gladiator/GladiatorBrawler.java @@ -91,7 +91,7 @@ public class GladiatorBrawler extends ApplicationAdapter { renderedObject.playAnimation("Idle"); player.add(renderedObject); player.add(new CPhysics().setSize(2, 4).setPosition(0, 5)); - player.add(new CCombat().setBaseDamage(100).setHealth(1000).setSwingCD(.5f)); + player.add(new CCombat().setBaseDamage(100).setHealth(1000)); engine.addEntity(player); AppUtil.player = player; diff --git a/core/src/com/saltosion/gladiator/components/CCombat.java b/core/src/com/saltosion/gladiator/components/CCombat.java index ebcd4a0..4b160ca 100644 --- a/core/src/com/saltosion/gladiator/components/CCombat.java +++ b/core/src/com/saltosion/gladiator/components/CCombat.java @@ -16,7 +16,7 @@ public class CCombat extends Component { private CombatListener combatListener; private Vector2 swinging = new Vector2(); - private float swingCd = 0; + private float swingDuration = 0.4f; public float swingCdCounter = 0; public HashMap inputs = new HashMap(); @@ -50,7 +50,7 @@ public class CCombat extends Component { } public CCombat setSwingCD(float cd) { - this.swingCd = cd; + this.swingDuration = cd; return this; } @@ -83,8 +83,8 @@ public class CCombat extends Component { return randomdamage; } - public float getSwingCD() { - return this.swingCd; + public float getSwingDuration() { + return this.swingDuration; } public Vector2 getSwing() { diff --git a/core/src/com/saltosion/gladiator/systems/CombatSystem.java b/core/src/com/saltosion/gladiator/systems/CombatSystem.java index b488763..14dea62 100644 --- a/core/src/com/saltosion/gladiator/systems/CombatSystem.java +++ b/core/src/com/saltosion/gladiator/systems/CombatSystem.java @@ -68,7 +68,7 @@ public class CombatSystem extends EntitySystem { } createSwingHitbox(e, pos); - combat.swingCdCounter = combat.getSwingCD(); + combat.swingCdCounter = combat.getSwingDuration(); } } } @@ -81,7 +81,7 @@ public class CombatSystem extends EntitySystem { e.add(new CPhysics().setGhost(true).setGravityApplied(false).setMovable(false) .setSize(combat.getSwingSize())); e.getComponent(CPhysics.class).setPosition(position).setCollisionListener(new SwingHitboxListener(source)); - e.add(new CDestructive(.1f)); + e.add(new CDestructive(combat.getSwingDuration()/2)); AppUtil.engine.addEntity(e); } diff --git a/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java b/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java index 2ce15fe..a2f2d0f 100644 --- a/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java +++ b/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java @@ -6,6 +6,7 @@ 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.saltosion.gladiator.components.CCombat; import com.saltosion.gladiator.components.CPhysics; import com.saltosion.gladiator.util.Direction; @@ -17,6 +18,7 @@ public class PhysicsSystem extends EntitySystem { private static final float MAX_VEL = 0.5f; private ComponentMapper pm = ComponentMapper.getFor(CPhysics.class); + private ComponentMapper cm = ComponentMapper.getFor(CCombat.class); private ImmutableArray entities; @Override @@ -29,6 +31,7 @@ public class PhysicsSystem extends EntitySystem { deltaTime = Math.min(deltaTime, 0.033f); for (int i = 0; i < entities.size(); i++) { CPhysics obj = pm.get(entities.get(i)); + CCombat combat = cm.get(entities.get(i)); // Apply movement obj.getPosition().add(obj.getVelocity()); @@ -43,6 +46,11 @@ public class PhysicsSystem extends EntitySystem { move++; } obj.getVelocity().x = move * obj.getMovespeed() * deltaTime; + if (combat != null) { + if (combat.swingCdCounter > 0) { + obj.getVelocity().x /= 2; + } + } if (obj.jumping && obj.isGrounded()) { obj.setGrounded(false); obj.getVelocity().y = obj.getJumpForce();