Commit 620dd1ab authored by Louis Cohen's avatar Louis Cohen
Browse files

Merge branch 'master' of gitlab.crans.org:genie_logiciel_2015/the_dungeon_project

parents 2042e2e1 fe886f89
......@@ -7,7 +7,7 @@ PACKAGEDIRS = ${shell find . -iname '*.java' | sed 's/\.\/\|[^/]*.java//g' | sor
#TESTCLASS = ${shell find . -name *Test.java | sed 's/.\/src\/\|.java//g' | sed 's/\//./g'}
PARSER = ${shell find . -name *.jj | sed "s/\.\///"}
PARSER = src/ingame_programming/Script.jj
# Java compiler
JAVAC = javac
......@@ -70,7 +70,7 @@ buildplay: all
# Generate parser
genpars: $(PARSER)
cd `dirname $<` ;find . -name *.jj | while read i; do java -cp lib/javacc-6.1.2.jar javacc $$i; done
@cd `dirname $<` ;find . -name *.jj | while read i; do java -cp lib/javacc-6.1.2.jar javacc $$i; done
clean :
rm -rf $(BIN)
......
src/assets/firebolt.png

2.65 KB | W: | H:

src/assets/firebolt.png

2.65 KB | W: | H:

src/assets/firebolt.png
src/assets/firebolt.png
src/assets/firebolt.png
src/assets/firebolt.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -72,7 +72,7 @@ CHATROSE
0
#abilityList
4
TEST_ATTACK_ABILITY
MENTALI_ATTACK
TEST_FIREBOLT
NULL_ABILITY
TEST_LP_FIREBOLT
......@@ -90,7 +90,7 @@ WATER
LIGHT
DARK
#baseHP
10
200
#baseDef
1
#baseMental
......
......@@ -8,5 +8,6 @@ public enum AbilityKey {
TEST_ATTACK_ABILITY,
TEST_LP_FIREBOLT,
TEST_FIREBOLT,
MENTALI_ATTACK,
TEST_SUICIDE;
}
......@@ -33,13 +33,29 @@ public class AbilityRoster {
abilityGenerator =
() -> new Ability(
1200,
100,
AbilityIconKeys.SWORD_RED_1,
Action.ATTACK,
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_ATTACK_EFFECT, new int[]{2})))
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_ATTACK_EFFECT, new int[]{1})))
);
abilityFactory.registerAbilityGenerator(AbilityKey.TEST_ATTACK_ABILITY, abilityGenerator);
abilityGenerator =
() -> new Ability(
2000,
AbilityIconKeys.MENTALI_ATTACK,
Action.ATTACK,
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.MENTALI_ATTACK_DAMAGE, new int[]{10000,32})))
);
abilityFactory.registerAbilityGenerator(AbilityKey.MENTALI_ATTACK, abilityGenerator);
abilityGenerator =
() -> new Ability(
2000,
......@@ -48,6 +64,7 @@ public class AbilityRoster {
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_FIREBOLT, new int[]{5,10})))
);
abilityFactory.registerAbilityGenerator(AbilityKey.TEST_FIREBOLT, abilityGenerator);
abilityGenerator =
() -> new Ability(
2000,
......
package core.abilities.effects;
import core.zone.Translation;
/**
* Created by dupriez on 22/12/15.
*
......@@ -28,6 +30,23 @@ public final class EffectGeneratorRoster {
};
effectFactory.registerEffectGenerator(EffectKey.TEST_ATTACK_EFFECT, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
int amountOfDamage = parameters.getNthParameter(0);
int range = parameters.getNthParameter(1);
return eb.affectZone((character -> (character.getHitbox().clone().translate(Translation.construct(character.getDirection(),range)) ) ),
eb.filter( CommonCharacterIDListFilter.allExceptOne(casterCharacterID),
eb.reduceHP(amountOfDamage)));
};
effectFactory.registerEffectGenerator(EffectKey.MENTALI_ATTACK_DAMAGE, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
return eb.suicide();
......
......@@ -14,7 +14,8 @@ public enum EffectKey {
TEST_SUICIDE(1),
TRAP_TRIGGER(0),
TRIGGER_DEGAT(0),
TRIGGER_DEGAT_LP(0);
TRIGGER_DEGAT_LP(0),
MENTALI_ATTACK_DAMAGE(2);
private EffectKey(int parameterNb) {
this.parameterNb = parameterNb;
......
......@@ -8,6 +8,6 @@ package core.gamestate;
public enum Action {
WALK,
ATTACK,
HIT
;
HIT,
NONE
}
......@@ -11,6 +11,7 @@ public enum AbilityIconKeys {
VIAL_RED_1,
FIRE_BOLT_1,
FROST_BOLT_1,
MENTALI_ATTACK,
EXPLOSION_1,
NULL_ABILITY,
}
package graphics.guiSkeleton.entityDisplayer;
import core.gamestate.Action;
import core.zone.Direction;
/**
* Created by gwendoline on 05/01/16.
*
* Contains an Orientation and an Action.
* To be mapped to instances of Animation
*/
public class DirectionAndAction {
private Direction direction;
private Action action;
public DirectionAndAction(Direction direction, Action action) {
this.direction = direction;
this.action = action;
}
public Direction getDirection() {
return direction;
}
public Action getAction() {
return action;
}
}
package graphics.guiSkeleton.entityDisplayer;
import core.gamestate.Action;
import core.gamestate.Entity;
import core.zone.Direction;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
import graphics.guiSkeleton.mapManagement.PositionedSprite;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.sprites.Animation;
import graphics.guiSkeleton.sprites.Sprite;
/**
......@@ -15,23 +23,55 @@ import graphics.guiSkeleton.mapManagement.GraphicsMap;
* Each entity should have one instance of a subclass of this class
* It is used by the gui to know how to display the said entity
*/
abstract public class EntityDisplayer implements Serializable {
public class EntityDisplayer implements Serializable {
private static final long serialVersionUID = 1L;
//The Entity this Displayer is associated to
private Entity associatedEntity;
private Map<Action, Animation>[] animationMapTab= new Map[Direction.values().length] ;
private char charForTerminalSprite;
public EntityDisplayer(Entity associatedEntity) {
public EntityDisplayer(Entity associatedEntity, Map<Action, Animation>[] animationMapTab, char charForTerminalSprite) {
this.associatedEntity = associatedEntity;
}
this.charForTerminalSprite = charForTerminalSprite;
this.animationMapTab = animationMapTab;
}
/**
* The purpose of this function is to be called by the gui when it displays the entity related to this displayer
* @param graphicsMap: the GraphicsMap of the map the associatedEntity is on
* @return The PositionedSprite that the gui should display to represent this entity
*/
abstract public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap);
abstract public char getTermSprite();
public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
//Get the good image
int dir = associatedEntity.getDirection().ordinal();
Animation animation;
if (associatedEntity.hasAction(Action.ATTACK)) {
animation = animationMapTab[dir].get(Action.ATTACK);
if (associatedEntity.hasAction(Action.HIT))
animation.setHIT(true);
associatedEntity.removeAction(Action.ATTACK);
}
else if (associatedEntity.hasAction(Action.WALK)) {
animation = animationMapTab[dir].get(Action.WALK);
if (associatedEntity.hasAction(Action.HIT))
animation.setHIT(true);
associatedEntity.removeAction(Action.WALK);
}
else {
animation = animationMapTab[dir].get(Action.NONE);
if (associatedEntity.hasAction(Action.HIT))
animation.setHIT(true);
}
Sprite sprite = new Sprite(animation.getSpriteImage());
GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(associatedEntity.getX(), associatedEntity.getY());
GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(-animation.getCurrentSpriteWidth() / 2, -animation.getCurrentSpriteHeight() / 2);
return PositionedSprite.PositionSprite(sprite, spriteTopLeftGraphicsMapPoint);
}
public char getTermSprite() {
return charForTerminalSprite;
}
//abstract public PositionedSpriteTerm getPositionedSpriteTerm(GraphicsMapTerm graphicsMap);
public Entity getAssociatedEntity() {
......
package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank;
import core.gamestate.Action;
import core.gamestate.Entity;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayer;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
import graphics.guiSkeleton.mapManagement.PositionedSprite;
import graphics.guiSkeleton.sprites.SpriteStorage;
import graphics.guiSkeleton.sprites.Sprite;
/**
* Created by dupriez on 14/11/15.
* Full credits for the code go to Gwendoline, I just created this class and put it in
*
* An implementation of the entityDisplayer class for the pokemon Mentali
*/
public class ChatRoseEntityDisplayer extends EntityDisplayer {
private static final long serialVersionUID = 1L;
//The unique sprite of "Doty the Entity" (it is not animated)
int sprite_num; // le numéro d'image où on en est de l'animation
int sprite_height;
int sprite_width;
int nb_images[]=new int[Action.values().length];
final static int DEFAULT_SPRITE=1;
public ChatRoseEntityDisplayer(Entity associatedEntity) {
super(associatedEntity);
sprite_num = 0;
sprite_height = 32;
sprite_width = 32;
nb_images[Action.WALK.ordinal()] = 2;
//QUickFix -Thomas
//0 -> 2
nb_images[Action.ATTACK.ordinal()] = /*0*/2;
nb_images[Action.HIT.ordinal()] = 2;
}
// TODO : change in action. Adaptation for multiaction.
@Override
public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
Sprite sprite = SpriteStorage.getInstance().getChatRose();
Entity entity = getAssociatedEntity();
GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY());
//applying translation
GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(- sprite_width/2, - sprite_height/2);
int direction = entity.getDirection().ordinal();
int x_sprite=0;
int y_sprite = direction * sprite_height;
int nbSprites=DEFAULT_SPRITE;
for(Action act : Action.values()){
if(entity.hasAction(act)){
nbSprites=nb_images[act.ordinal()];
break;
}
}
sprite_num=(sprite_num+1)%(10*nbSprites);
for(int u=0; u<nbSprites; u++) {
if (sprite_num < 10*u) x_sprite = x_sprite + sprite_width;
}
Sprite res = new Sprite((sprite.getSpriteImage()).getSubimage(x_sprite,y_sprite,sprite_height,sprite_width));
return PositionedSprite.PositionSprite(res, spriteTopLeftGraphicsMapPoint);
}
public char getTermSprite(){
return 'C';
}
}
package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank;
import core.gamestate.Action;
import core.gamestate.Entity;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayer;
import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
import graphics.guiSkeleton.mapManagement.PositionedSprite;
import graphics.guiSkeleton.sprites.Sprite;
import graphics.guiSkeleton.sprites.SpriteStorage;
/**
*
* @author Lucas Delcros
* Classe pour diagla (le boss) juste du copy-paste d'autres entites
*/
public class DiaglaEntityDisplayer extends EntityDisplayer{
private static final long serialVersionUID = 1L;
//The unique sprite of "Doty the Entity" (it is not animated)
int sprite_num; // le numéro d'image où on en est de l'animation
int sprite_height;
int sprite_width;
int nb_images[]=new int[Action.values().length];
final static int DEFAULT_SPRITE=1;
public DiaglaEntityDisplayer(Entity associatedEntity) {
super(associatedEntity);
sprite_num = 0;
sprite_height = 64;
sprite_width = 64;
nb_images[Action.WALK.ordinal()] = 2;
//QUickFix -Thomas
//0 -> 2
nb_images[Action.ATTACK.ordinal()] = /*0*/2;
nb_images[Action.HIT.ordinal()] = 2;
}
// TODO : change in action. Adaptation for multiaction.
@Override
public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
Sprite sprite = SpriteStorage.getInstance().getDiagla();
Entity entity = getAssociatedEntity();
GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY());
//applying translation
GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(- sprite_width/2, - sprite_height/2);
int direction = entity.getDirection().ordinal();
int x_sprite=0;
int y_sprite = direction * sprite_height;
int nbSprites=DEFAULT_SPRITE;
for(Action act : Action.values()){
if(entity.hasAction(act)){
nbSprites=nb_images[act.ordinal()];
break;
}
}
sprite_num=(sprite_num+1)%(10*nbSprites);
for(int u=0; u<nbSprites; u++) {
if (sprite_num < 10*u) x_sprite = x_sprite + sprite_width;
}
Sprite res = new Sprite((sprite.getSpriteImage()).getSubimage(x_sprite,y_sprite,sprite_height,sprite_width));
return PositionedSprite.PositionSprite(res, spriteTopLeftGraphicsMapPoint);
}
@Override
public char getTermSprite() {
return 'D';
}
}
package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank;
import core.gamestate.Action;
import core.gamestate.Entity;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayer;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
import graphics.guiSkeleton.mapManagement.PositionedSprite;
import graphics.guiSkeleton.sprites.SpriteStorage;
import graphics.guiSkeleton.sprites.Sprite;
/**
* Created by hilaire on 05/01/16
* Full credits for the code go to Gwendoline, I just created this class and put it in
*
* An implementation of the entityDisplayer class for the Firebolt
*/
public class FireboltEntityDisplayer extends EntityDisplayer {
private static final long serialVersionUID = 1L;
//The unique sprite of "Doty the Entity" (it is not animated)
int sprite_num; // le numéro d'image où on en est de l'animation
int sprite_height;
int sprite_width;
int nb_images[]=new int[Action.values().length];
final static int DEFAULT_SPRITE=1;
public FireboltEntityDisplayer(Entity associatedEntity) {
super(associatedEntity);
sprite_num = 0;
sprite_height = 32;
sprite_width = 32;
nb_images[Action.WALK.ordinal()] = 2;
nb_images[Action.ATTACK.ordinal()] = 2;
nb_images[Action.HIT.ordinal()] = 2;
}
@Override
public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
Sprite sprite = SpriteStorage.getInstance().getFirebolt();
Entity entity = getAssociatedEntity();
GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY());
//applying translation
GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(- sprite_width/2, - sprite_height/2);
int direction = entity.getDirection().ordinal();
int x_sprite=0;
int y_sprite = direction * sprite_height;
int nbSprites=DEFAULT_SPRITE;
for(Action act : Action.values()){
if(entity.hasAction(act)){
nbSprites=nb_images[act.ordinal()];
break;
}
}
sprite_num=(sprite_num+1)%(10*nbSprites);
for(int u=0; u<nbSprites; u++) {
if (sprite_num < 10*u) x_sprite = x_sprite + sprite_width;
}
Sprite res = new Sprite((sprite.getSpriteImage()).getSubimage(x_sprite,y_sprite,sprite_height,sprite_width));
return PositionedSprite.PositionSprite(res, spriteTopLeftGraphicsMapPoint);
}
public char getTermSprite(){
return 'C';
}
}
package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank;
import core.gamestate.Action;
import core.gamestate.Entity;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayer;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
import graphics.guiSkeleton.mapManagement.PositionedSprite;
import graphics.guiSkeleton.sprites.SpriteStorage;
import graphics.guiSkeleton.sprites.Sprite;
/**
* Created by hilaire on 05/01/16
* Full credits for the code go to Gwendoline, I just created this class and put it in
*
* An implementation of the entityDisplayer class for the Frostbolt
*/
public class FrostboltEntityDisplayer extends EntityDisplayer {
private static final long serialVersionUID = 1L;
//The unique sprite of "Doty the Entity" (it is not animated)
int sprite_num; // le numéro d'image où on en est de l'animation
int sprite_height;
int sprite_width;
int nb_images[]=new int[Action.values().length];
final static int DEFAULT_SPRITE=1;
public FrostboltEntityDisplayer(Entity associatedEntity) {
super(associatedEntity);
sprite_num = 0;
sprite_height = 32;
sprite_width = 32;
nb_images[Action.WALK.ordinal()] = 2;
nb_images[Action.ATTACK.ordinal()] = 2;
nb_images[Action.HIT.ordinal()] = 2;
}
@Override
public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
Sprite sprite = SpriteStorage.getInstance().getFrostbolt();
Entity entity = getAssociatedEntity();
GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY());
//applying translation
GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(- sprite_width/2, - sprite_height/2);
int direction = entity.getDirection().ordinal();
int x_sprite=0;
int y_sprite = direction * sprite_height;
int nbSprites=DEFAULT_SPRITE;
for(Action act : Action.values()){
if(entity.hasAction(act)){
nbSprites=nb_images[act.ordinal()];
break;
}
}
sprite_num=(sprite_num+1)%(10*nbSprites);
for(int u=0; u<nbSprites; u++) {
if (sprite_num < 10*u) x_sprite = x_sprite + sprite_width;
}
Sprite res = new Sprite((sprite.getSpriteImage()).getSubimage(x_sprite,y_sprite,sprite_height,sprite_width));
return PositionedSprite.PositionSprite(res, spriteTopLeftGraphicsMapPoint);
}
public char getTermSprite(){
return 'C';
}
}
package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank;
import core.gamestate.Entity;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayer;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
import graphics.guiSkeleton.mapManagement.PositionedSprite;
import graphics.guiSkeleton.sprites.SpriteStorage;
import graphics.guiSkeleton.sprites.Sprite;
/**
* Created by dupriez on 14/11/15.
*
* An implementation of the entityDisplayer class for invisible objects