Implemented HandleThrow in match and added some fonction in Character

and ThrowPart
This commit is contained in:
Rémi Rativel 2021-06-09 17:45:09 +02:00
parent d152b2c0aa
commit 0d929b67ca
3 changed files with 61 additions and 3 deletions

View File

@ -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();
}
}

View File

@ -48,6 +48,7 @@ public class Character extends Entity {
private Frame crouchHitFrame;
private ArrayList<attackPart> nextAttackParts;
private ArrayList<ThrowPart> 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<ThrowPart> getNextThrowParts() {
return nextThrowParts;
}
public void setNextThrowParts(ArrayList<ThrowPart> nextAttackParts) {
this.nextThrowParts = new ArrayList<ThrowPart>(nextAttackParts);
}
public void setThrowPartsArray(ThrowPart[] parts) {
this.nextThrowParts = new ArrayList<ThrowPart>();
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;

View File

@ -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<Active_throw_Hitbox> activeP1 = new ArrayList<Active_throw_Hitbox>(p1.getCurrentframe().getActThrowHitBox());
ArrayList<Passive_throw_HitBox> passiveP2 = new ArrayList<Passive_throw_HitBox>(p2.getCurrentframe().getPassThrowHitBox());
ArrayList<ThrowPart> tP = new ArrayList<ThrowPart>(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);
}
}
}
}
}
/**