Attack combo state setup
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
4531e1653c
commit
57f9a1d132
@ -21,6 +21,9 @@ public class Player extends PhysicsObject{
|
||||
final static long slide_AnimationWaitTime = TimeUtils.millisToNanos(100);
|
||||
final static long slide_duration = TimeUtils.millisToNanos(700);
|
||||
final static long weaponSwingAnimationTime = TimeUtils.millisToNanos(333);
|
||||
final static long weaponComboWaitTime = TimeUtils.millisToNanos(60);
|
||||
final static double finalComboJumpBackSpeedX = -150;
|
||||
final static double finalComboJumpBackSpeedY = -96;
|
||||
|
||||
long weaponSwingTime = 0;
|
||||
|
||||
@ -75,6 +78,16 @@ public class Player extends PhysicsObject{
|
||||
state=State.IDLE;
|
||||
}
|
||||
break;
|
||||
case ATTACK2:
|
||||
if (RabiClone.TIME - weaponSwingTime > weaponSwingAnimationTime) {
|
||||
state=State.IDLE;
|
||||
}
|
||||
break;
|
||||
case ATTACK3:
|
||||
if (RabiClone.TIME - weaponSwingTime > weaponSwingAnimationTime) {
|
||||
state=State.IDLE;
|
||||
}
|
||||
break;
|
||||
case FALLING:
|
||||
if (prvState != State.FALLING) {
|
||||
jump_slide_fall_StartAnimationTimer = RabiClone.TIME;
|
||||
@ -157,7 +170,8 @@ public class Player extends PhysicsObject{
|
||||
break;
|
||||
}
|
||||
prvState = state;
|
||||
if (KeyHeld(Action.JUMP) && RabiClone.TIME - spacebarPressed < jumpHoldTime) {
|
||||
if (KeyHeld(Action.JUMP) && RabiClone.TIME - spacebarPressed < jumpHoldTime
|
||||
&& state!=State.ATTACK2&&state!=State.ATTACK3) {
|
||||
y_velocity = jump_velocity;
|
||||
}
|
||||
// System.out.println(state);
|
||||
@ -183,6 +197,24 @@ public class Player extends PhysicsObject{
|
||||
public void KeyPressed(Action a) {
|
||||
switch (state) {
|
||||
case ATTACK:
|
||||
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||
state=State.ATTACK2;
|
||||
weaponSwingTime=RabiClone.TIME;
|
||||
}
|
||||
break;
|
||||
case ATTACK2:
|
||||
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||
state=State.ATTACK3;
|
||||
weaponSwingTime=RabiClone.TIME;
|
||||
}
|
||||
break;
|
||||
case ATTACK3:
|
||||
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||
state=State.ATTACK4;
|
||||
weaponSwingTime=RabiClone.TIME;
|
||||
y_velocity = finalComboJumpBackSpeedY;
|
||||
x_velocity = finalComboJumpBackSpeedX*(facing_direction?1:-1);
|
||||
}
|
||||
break;
|
||||
case IDLE:
|
||||
if (a == Action.SLIDE || a == Action.FALL) {
|
||||
@ -217,7 +249,8 @@ public class Player extends PhysicsObject{
|
||||
weaponSwingTime=RabiClone.TIME;
|
||||
}
|
||||
if (groundCollision) {
|
||||
if (spacebarReleased && (a == Action.JUMP) && jumpCount > 0) {
|
||||
if (spacebarReleased && (a == Action.JUMP) && jumpCount > 0
|
||||
&&state!=State.ATTACK2&&state!=State.ATTACK3) {
|
||||
state = State.JUMP;
|
||||
jumpCount--;
|
||||
y_velocity = jump_velocity;
|
||||
@ -356,12 +389,12 @@ public class Player extends PhysicsObject{
|
||||
|
||||
@Override
|
||||
public boolean rightKeyHeld() {
|
||||
return KeyHeld(Action.MOVE_RIGHT);
|
||||
return state!=State.ATTACK2&&state!=State.ATTACK3&&KeyHeld(Action.MOVE_RIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leftKeyHeld() {
|
||||
return KeyHeld(Action.MOVE_LEFT);
|
||||
return state!=State.ATTACK2&&state!=State.ATTACK3&&KeyHeld(Action.MOVE_LEFT);
|
||||
}
|
||||
|
||||
public double getYVelocity() {
|
||||
|
@ -6,6 +6,9 @@ public enum State{
|
||||
JUMP,
|
||||
FALLING,
|
||||
ATTACK,
|
||||
ATTACK2,
|
||||
ATTACK3,
|
||||
ATTACK4,
|
||||
STAGGER,
|
||||
UNCONTROLLABLE
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user