From 04b573d39536130e8f34a60a05ea26e29c8288a3 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Tue, 21 Jun 2022 15:58:18 +0000 Subject: [PATCH] Include a second knife swing animation for the combo attack Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 --- src/sig/objects/weapons/KnifeSwing2.java | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/sig/objects/weapons/KnifeSwing2.java diff --git a/src/sig/objects/weapons/KnifeSwing2.java b/src/sig/objects/weapons/KnifeSwing2.java new file mode 100644 index 0000000..83afb83 --- /dev/null +++ b/src/sig/objects/weapons/KnifeSwing2.java @@ -0,0 +1,69 @@ +package sig.objects.weapons; + +import sig.engine.AnimatedSprite; +import sig.engine.Panel; +import sig.engine.Transform; +import sig.objects.actor.AttachableObject; +import sig.objects.actor.PhysicsObject; +import sig.objects.actor.State; +import sig.engine.objects.AnimatedObject; +import sig.engine.objects.Object; + +public class KnifeSwing2 extends AttachableObject{ + + final byte frameCount = 5; //Number of frames before animation ends. + + public KnifeSwing2(AnimatedSprite spr, double animationSpd, Panel panel, Object attachedObj) { + super(spr, animationSpd, panel, attachedObj); + } + + @Override + public void update(double updateMult) { + super.update(updateMult); + if (getCurrentFrame()>frameCount) { + setMarkedForDeletion(true); + return; + } + if (getSpriteTransform()==Transform.HORIZONTAL) { + setX(getAttachedObject().getX()+getAnimatedSpr().getWidth()/2); + } else { + setX(getAttachedObject().getX()-getAnimatedSpr().getWidth()/2); + } + setY(getAttachedObject().getY()); + } + + @Override + public void collisionEvent(AnimatedObject obj) { + //System.out.println("Bonk"); + if(obj instanceof PhysicsObject){ + PhysicsObject pobj = (PhysicsObject)obj; + if(pobj.state!=State.STAGGER){ + if(getSpriteTransform()==Transform.NONE){ + pobj.staggerDuration=0.3; + pobj.x_velocity = -500; + pobj.y_velocity = -300; + pobj.state = State.STAGGER; + }else{ + pobj.staggerDuration=0.3; + pobj.x_velocity = 500; + pobj.y_velocity = -300; + pobj.state = State.STAGGER; + } + } + } + } + + @Override + public void draw(byte[] p) { + } + + @Override + public Transform getSpriteTransform() { + return getAttached().getSpriteTransform(); + } + + @Override + public boolean isFriendlyObject() { + return true; + } +}