Changed filenames & combat tweaking dev.
Before Width: | Height: | Size: 736 KiB After Width: | Height: | Size: 736 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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<Entity> hitEntities = new ArrayList<Entity>();
|
||||
private ComponentMapper<CCombat> cm = ComponentMapper.getFor(CCombat.class);
|
||||
private Entity source;
|
||||
|
||||
public SwingHitboxListener(Entity source) {
|
||||
|
||||
private final ArrayList<Entity> hitEntities = new ArrayList<Entity>();
|
||||
private final ComponentMapper<CCombat> cm = ComponentMapper.getFor(CCombat.class);
|
||||
private final ComponentMapper<CPhysics> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
|