From 907ae78eec5d101735269625f9018b0a70b998d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Wed, 15 Jun 2022 16:49:33 +0200 Subject: [PATCH] finish to add enemy --- .../Battle/Fight/{enemi.csv => enemy.csv} | 0 .../Battle/Speech/{enemi.txt => enemy.txt} | 0 src/Entity/Enemy.java | 4 ++-- src/Main/PokeMudry.java | 23 +++++++++++++------ src/Screen/ScreenPlayer.java | 3 ++- src/Text/TextEnemy.java | 3 ++- 6 files changed, 22 insertions(+), 11 deletions(-) rename resources/Battle/Fight/{enemi.csv => enemy.csv} (100%) rename resources/Battle/Speech/{enemi.txt => enemy.txt} (100%) diff --git a/resources/Battle/Fight/enemi.csv b/resources/Battle/Fight/enemy.csv similarity index 100% rename from resources/Battle/Fight/enemi.csv rename to resources/Battle/Fight/enemy.csv diff --git a/resources/Battle/Speech/enemi.txt b/resources/Battle/Speech/enemy.txt similarity index 100% rename from resources/Battle/Speech/enemi.txt rename to resources/Battle/Speech/enemy.txt diff --git a/src/Entity/Enemy.java b/src/Entity/Enemy.java index 7deea2e..5467ead 100644 --- a/src/Entity/Enemy.java +++ b/src/Entity/Enemy.java @@ -8,13 +8,13 @@ public class Enemy extends Character{ - public Enemy(String name, int x, int y, String img, String map, int pv, String branch) { + public Enemy(String name, int x, int y, String img, String map, int pv, String branch, Character.Direction dir) { super(name, x, y, img, map); //generate his text this.map = map; - turn(Character.Direction.DOWN); + turn(dir); this.branch = branch; diff --git a/src/Main/PokeMudry.java b/src/Main/PokeMudry.java index ddf24bc..4c7003b 100644 --- a/src/Main/PokeMudry.java +++ b/src/Main/PokeMudry.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.Input; import Control.Controller; import Entity.Enemy; import Entity.Entity; +import Entity.Character.Direction; import Game.Battle; import Screen.ScreenBattle; import Screen.ScreenMap; @@ -45,8 +46,12 @@ public class PokeMudry extends PortableApplication { // add player, create and add all enemies in entities entities.add((Entity) sp.p); - enemies.add(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 25, "informatique")); - enemies.add(new Enemy("Mudry", 5, 11, "lumberjack_sheet32", "21N304", 25, "informatique")); + enemies.add(new Enemy("Mudry", 5, 11, "lumberjack_sheet32", "21N304", 25, "informatique", Direction.DOWN)); + enemies.add(new Enemy("Paciotti", 5, 11, "lumberjack_sheet32", "21N205", 0, "mecanique", Direction.DOWN)); + enemies.add(new Enemy("Gloeckner", 1, 7, "lumberjack_sheet32", "21N307", 0, "allemand", Direction.RIGHT)); + enemies.add(new Enemy("Bianchi", 1, 3, "lumberjack_sheet32", "23N308", 0, "electricite", Direction.RIGHT)); + enemies.add(new Enemy("Nicollier", 4, 2, "lumberjack_sheet32", "21N308", 0, "mathematique", Direction.LEFT)); + enemies.add(new Enemy("Ellert", 1, 4, "lumberjack_sheet32", "23N215", 0, "physique", Direction.RIGHT)); for (Enemy enemy : enemies) { entities.add(enemy); } @@ -65,11 +70,15 @@ public class PokeMudry extends PortableApplication { // Switch screen if (sp.p.onEnemy && onMapScreen){ sp.e = sp.p.lastEnemy; - sp.sb = sp.screenManager.getScreenBattle(); - if(sp.e == null) System.out.println("sdfsdfsdfsdf"); - - sp.b = new Battle(sp.e); - g.resetCamera(); + int pv = sp.e.getPv(); + + if (pv>0) { + sp.sb = sp.screenManager.getScreenBattle(); + sp.b = new Battle(sp.e); + g.resetCamera(); + } else { + sp.p.onEnemy = false; + } } if(onBattleScreen) sp.sb.manage(controller, sp.b); diff --git a/src/Screen/ScreenPlayer.java b/src/Screen/ScreenPlayer.java index 2090001..131d432 100644 --- a/src/Screen/ScreenPlayer.java +++ b/src/Screen/ScreenPlayer.java @@ -2,6 +2,7 @@ package Screen; import Entity.Enemy; import Entity.Player; +import Entity.Character.Direction; import Game.Battle; import ch.hevs.gdx2d.lib.GdxGraphics; @@ -19,7 +20,7 @@ public class ScreenPlayer { //p = new Player(8, 15, "desert"); p = new Player(4, 2, "21RI"); - b = new Battle(new Enemy("enemi", 0, 0, "lumberjack_sheet32", "desert", 50, "enemi")); + b = new Battle(new Enemy("enemy", 0, 0, "lumberjack_sheet32", "desert", 50, "enemy",Direction.NULL)); // Create both type of screen and record for reuse screenManager.registerScreen(ScreenMap.class); diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index eb43dd2..d276053 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -3,6 +3,7 @@ package Text; import java.util.Vector; import Entity.Enemy; +import Entity.Character.Direction; import java.util.Arrays; import java.util.Random; @@ -20,7 +21,7 @@ public class TextEnemy { public static void main(String[] args) { - TextEnemy t = new TextEnemy(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 25, "informatique")); + TextEnemy t = new TextEnemy(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 25, "informatique",Direction.NULL)); t.generateText();