324 lines
8.0 KiB
Java
324 lines
8.0 KiB
Java
package gameplay.entities;
|
|
|
|
import gameplay.actions.*;
|
|
import gameplay.frames.Frame;
|
|
import gameplay.frames.nextFrameBuffer;
|
|
import gameplay.input.InputBuffer;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
/**
|
|
* Character class, which is a sub-class of an entity
|
|
* @author Victor
|
|
*
|
|
*/
|
|
public class Character extends Entity {
|
|
private int maxHP;
|
|
private int currentHP;
|
|
|
|
/**
|
|
* All of the attacks, both special and normal, of the character
|
|
* They should be put in the order of priority (attacks[0] being the highest priority)
|
|
* For example, you should have something like :
|
|
* {Rising Punch, FireBall, Jump D/C/B/A, Crouch D/C/B/A, Stand D/C/B/A}
|
|
*/
|
|
private Attack[] attacks;
|
|
|
|
private Jump forwardJump;
|
|
private Jump neutralJump;
|
|
private Jump backJump;
|
|
|
|
private Dash forwardDash;
|
|
private Dash backDash;
|
|
|
|
private Throw normalthrow;
|
|
|
|
private Status status;
|
|
|
|
private Frame[] defaultStandingFrames;
|
|
private Frame[] defaultCrouchingFrames;
|
|
private Frame[] forwardWalkFrames;
|
|
private Frame[] backWalkFrames;
|
|
private Frame hitInAirFrame; //the frame to display when hit in the air. Shouldmake the character rise
|
|
private Frame fallingframe; //the frame to display when falling from the air
|
|
private Frame[] knockedDownFrames;
|
|
private Frame standGuardFrame;
|
|
private Frame crouchGuardFrame;
|
|
private Frame standHitFrame;
|
|
private Frame crouchHitFrame;
|
|
|
|
private ArrayList<attackPart> nextAttackParts;
|
|
private ArrayList<ThrowPart> nextThrowParts;
|
|
|
|
/**
|
|
* Main constructor for a character. By default its max health is 1000 if not specified
|
|
*/
|
|
public Character() {
|
|
super();
|
|
this.maxHP = 1000;
|
|
this.currentHP = this.maxHP;
|
|
this.status = Status.NORMAL;
|
|
}
|
|
|
|
public Character(int posx, int posy, Frame f, int maxHP) {
|
|
super(posx, posy, f);
|
|
this.maxHP = maxHP;
|
|
this.status = Status.NORMAL;
|
|
this.currentHP = this.maxHP;
|
|
}
|
|
|
|
public Character(int posx, int posy, Frame f, int maxHP, Attack[] attacks, Jump forwardJump, Jump neutralJump, Jump backJump, Dash forwardDash, Dash backDash, Throw normalthrow, Frame[] defaultStandingFrames, Frame[] defaultCrouchingFrames, Frame[] forwardWalkFrames, Frame[] backWalkFrames, Frame hitInAirFrame, Frame fallingframe, Frame[] knockedDownFrames, Frame standGuardFrame, Frame crouchGuardFrame, Frame standHitFrame, Frame crouchHitFrame) {
|
|
super(posx, posy, f);
|
|
this.maxHP = maxHP;
|
|
this.attacks = attacks;
|
|
this.forwardJump = forwardJump;
|
|
this.neutralJump = neutralJump;
|
|
this.backJump = backJump;
|
|
this.forwardDash = forwardDash;
|
|
this.backDash = backDash;
|
|
this.normalthrow = normalthrow;
|
|
this.defaultStandingFrames = defaultStandingFrames;
|
|
this.defaultCrouchingFrames = defaultCrouchingFrames;
|
|
this.forwardWalkFrames = forwardWalkFrames;
|
|
this.backWalkFrames = backWalkFrames;
|
|
this.hitInAirFrame = hitInAirFrame;
|
|
this.fallingframe = fallingframe;
|
|
this.knockedDownFrames = knockedDownFrames;
|
|
this.standGuardFrame = standGuardFrame;
|
|
this.crouchGuardFrame = crouchGuardFrame;
|
|
this.standHitFrame = standHitFrame;
|
|
this.crouchHitFrame = crouchHitFrame;
|
|
this.nextAttackParts = new ArrayList<attackPart>();
|
|
this.nextThrowParts = new ArrayList<ThrowPart>();
|
|
this.currentHP = maxHP;
|
|
this.status = Status.NORMAL;
|
|
}
|
|
|
|
public void setMaxHP(int HP) {
|
|
this.maxHP = HP;
|
|
}
|
|
|
|
public int getMaxHP() { return this.maxHP;}
|
|
|
|
public Attack[] getAttacks() {
|
|
return this.attacks;
|
|
}
|
|
|
|
public void setAttacks(Attack[] attacks) {
|
|
this.attacks = attacks;
|
|
}
|
|
|
|
public Jump getForwardJump() {
|
|
return this.forwardJump;
|
|
}
|
|
|
|
public void setForwardJump(Jump forwardJump) {
|
|
this.forwardJump = forwardJump;
|
|
}
|
|
|
|
public Jump getNeutralJump() {
|
|
return this.neutralJump;
|
|
}
|
|
|
|
public void setNeutralJump(Jump neutralJump) {
|
|
this.neutralJump = neutralJump;
|
|
}
|
|
|
|
public Jump getBackJump() {
|
|
return this.backJump;
|
|
}
|
|
|
|
public void setBackJump(Jump backJump) {
|
|
this.backJump = backJump;
|
|
}
|
|
|
|
public Dash getForwardDash() {
|
|
return this.forwardDash;
|
|
}
|
|
|
|
public void setForwardDash(Dash forwardDash) {
|
|
this.forwardDash = forwardDash;
|
|
}
|
|
|
|
public Dash getBackDash() {
|
|
return this.backDash;
|
|
}
|
|
|
|
public void setBackDash(Dash backDash) {
|
|
this.backDash = backDash;
|
|
}
|
|
|
|
public Throw getNormalthrow() {
|
|
return this.normalthrow;
|
|
}
|
|
|
|
public void setNormalthrow(Throw normalthrow) {
|
|
this.normalthrow = normalthrow;
|
|
}
|
|
|
|
public Status getStatus() {
|
|
return this.status;
|
|
}
|
|
|
|
public void setStatus(Status status) {
|
|
this.status = status;
|
|
}
|
|
|
|
public Frame[] getDefaultStandingFrames() {
|
|
return this.defaultStandingFrames;
|
|
}
|
|
|
|
public void setDefaultStandingFrames(Frame[] defaultStandingFrames) {
|
|
this.defaultStandingFrames = defaultStandingFrames;
|
|
}
|
|
|
|
public Frame[] getDefaultCrouchingFrames() {
|
|
return this.defaultCrouchingFrames;
|
|
}
|
|
|
|
public void setDefaultCrouchingFrames(Frame[] defaultCrouchingFrames) {
|
|
this.defaultCrouchingFrames = defaultCrouchingFrames;
|
|
}
|
|
|
|
public Frame[] getForwardWalkFrames() {
|
|
return this.forwardWalkFrames;
|
|
}
|
|
|
|
public void setForwardWalkFrames(Frame[] forwardWalkFrames) {
|
|
this.forwardWalkFrames = forwardWalkFrames;
|
|
}
|
|
|
|
public Frame[] getBackWalkFrames() {
|
|
return this.backWalkFrames;
|
|
}
|
|
|
|
public void setBackWalkFrames(Frame[] backWalkFrames) {
|
|
this.backWalkFrames = backWalkFrames;
|
|
}
|
|
|
|
public ArrayList<attackPart> getNextAttackParts() {
|
|
return this.nextAttackParts;
|
|
}
|
|
|
|
public void setNextAttackParts(ArrayList<attackPart> nextAttackParts) {
|
|
this.nextAttackParts = new ArrayList<attackPart>(nextAttackParts);
|
|
}
|
|
|
|
public void setAttackPartsArray(attackPart[] parts) {
|
|
this.nextAttackParts = new ArrayList<attackPart>();
|
|
for(int i = 0; i < parts.length; i++) {
|
|
this.nextAttackParts.add(parts[i]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Removes current attack part from the list,
|
|
* which indicates the character has moved on to the next one
|
|
*/
|
|
public void removeFirstAttackPart() {
|
|
this.nextAttackParts.remove(0);
|
|
}
|
|
|
|
public ArrayList<ThrowPart> getNextThrowParts() {
|
|
return this.nextThrowParts;
|
|
}
|
|
|
|
public void setNextThrowParts(ArrayList<ThrowPart> nextAttackParts) {
|
|
this.nextThrowParts = new ArrayList<ThrowPart>(nextAttackParts);
|
|
}
|
|
|
|
public void setThrowPartsArray(ThrowPart[] parts) {
|
|
this.nextThrowParts = new ArrayList<ThrowPart>();
|
|
for(int i = 0; i < parts.length; i++) {
|
|
this.nextThrowParts.add(parts[i]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Removes current Throw part from the list,
|
|
* which indicates the character has moved on to the next one
|
|
*/
|
|
public void removeFirstThrowPart() {
|
|
this.nextThrowParts.remove(0);
|
|
}
|
|
|
|
public int getCurrentHP() {
|
|
return this.currentHP;
|
|
}
|
|
|
|
public void setCurrentHP(int currentHP) {
|
|
this.currentHP = currentHP;
|
|
}
|
|
|
|
/**
|
|
* reduces the current hp of the character by a certain amount.
|
|
* @param dmg the amount of hp to reduce to the character's current hp
|
|
*/
|
|
public void reduceHP(int dmg) {
|
|
this.currentHP = this.currentHP - dmg;
|
|
}
|
|
|
|
/**
|
|
* puts the character's current hp back to its max value
|
|
*/
|
|
public void resetCurrentHP() {
|
|
this.currentHP = this.maxHP;
|
|
}
|
|
|
|
public Frame getHitInAirFrame() {
|
|
return this.hitInAirFrame;
|
|
}
|
|
|
|
public void setHitInAirFrame(Frame hitInAirFrame) {
|
|
this.hitInAirFrame = hitInAirFrame;
|
|
}
|
|
|
|
public Frame getFallingframe() {
|
|
return this.fallingframe;
|
|
}
|
|
|
|
public void setFallingframe(Frame fallingframe) {
|
|
this.fallingframe = fallingframe;
|
|
}
|
|
|
|
public Frame[] getKnockedDownFrames() {
|
|
return this.knockedDownFrames;
|
|
}
|
|
|
|
public void setKnockedDownFrames(Frame[] knockedDownFrames) {
|
|
this.knockedDownFrames = knockedDownFrames;
|
|
}
|
|
|
|
public Frame getStandGuardFrame() {
|
|
return this.standGuardFrame;
|
|
}
|
|
|
|
public void setStandGuardFrame(Frame standGuardFrame) {
|
|
this.standGuardFrame = standGuardFrame;
|
|
}
|
|
|
|
public Frame getCrouchGuardFrame() {
|
|
return this.crouchGuardFrame;
|
|
}
|
|
|
|
public void setCrouchGuardFrame(Frame crouchGuardFrame) {
|
|
this.crouchGuardFrame = crouchGuardFrame;
|
|
}
|
|
|
|
public Frame getStandHitFrame() {
|
|
return this.standHitFrame;
|
|
}
|
|
|
|
public void setStandHitFrame(Frame standHitFrame) {
|
|
this.standHitFrame = standHitFrame;
|
|
}
|
|
|
|
public Frame getCrouchHitFrame() {
|
|
return this.crouchHitFrame;
|
|
}
|
|
|
|
public void setCrouchHitFrame(Frame crouchHitFrame) {
|
|
this.crouchHitFrame = crouchHitFrame;
|
|
}
|
|
}
|