From 57f9a1d1328469fd2db6e9349c673951b5ce3082 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Tue, 21 Jun 2022 15:25:04 +0000 Subject: [PATCH] Attack combo state setup Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 --- src/sig/objects/Player.java | 41 ++++++++++++++++++++++++++++---- src/sig/objects/actor/State.java | 3 +++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/sig/objects/Player.java b/src/sig/objects/Player.java index a11a94c..83ca59e 100644 --- a/src/sig/objects/Player.java +++ b/src/sig/objects/Player.java @@ -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() { diff --git a/src/sig/objects/actor/State.java b/src/sig/objects/actor/State.java index 6b9d92d..88068db 100644 --- a/src/sig/objects/actor/State.java +++ b/src/sig/objects/actor/State.java @@ -6,6 +6,9 @@ public enum State{ JUMP, FALLING, ATTACK, + ATTACK2, + ATTACK3, + ATTACK4, STAGGER, UNCONTROLLABLE } \ No newline at end of file