Added the interface Action and implemented the class Attack, Dash, Jump,
Throw, ThrowPart
This commit is contained in:
parent
ab6939466d
commit
ff38cfec5e
10
src/gameplay/actions/Action.java
Normal file
10
src/gameplay/actions/Action.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package gameplay.actions;
|
||||||
|
|
||||||
|
import gameplay.frames.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public interface Action {
|
||||||
|
|
||||||
|
ArrayList<Frame> getFrame();
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,11 @@
|
|||||||
package gameplay.actions;
|
package gameplay.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import gameplay.frames.*;
|
||||||
import gameplay.input.*;
|
import gameplay.input.*;
|
||||||
|
|
||||||
public class Attack {
|
public class Attack implements Action {
|
||||||
/**
|
/**
|
||||||
* Defines if the attack is a special one (E.G. a fireball) or a normal one (a punch)
|
* Defines if the attack is a special one (E.G. a fireball) or a normal one (a punch)
|
||||||
*/
|
*/
|
||||||
@ -15,8 +18,28 @@ public class Attack {
|
|||||||
*/
|
*/
|
||||||
private static Button[][] command;
|
private static Button[][] command;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The different sections of the attack
|
* The different sections of the attack
|
||||||
*/
|
*/
|
||||||
private attackPart[] parts;
|
private attackPart[] parts;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<Frame> getFrame() {
|
||||||
|
ArrayList<Frame> res = new ArrayList<Frame>();
|
||||||
|
|
||||||
|
//browse parts
|
||||||
|
for(int i = 0; i < this.parts.length; i++) {
|
||||||
|
|
||||||
|
//stock current tab of frames
|
||||||
|
Frame[] tmp = this.parts[i].getFrames();
|
||||||
|
int size = tmp.length;
|
||||||
|
|
||||||
|
//browse the tab of frames and add it into a list
|
||||||
|
for(int j = 0; j < size; j++) {
|
||||||
|
res.add(tmp[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
28
src/gameplay/actions/Dash.java
Normal file
28
src/gameplay/actions/Dash.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package gameplay.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import gameplay.frames.Frame;
|
||||||
|
import gameplay.input.Button;
|
||||||
|
|
||||||
|
public class Dash implements Action {
|
||||||
|
/**
|
||||||
|
* The suite of Inputs to have the move come out.
|
||||||
|
* For example, a Front Dash would be something like
|
||||||
|
* {{RIGHT},{RIGHT}}
|
||||||
|
*/
|
||||||
|
private static Button[][] command;
|
||||||
|
|
||||||
|
private Frame[] frames;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<Frame> getFrame() {
|
||||||
|
ArrayList<Frame> res = new ArrayList<Frame>();
|
||||||
|
|
||||||
|
for(int i = 0; i < frames.length; i++) {res.add(frames[i]);}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
src/gameplay/actions/Jump.java
Normal file
28
src/gameplay/actions/Jump.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package gameplay.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import gameplay.frames.Frame;
|
||||||
|
import gameplay.input.Button;
|
||||||
|
|
||||||
|
public class Jump implements Action {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Input to have the move come out.
|
||||||
|
* For example, a Front Jump would be something like
|
||||||
|
* {UP,RIGHT}
|
||||||
|
*/
|
||||||
|
private static Button[] command;
|
||||||
|
|
||||||
|
private Frame[] frames;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<Frame> getFrame() {
|
||||||
|
ArrayList<Frame> res = new ArrayList<Frame>();
|
||||||
|
|
||||||
|
for(int i = 0; i < frames.length; i++) {res.add(frames[i]);}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
src/gameplay/actions/Throw.java
Normal file
53
src/gameplay/actions/Throw.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package gameplay.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import gameplay.frames.Frame;
|
||||||
|
import gameplay.input.Button;
|
||||||
|
|
||||||
|
public class Throw implements Action {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines if the throw is a special one (E.G. a Moonsault Press ) or a normal one
|
||||||
|
*/
|
||||||
|
private static boolean isSpecial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The suite of Inputs to have the move come out.
|
||||||
|
* For example, a Moonsault Press would be something like
|
||||||
|
* {{LEFT},{DOWN,LEFT},{DOWN},{DOWN,RIGHT},{RIGHT},{RIGHT,UP},{UP},{A}}
|
||||||
|
*/
|
||||||
|
private static Button[][] command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The different sections of the throw
|
||||||
|
*/
|
||||||
|
private ThrowPart[] parts;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<Frame> getFrame() {
|
||||||
|
ArrayList<Frame> res = new ArrayList<Frame>();
|
||||||
|
|
||||||
|
//browse parts
|
||||||
|
for(int i = 0; i < this.parts.length; i++) {
|
||||||
|
|
||||||
|
//stock current tab of frames
|
||||||
|
Frame[] tmp = this.parts[i].getFrames();
|
||||||
|
int size = tmp.length;
|
||||||
|
if(this.parts[i].getisActive()) {
|
||||||
|
if(this.parts[i].hasHit()) {
|
||||||
|
for(int j = 0; j < size; j++) {
|
||||||
|
res.add(tmp[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
//browse the tab of frames and add it into a list
|
||||||
|
for(int j = 0; j < size; j++) {
|
||||||
|
res.add(tmp[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
90
src/gameplay/actions/ThrowPart.java
Normal file
90
src/gameplay/actions/ThrowPart.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
package gameplay.actions;
|
||||||
|
|
||||||
|
import gameplay.frames.Frame;
|
||||||
|
|
||||||
|
public class ThrowPart {
|
||||||
|
private int damage, hitstun;
|
||||||
|
private double knockbackOnHit;
|
||||||
|
private Frame[] frames;
|
||||||
|
private boolean hasHit;
|
||||||
|
private boolean isActive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with most parameters for an attack part, generally a hit
|
||||||
|
* @param damage the damage dealt to the enemy if the throw part connects
|
||||||
|
* @param hitstun the amount of frames where the enemy is in hitstun if the throw part connects
|
||||||
|
* @param knockbackOnHit the distance the enemy gets moved back if throwed
|
||||||
|
* @param frames the array of frames for the part
|
||||||
|
* @param isActive true if the part is an active part
|
||||||
|
*/
|
||||||
|
public ThrowPart(int damage, int hitstun, double knockbackOnHit, Frame[] frames, boolean isActive) {
|
||||||
|
this.damage = damage;
|
||||||
|
this.hitstun = hitstun;
|
||||||
|
this.knockbackOnHit = knockbackOnHit;
|
||||||
|
this.frames = frames;
|
||||||
|
this.hasHit = false;
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for an attack part with only a frames array as parameter.
|
||||||
|
* Generally for a move startup or recovery.
|
||||||
|
* @param frames the array of frames for the part
|
||||||
|
*/
|
||||||
|
public ThrowPart(Frame[] frames) {
|
||||||
|
this.frames = frames;
|
||||||
|
this.damage = 0;
|
||||||
|
this.hitstun = 0;
|
||||||
|
this.knockbackOnHit = 0.0;
|
||||||
|
this.hasHit = false;
|
||||||
|
this.isActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasHit() {
|
||||||
|
return hasHit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasHit(boolean hasHit) {
|
||||||
|
this.hasHit = hasHit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamage() {
|
||||||
|
return this.damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDamage(int damage) {
|
||||||
|
this.damage = damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHitstun() {
|
||||||
|
return hitstun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHitstun(int hitstun) {
|
||||||
|
this.hitstun = hitstun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getKnockbackOnHit() {
|
||||||
|
return knockbackOnHit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKnockbackOnHit(double knockback) {
|
||||||
|
this.knockbackOnHit = knockback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Frame[] getFrames() {
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrames(Frame[] frames) {
|
||||||
|
this.frames = frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getisActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setisActive(boolean isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user