diff --git a/src/gameplay/actions/ThrowPart.java b/src/gameplay/actions/ThrowPart.java index e930c1c..f583198 100644 --- a/src/gameplay/actions/ThrowPart.java +++ b/src/gameplay/actions/ThrowPart.java @@ -87,4 +87,12 @@ public class ThrowPart { public void setisActive(boolean isActive) { this.isActive = isActive; } + + public void clone(ThrowPart tP) { + this.hasHit = tP.hasHit(); + this.hitstun = tP.getHitstun(); + this.frames = tP.getFrames(); + this.knockbackOnHit = tP.getKnockbackOnHit(); + this.damage = tP.getDamage(); + } } \ No newline at end of file diff --git a/src/gameplay/entities/Character.java b/src/gameplay/entities/Character.java index 8ae34ca..fd357ae 100644 --- a/src/gameplay/entities/Character.java +++ b/src/gameplay/entities/Character.java @@ -48,6 +48,7 @@ public class Character extends Entity { private Frame crouchHitFrame; private ArrayList nextAttackParts; + private ArrayList nextThrowParts; /** * Main constructor for a character. By default its max health is 1000 if not specified @@ -183,7 +184,7 @@ public class Character extends Entity { this.nextAttackParts.add(parts[i]); } } - + /** * Removes current attack part from the list, * which indicates the character has moved on to the next one @@ -191,6 +192,29 @@ public class Character extends Entity { public void removeFirstAttackPart() { this.nextAttackParts.remove(0); } + + public ArrayList getNextThrowParts() { + return nextThrowParts; + } + + public void setNextThrowParts(ArrayList nextAttackParts) { + this.nextThrowParts = new ArrayList(nextAttackParts); + } + + public void setThrowPartsArray(ThrowPart[] parts) { + this.nextThrowParts = new ArrayList(); + for(int i = 0; i < parts.length; i++) { + this.nextThrowParts.add(parts[i]); + } + } + + /** + * Removes current Throw part from the list, + * which indicates the character has moved on to the next one + */ + public void removeFirstThrowPart() { + this.nextThrowParts.remove(0); + } public static int getCurrentHP() { return currentHP; diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 7d19961..1742cb5 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -4,10 +4,14 @@ import engine.input.Button; import engine.input.GamepadInput; import gameplay.actions.Attack; import gameplay.actions.attackPart; +import gameplay.actions.Throw; +import gameplay.actions.ThrowPart; import gameplay.entities.Status; import gameplay.frames.Frame; import gameplay.hitboxes.Active_HitBox; import gameplay.hitboxes.Passive_HitBox; +import gameplay.hitboxes.Active_throw_Hitbox; +import gameplay.hitboxes.Passive_throw_HitBox; import gameplay.input.InputBuffer; import gameplay.entities.Character; import gameplay.input.Inputs; @@ -216,7 +220,7 @@ public class match { //start of the handling of hitboxes case 21: - handleThrows(); + handleThrows(p1,p2); handleHits(p1,p2,inputsP2); handleHits(p2,p1,inputsP1); ac(22); @@ -340,8 +344,30 @@ public class match { } - private static void handleThrows() { + private static void handleThrows(Character p1, Character p2) { + ArrayList activeP1 = new ArrayList(p1.getCurrentframe().getActThrowHitBox()); + ArrayList passiveP2 = new ArrayList(p2.getCurrentframe().getPassThrowHitBox()); + ArrayList tP = new ArrayList(p1.getNextThrowParts()); + ThrowPart hit = new ThrowPart(tP.get(0).getFrames()); + hit.clone(tP.get(0)); + for(Active_throw_Hitbox atH : activeP1) { + for(Passive_throw_HitBox ptH : passiveP2) { + if(!hit.hasHit()){ + boolean p1LooksRight = p1.getPosX() < p2.getPosX(); + boolean touchH = (p1LooksRight && (atH.getPosX()+p1.getPosX()+ atH.getSize_x() > ptH.getPosX()+p2.getPosX()+ptH.getSize_x()) + && (atH.getPosX() < ptH.getPosX())) + || (!p1LooksRight && (atH.getPosX()+p1.getPosX()+ atH.getSize_x() < ptH.getPosX()+p2.getPosX()+ptH.getSize_x()) + && (atH.getPosX() > ptH.getPosX())); + boolean touchV = (atH.getPosY() - atH.getSize_y() < ptH.getPosY()) && (atH.getPosY() > ptH.getPosY() - ptH.getSize_y()); + if(touchH && touchV) { + hit.setHasHit(true); + tP.set(0,hit); + } + + } + } + } } /**