diff --git a/core/assets/sprites/Audience.png b/core/assets/sprites/audience.png similarity index 100% rename from core/assets/sprites/Audience.png rename to core/assets/sprites/audience.png diff --git a/core/assets/sprites/buttons/Button_Big.png b/core/assets/sprites/buttons/button_big.png similarity index 100% rename from core/assets/sprites/buttons/Button_Big.png rename to core/assets/sprites/buttons/button_big.png diff --git a/core/assets/sprites/buttons/Button_Big_Hover.png b/core/assets/sprites/buttons/button_big_hover.png similarity index 100% rename from core/assets/sprites/buttons/Button_Big_Hover.png rename to core/assets/sprites/buttons/button_big_hover.png diff --git a/core/assets/sprites/buttons/Button_Huge.png b/core/assets/sprites/buttons/button_huge.png similarity index 100% rename from core/assets/sprites/buttons/Button_Huge.png rename to core/assets/sprites/buttons/button_huge.png diff --git a/core/assets/sprites/buttons/Button_Huge_Hover.png b/core/assets/sprites/buttons/button_huge_hover.png similarity index 100% rename from core/assets/sprites/buttons/Button_Huge_Hover.png rename to core/assets/sprites/buttons/button_huge_hover.png diff --git a/core/assets/sprites/buttons/Button_Small.png b/core/assets/sprites/buttons/button_small.png similarity index 100% rename from core/assets/sprites/buttons/Button_Small.png rename to core/assets/sprites/buttons/button_small.png diff --git a/core/assets/sprites/buttons/Button_Small_Hover.png b/core/assets/sprites/buttons/button_small_hover.png similarity index 100% rename from core/assets/sprites/buttons/Button_Small_Hover.png rename to core/assets/sprites/buttons/button_small_hover.png diff --git a/core/assets/sprites/Ground.png b/core/assets/sprites/ground.png similarity index 100% rename from core/assets/sprites/Ground.png rename to core/assets/sprites/ground.png diff --git a/core/src/com/saltosion/gladiator/gui/creators/InGameGUICreator.java b/core/src/com/saltosion/gladiator/gui/creators/InGameGUICreator.java index fad095a..43509ff 100644 --- a/core/src/com/saltosion/gladiator/gui/creators/InGameGUICreator.java +++ b/core/src/com/saltosion/gladiator/gui/creators/InGameGUICreator.java @@ -1,12 +1,7 @@ package com.saltosion.gladiator.gui.creators; -import com.badlogic.gdx.graphics.g2d.Sprite; -import com.saltosion.gladiator.gui.nodes.ButtonNode; import com.saltosion.gladiator.gui.nodes.TextNode; import com.saltosion.gladiator.util.AppUtil; -import com.saltosion.gladiator.util.Log; -import com.saltosion.gladiator.util.Name; -import com.saltosion.gladiator.util.SpriteLoader; public class InGameGUICreator implements GUICreator { @@ -14,30 +9,8 @@ public class InGameGUICreator implements GUICreator { @Override public void create() { - Sprite img1 = SpriteLoader.loadSprite(Name.WALLIMG, 0, 0, 32, 64); - Sprite img2 = SpriteLoader.loadSprite(Name.WALLIMG, 1, 0, 32, 64); - ButtonNode button = new ButtonNode("test-button", img1, img2) { - @Override - public void pressed(int x, int y, int mouseButton) { - Log.info("I should never be pressed against my will!"); - - } - - @Override - public void released(int x, int y, int mouseButton) { - Log.info("And now I was even released! Blasphemy!"); - - } - }; - button.setPosition(0.12f, 0.5f); - AppUtil.guiManager.getRootNode().addChild(button); - - TextNode text = new TextNode("test-text", "Test!"); - text.setPosition(0.8f, 0.5f); - AppUtil.guiManager.getRootNode().addChild(text); - - levelChangeText = new TextNode("Level-Change-Text", "Level change"); - levelChangeText.setPosition(0.4f, 0.5f); + levelChangeText = new TextNode("Level-Change-Text", "Round X"); + levelChangeText.setPosition(0.435f, 0.5f); AppUtil.guiManager.getRootNode().addChild(levelChangeText); } diff --git a/core/src/com/saltosion/gladiator/listeners/SwingHitboxListener.java b/core/src/com/saltosion/gladiator/listeners/SwingHitboxListener.java index b6c7d1f..24f7c8c 100644 --- a/core/src/com/saltosion/gladiator/listeners/SwingHitboxListener.java +++ b/core/src/com/saltosion/gladiator/listeners/SwingHitboxListener.java @@ -5,17 +5,22 @@ import java.util.ArrayList; import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.saltosion.gladiator.components.CCombat; +import com.saltosion.gladiator.components.CPhysics; import com.saltosion.gladiator.systems.CombatSystem; import com.saltosion.gladiator.util.Direction; +import com.saltosion.gladiator.util.Log; public class SwingHitboxListener implements CollisionListener { - - private ArrayList hitEntities = new ArrayList(); - private ComponentMapper cm = ComponentMapper.getFor(CCombat.class); - private Entity source; - - public SwingHitboxListener(Entity source) { + + private final ArrayList hitEntities = new ArrayList(); + private final ComponentMapper cm = ComponentMapper.getFor(CCombat.class); + private final ComponentMapper pm = ComponentMapper.getFor(CPhysics.class); + private final Entity source; + private final Direction direction; + + public SwingHitboxListener(Entity source, Direction direction) { this.source = source; + this.direction = direction; } @Override @@ -24,13 +29,25 @@ public class SwingHitboxListener implements CollisionListener { return; // These entities don't need to take damage } hitEntities.add(other); - + CCombat otherCombat = cm.get(other); - if (otherCombat == null) { - return; + if (otherCombat != null) { + int damage = cm.get(source).getDamage(); + CombatSystem.dealDamage(source, other, damage); + } + + CPhysics otherPhysics = pm.get(other); + if (otherPhysics != null && otherPhysics.getCollisionListener() != null + && otherPhysics.getCollisionListener() instanceof SwingHitboxListener) { + Log.info("Clash!"); + float x = 0; + if (direction == Direction.LEFT) { + x = -1; + } + if (direction == Direction.RIGHT) { + x = 1; + } } - int damage = cm.get(source).getDamage(); - CombatSystem.dealDamage(source, other, damage); } } diff --git a/core/src/com/saltosion/gladiator/systems/CombatSystem.java b/core/src/com/saltosion/gladiator/systems/CombatSystem.java index 66594e9..a5f54e8 100644 --- a/core/src/com/saltosion/gladiator/systems/CombatSystem.java +++ b/core/src/com/saltosion/gladiator/systems/CombatSystem.java @@ -71,21 +71,21 @@ public class CombatSystem extends EntitySystem { } else if (combat.getSwingDirection() == Direction.DOWN) { pos.add(0, -combat.getSwingSize().y / 3 * 2); } - createSwingHitbox(e, pos); + createSwingHitbox(e, combat.getSwingDirection(), pos); combat.swingCdCounter = combat.getSwingDuration(); } } } - public void createSwingHitbox(Entity source, Vector2 position) { + public void createSwingHitbox(Entity source, Direction direction, Vector2 position) { Entity e = new Entity(); CCombat combat = cm.get(source); Sprite s = SpriteLoader.loadSprite(Name.SWINGHITBOXIMG); e.add(new CRenderedObject(s)); e.add(new CPhysics().setGhost(true).setGravityApplied(false).setMovable(false) .setSize(combat.getSwingSize())); - e.getComponent(CPhysics.class).setPosition(position).setCollisionListener(new SwingHitboxListener(source)); + e.getComponent(CPhysics.class).setPosition(position).setCollisionListener(new SwingHitboxListener(source, direction)); e.add(new CDestructive(combat.getSwingDuration() / 2)); AppUtil.engine.addEntity(e); diff --git a/core/src/com/saltosion/gladiator/util/SpriteLoader.java b/core/src/com/saltosion/gladiator/util/SpriteLoader.java index ccddc16..45b5bae 100644 --- a/core/src/com/saltosion/gladiator/util/SpriteLoader.java +++ b/core/src/com/saltosion/gladiator/util/SpriteLoader.java @@ -17,14 +17,14 @@ public class SpriteLoader { loadTexture(Name.GROUNDIMG, "sprites/ground.png"); loadTexture(Name.WALLIMG, "sprites/wall.png"); loadTexture(Name.SWINGHITBOXIMG, "sprites/swinghitbox.png"); - loadTexture(Name.AUDIENCEIMG, "sprites/Audience.png"); + loadTexture(Name.AUDIENCEIMG, "sprites/audience.png"); - loadTexture(Name.BUTTON_HUGE, "sprites/buttons/Button_Huge.png"); - loadTexture(Name.BUTTON_HUGE_HOVER, "sprites/buttons/Button_Huge_Hover.png"); - loadTexture(Name.BUTTON_BIG, "sprites/buttons/Button_Big.png"); - loadTexture(Name.BUTTON_BIG_HOVER, "sprites/buttons/Button_Big_Hover.png"); - loadTexture(Name.BUTTON_SMALL, "sprites/buttons/Button_Small.png"); - loadTexture(Name.BUTTON_SMALL_HOVER, "sprites/buttons/Button_Small_Hover.png"); + loadTexture(Name.BUTTON_HUGE, "sprites/buttons/button_huge.png"); + loadTexture(Name.BUTTON_HUGE_HOVER, "sprites/buttons/button_huge_hover.png"); + loadTexture(Name.BUTTON_BIG, "sprites/buttons/button_big.png"); + loadTexture(Name.BUTTON_BIG_HOVER, "sprites/buttons/button_big_hover.png"); + loadTexture(Name.BUTTON_SMALL, "sprites/buttons/button_small.png"); + loadTexture(Name.BUTTON_SMALL_HOVER, "sprites/buttons/button_small_hover.png"); } /**