Handling of the inputs done. Determines what the characters next frames will be depending on what th player has input.
This commit is contained in:
@ -2,6 +2,8 @@ package gameplay.match;
|
||||
|
||||
import engine.input.Button;
|
||||
import engine.input.GamepadInput;
|
||||
import gameplay.actions.Attack;
|
||||
import gameplay.entities.Status;
|
||||
import gameplay.input.InputBuffer;
|
||||
import gameplay.entities.Character;
|
||||
import gameplay.input.Inputs;
|
||||
@ -216,9 +218,71 @@ public class match {
|
||||
*/
|
||||
private static void handleInputs(Character c, InputBuffer input) {
|
||||
Inputs latestIn = input.getLatestInputs();
|
||||
if(latestIn.containsButtonTab(c.getNormalthrow().getCommand()[0])) {
|
||||
boolean actionSet = false;
|
||||
if(latestIn.containsButtonTab(c.getNormalthrow().getCommand()[0]) && c.getCurrentframe().isNormalCancellable()) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFramesList(c.getNormalthrow().getFrame());
|
||||
actionSet = true;
|
||||
} else {
|
||||
int atkCount = 0;
|
||||
//do an attack if possible
|
||||
while(atkCount < c.getAttacks().length && !actionSet) {
|
||||
Attack atk = c.getAttacks()[atkCount];
|
||||
Boolean attackIsPossible = input.commandRecognized(atk.getCommand())
|
||||
&& atk.getRequiredStatus().equals(c.getStatus())
|
||||
&& ((atk.isSpecial() && c.getCurrentframe().isSpecialCancellable())
|
||||
|| (!atk.isSpecial() && c.getCurrentframe().isNormalCancellable()));
|
||||
if(attackIsPossible) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFramesList(atk.getFrame());
|
||||
actionSet = true;
|
||||
}
|
||||
atkCount++;
|
||||
}
|
||||
if(c.getCurrentframe().isJumpCancellable() && !actionSet) {
|
||||
if (input.commandRecognized(c.getForwardJump().getCommand())) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFramesList(c.getForwardJump().getFrame());
|
||||
actionSet = true;
|
||||
c.setStatus(Status.JUMPING);
|
||||
} else if (input.commandRecognized(c.getBackJump().getCommand())) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFramesList(c.getForwardJump().getFrame());
|
||||
actionSet = true;
|
||||
c.setStatus(Status.JUMPING);
|
||||
} else if (input.commandRecognized(c.getNeutralJump().getCommand())) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFramesList(c.getNeutralJump().getFrame());
|
||||
actionSet = true;
|
||||
c.setStatus(Status.JUMPING);
|
||||
}
|
||||
}
|
||||
if(c.getCurrentframe().isDashCancellable() && !actionSet) {
|
||||
if (input.commandRecognized(c.getForwardDash().getCommand())) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFramesList(c.getForwardDash().getFrame());
|
||||
actionSet = true;
|
||||
} else if (input.commandRecognized(c.getBackDash().getCommand())) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFramesList(c.getBackDash().getFrame());
|
||||
actionSet = true;
|
||||
}
|
||||
}
|
||||
if(c.getCurrentframe().isMoveCancellable() && !actionSet) {
|
||||
if(input.getLatestInputs().containsInput(ButtonIG.DOWN)) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFrames(c.getDefaultCrouchingFrames());
|
||||
} else if(input.getLatestInputs().containsInput(ButtonIG.BACK)) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFrames(c.getBackWalkFrames());
|
||||
} if(input.getLatestInputs().containsInput(ButtonIG.FORWARD)) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFrames(c.getForwardWalkFrames());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user