1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-23 09:53:28 +00:00

dialog ok

This commit is contained in:
Fastium 2022-06-10 19:33:24 +02:00
parent 4c47120c40
commit 0fe608e183
10 changed files with 149 additions and 69 deletions

View File

@ -1,7 +1,7 @@
attaque,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,1 attaque1,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,1
df,sdfs,dfs,df,sdf,10 attaque2,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,10
sdf,sdf,sd,sdf,sdfs,3 attaque3,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,3
sdf,sdf,fsd,sdf,dfs,45 attaque4,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,45
sd,fsdf,fsd,f,dfsd,4 attaque5,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,4
sdfsf,df,sdf,sdf,fsdf,6 attaque6,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,6
sdf,sdf,sdf,sdfs,df,3 attaque7,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,3

1 attaque attaque1 contre-attaque 1 contre-attaque 2 contre-attaque 3 contre-attaque 4 1
2 df attaque2 sdfs contre-attaque 1 dfs contre-attaque 2 df contre-attaque 3 sdf contre-attaque 4 10
3 sdf attaque3 sdf contre-attaque 1 sd contre-attaque 2 sdf contre-attaque 3 sdfs contre-attaque 4 3
4 sdf attaque4 sdf contre-attaque 1 fsd contre-attaque 2 sdf contre-attaque 3 dfs contre-attaque 4 45
5 sd attaque5 fsdf contre-attaque 1 fsd contre-attaque 2 f contre-attaque 3 dfsd contre-attaque 4 4
6 sdfsf attaque6 df contre-attaque 1 sdf contre-attaque 2 sdf contre-attaque 3 fsdf contre-attaque 4 6
7 sdf attaque7 sdf contre-attaque 1 sdf contre-attaque 2 sdfs contre-attaque 3 df contre-attaque 4 3

View File

@ -1,7 +1,7 @@
introduction text introduction text
attack 1 attack 1 :
attack 2 attack 2 :
attack 3 attack 3 :
attack 4 attack 4 :
death death
win win

View File

@ -2,18 +2,15 @@ package Entity;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import Text.TextEnemy;
public class Enemy extends Character{ public class Enemy extends Character{
private String map; private String map;
public TextEnemy textEnemy;
public Enemy(String name, int x, int y, String img, String map) { public Enemy(String name, int x, int y, String img, String map) {
super(name, x, y, img); super(name, x, y, img);
//generate his text //generate his text
this.textEnemy = new TextEnemy("enemi"); //TODO should be name
textEnemy.generateText();
this.map = map; this.map = map;
turn(Character.Direction.DOWN); turn(Character.Direction.DOWN);

12
src/Game/Battle.java Normal file
View File

@ -0,0 +1,12 @@
package Game;
public class Battle {
//TODO faire la logique du combat :$
/*
* les points
* réponses juste
* barre de vie
*/
}

View File

@ -1,9 +1,8 @@
package Screen; package Screen;
import Main.Settings;
import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.components.screen_management.RenderingScreen;
import ch.hevs.gdx2d.lib.GdxGraphics; import ch.hevs.gdx2d.lib.GdxGraphics;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
@ -11,9 +10,15 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.utils.Align;
import Control.Controller; import Control.Controller;
import Entity.Enemy; import Entity.Enemy;
import Entity.Player;
import Text.Line;
import Text.TextEnemy;
import Main.Settings;
public class ScreenBattle extends RenderingScreen{ public class ScreenBattle extends RenderingScreen{
@ -21,35 +26,49 @@ public class ScreenBattle extends RenderingScreen{
private static int HEIGHT_DIALOG = Settings.SIDE / 3; private static int HEIGHT_DIALOG = Settings.SIDE / 3;
private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE; private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE;
private boolean attackOn;
private int numAttack =0;
private BitmapFont optimus40; private BitmapFont optimus40;
private TextEnemy textEnemy;
private int lineSpeech = 0;
private String lineDialog = "";
private int answer = 0;
@Override @Override
public void onInit() { public void onInit() {
//display the question textEnemy = new TextEnemy("enemi");
generateFont("resources//font//OptimusPrinceps.ttf", optimus40, 20, Color.BLACK); textEnemy.generateText();
//display the question
generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
//initialize the first line
readNextLine();
} }
@Override @Override
public void onGraphicRender(GdxGraphics g) { public void onGraphicRender(GdxGraphics g) {
g.clear(Color.BLACK); g.clear(Color.BLACK);
g.drawStringCentered(g.getScreenHeight()/2, "attack", optimus40);
g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0); displayDialog(g);
} }
@Override @Override
public void dispose() { public void dispose() {
optimus40.dispose(); optimus40.dispose();
} }
public void generateFont(String file, BitmapFont bitmapFont, int height, Color c ){ public void generateFont(String file, int height, Color c ){
//Generate font with the file .ttf
FileHandle fileHandle = Gdx.files.internal(file); FileHandle fileHandle = Gdx.files.internal(file);
FreeTypeFontParameter parameter = new FreeTypeFontParameter(); FreeTypeFontParameter parameter = new FreeTypeFontParameter();
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
@ -60,23 +79,63 @@ public class ScreenBattle extends RenderingScreen{
} }
public void displayEnemy(Enemy e){ public void displayDialog(GdxGraphics g){
// stock his speech //dialog background
g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, 1600, HEIGHT_DIALOG, 0);
//display the person //dialog
g.drawString(15, 245 ,lineDialog , optimus40);
}
public void displayPlayer(Player p){
//TODO afficher le joueur
}
public void displayEnemy(Enemy e){
//TODO display the person
} }
public void readNextLine(){ public void readNextLine(){
//display the speech //display the speech and change line
lineDialog = textEnemy.lines.get(lineSpeech).line;
lineSpeech++;
} }
public void manage(Controller c){ public void manage(Controller c){
if (c.keyStatus.get(Input.Keys.SPACE)){ if (c.keyStatus.get(Input.Keys.SPACE)){
if(textEnemy.lines.get(lineSpeech).attackOn == false){
readNextLine(); readNextLine();
} }
} }
if (c.keyStatus.get(Input.Keys.NUM_1)){
if(textEnemy.lines.get(lineSpeech).attackOn == true){
readNextLine();
answer = 1;
}
}
if (c.keyStatus.get(Input.Keys.NUM_2)){
if(textEnemy.lines.get(lineSpeech).attackOn == true){
readNextLine();
answer = 2;
}
}
if (c.keyStatus.get(Input.Keys.NUM_3)){
if(textEnemy.lines.get(lineSpeech).attackOn == true){
readNextLine();
answer = 3;
}
}
if (c.keyStatus.get(Input.Keys.NUM_4)){
if(textEnemy.lines.get(lineSpeech).attackOn == false){
readNextLine();
answer = 4;
}
}
}

View File

@ -11,16 +11,6 @@ public class FightData {
private File file; private File file;
private static final String REGEX = ","; private static final String REGEX = ",";
/*
public static void main(String[] args) {
FightData d = new FightData("enemi");
d.readFile();
for(Attack a : d.attacks){
System.out.println(a);
}
}
*/
public FightData(String name) { public FightData(String name) {
file = new File("./resources/Battle/Fight/" + name + ".csv"); file = new File("./resources/Battle/Fight/" + name + ".csv");
} }
@ -46,6 +36,9 @@ public class FightData {
e.printStackTrace(); e.printStackTrace();
} }
} }
//return the vector with all attaks of one enemi //return the vector with all attaks of one enemi

12
src/Text/Line.java Normal file
View File

@ -0,0 +1,12 @@
package Text;
public class Line {
public String line;
public boolean attackOn;
Line( String line, boolean attackOn){
this.line = line;
this.attackOn = attackOn;
}
}

View File

@ -12,7 +12,7 @@ public class SpeechData {
public SpeechData(String name){ public SpeechData(String name){
file = new File("./resources/Battle/Fight/" + name + ".csv"); file = new File("./resources/Battle/Speech/" + name + ".txt");
} }
public void readFile() { public void readFile() {

View File

@ -6,7 +6,16 @@ public class TextEnemy {
public FightData fightData; public FightData fightData;
public SpeechData speechData; public SpeechData speechData;
Vector<Line> line = new Vector<Line>(); public Vector<Line> lines = new Vector<Line>();
public static void main(String[] args) {
TextEnemy t = new TextEnemy("enemi");
t.generateText();
for(Line l : t.lines) {
System.out.println(l.line);
}
}
public TextEnemy(String name){ public TextEnemy(String name){
//generate the vector of fight //generate the vector of fight
@ -20,13 +29,12 @@ public class TextEnemy {
} }
public void generateText(){ public void generateText(){
int i =0; int i =1;
//introduction line //introduction line
line.add(new Line(speechData.getSpeechs(i++), false)); lines.add(new Line(speechData.getSpeechs(0), false));
for(int j=0; j<4;j++){
for(int j=0; i<4;i++){
//attack and answer (number on vector : 1-4) //attack and answer (number on vector : 1-4)
line.add(new Line( lines.add(new Line(
speechData.getSpeechs(i++) + fightData.getAttack(j).attack + "? ("+fightData.getAttack(j).xp+ ") " + "\n" + speechData.getSpeechs(i++) + fightData.getAttack(j).attack + "? ("+fightData.getAttack(j).xp+ ") " + "\n" +
fightData.getAttack(j).answer1 + "\n" + fightData.getAttack(j).answer1 + "\n" +
fightData.getAttack(j).answer2 + "\n" + fightData.getAttack(j).answer2 + "\n" +
@ -35,18 +43,10 @@ public class TextEnemy {
// TODO mélanger les attaques aléatoirement // TODO mélanger les attaques aléatoirement
} }
//finish (win and death) //finish (win and death)
line.add(new Line(speechData.getSpeechs(i++), false)); lines.add(new Line(speechData.getSpeechs(5), false));
line.add(new Line(speechData.getSpeechs(i++), false)); lines.add(new Line(speechData.getSpeechs(6), false));
} }
} }
class Line {
String line;
boolean attackOn;
Line( String line, boolean attackOn){
this.line = line;
this.attackOn = attackOn;
}
}

View File

@ -36,6 +36,13 @@ public class testYann extends PortableApplication{
@Override @Override
public void onGraphicRender(GdxGraphics g) { public void onGraphicRender(GdxGraphics g) {
s.render(g); s.render(g);
((ScreenBattle) s.getActiveScreen()).manage(controller);
}
@Override
public void onDispose() {
// TODO Auto-generated method stub
super.onDispose();
} }
@Override @Override