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

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