mirror of
				https://github.com/Klagarge/PokeHES.git
				synced 2025-11-03 20:59:17 +00:00 
			
		
		
		
	dialog ok
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
attaque,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,1
 | 
			
		||||
df,sdfs,dfs,df,sdf,10
 | 
			
		||||
sdf,sdf,sd,sdf,sdfs,3
 | 
			
		||||
sdf,sdf,fsd,sdf,dfs,45
 | 
			
		||||
sd,fsdf,fsd,f,dfsd,4
 | 
			
		||||
sdfsf,df,sdf,sdf,fsdf,6
 | 
			
		||||
sdf,sdf,sdf,sdfs,df,3
 | 
			
		||||
attaque1,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,1
 | 
			
		||||
attaque2,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,10
 | 
			
		||||
attaque3,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,3
 | 
			
		||||
attaque4,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,45
 | 
			
		||||
attaque5,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,4
 | 
			
		||||
attaque6,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,6
 | 
			
		||||
attaque7,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,3
 | 
			
		||||
 
 | 
			
		||||
		
		
			
  | 
@@ -1,7 +1,7 @@
 | 
			
		||||
introduction text
 | 
			
		||||
attack 1
 | 
			
		||||
attack 2
 | 
			
		||||
attack 3
 | 
			
		||||
attack 4
 | 
			
		||||
attack 1 : 
 | 
			
		||||
attack 2 : 
 | 
			
		||||
attack 3 :
 | 
			
		||||
attack 4 :
 | 
			
		||||
death
 | 
			
		||||
win
 | 
			
		||||
@@ -1,19 +1,16 @@
 | 
			
		||||
package Entity;
 | 
			
		||||
 | 
			
		||||
import com.badlogic.gdx.math.Vector2;
 | 
			
		||||
 | 
			
		||||
import Text.TextEnemy;
 | 
			
		||||
import com.badlogic.gdx.math.Vector2; 
 | 
			
		||||
 | 
			
		||||
public class Enemy extends Character{
 | 
			
		||||
    private String map;
 | 
			
		||||
 | 
			
		||||
    public TextEnemy textEnemy;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public Enemy(String name, int x, int y, String img, String map) {
 | 
			
		||||
        super(name, x, y, img);
 | 
			
		||||
        //generate his text
 | 
			
		||||
        this.textEnemy = new TextEnemy("enemi"); //TODO should be name
 | 
			
		||||
        textEnemy.generateText();
 | 
			
		||||
 | 
			
		||||
        this.map = map;
 | 
			
		||||
 | 
			
		||||
        turn(Character.Direction.DOWN);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								src/Game/Battle.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/Game/Battle.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
package Game;
 | 
			
		||||
 | 
			
		||||
public class Battle {
 | 
			
		||||
 | 
			
		||||
    //TODO faire la logique du combat :$
 | 
			
		||||
    /*
 | 
			
		||||
     * les points
 | 
			
		||||
     * réponses juste 
 | 
			
		||||
     * barre de vie
 | 
			
		||||
     */
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +1,8 @@
 | 
			
		||||
package Screen;
 | 
			
		||||
 | 
			
		||||
import Main.Settings;
 | 
			
		||||
 | 
			
		||||
import ch.hevs.gdx2d.components.screen_management.RenderingScreen;
 | 
			
		||||
import ch.hevs.gdx2d.lib.GdxGraphics;
 | 
			
		||||
 | 
			
		||||
import com.badlogic.gdx.Gdx;
 | 
			
		||||
import com.badlogic.gdx.Input;
 | 
			
		||||
import com.badlogic.gdx.files.FileHandle;
 | 
			
		||||
@@ -11,45 +10,65 @@ import com.badlogic.gdx.graphics.Color;
 | 
			
		||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
 | 
			
		||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
 | 
			
		||||
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 Entity.Enemy;
 | 
			
		||||
import Entity.Player;
 | 
			
		||||
import Text.Line;
 | 
			
		||||
import Text.TextEnemy;
 | 
			
		||||
import Main.Settings;
 | 
			
		||||
 | 
			
		||||
public class ScreenBattle extends RenderingScreen{
 | 
			
		||||
 | 
			
		||||
	private static int EDGE = 10;
 | 
			
		||||
	private static int HEIGHT_DIALOG = Settings.SIDE / 3;
 | 
			
		||||
	private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE;
 | 
			
		||||
	
 | 
			
		||||
	private boolean attackOn;
 | 
			
		||||
	private int numAttack =0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	private BitmapFont optimus40;
 | 
			
		||||
 | 
			
		||||
	private TextEnemy textEnemy;
 | 
			
		||||
	private int lineSpeech = 0;
 | 
			
		||||
	private String lineDialog = "";
 | 
			
		||||
 | 
			
		||||
	private int answer  = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
	public void onInit() {
 | 
			
		||||
 | 
			
		||||
        //display the question
 | 
			
		||||
		generateFont("resources//font//OptimusPrinceps.ttf", optimus40, 20, Color.BLACK);
 | 
			
		||||
		textEnemy = new TextEnemy("enemi");
 | 
			
		||||
		textEnemy.generateText();
 | 
			
		||||
 | 
			
		||||
        //display the question
 | 
			
		||||
		generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		//initialize the first line
 | 
			
		||||
		readNextLine();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void onGraphicRender(GdxGraphics g) {
 | 
			
		||||
		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
 | 
			
		||||
	public void 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);
 | 
			
		||||
		FreeTypeFontParameter parameter = new FreeTypeFontParameter();
 | 
			
		||||
        FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
 | 
			
		||||
@@ -60,22 +79,62 @@ public class ScreenBattle extends RenderingScreen{
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void displayEnemy(Enemy e){
 | 
			
		||||
		// stock his speech
 | 
			
		||||
	public void displayDialog(GdxGraphics g){
 | 
			
		||||
		//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(){
 | 
			
		||||
		//display the speech
 | 
			
		||||
		
 | 
			
		||||
		//display the speech and change line
 | 
			
		||||
		lineDialog = textEnemy.lines.get(lineSpeech).line;
 | 
			
		||||
		lineSpeech++;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void manage(Controller c){
 | 
			
		||||
		if (c.keyStatus.get(Input.Keys.SPACE)){
 | 
			
		||||
			readNextLine();
 | 
			
		||||
			if(textEnemy.lines.get(lineSpeech).attackOn == false){
 | 
			
		||||
				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;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,16 +11,6 @@ public class FightData {
 | 
			
		||||
    private  File file;
 | 
			
		||||
    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) {
 | 
			
		||||
        file = new File("./resources/Battle/Fight/" + name + ".csv");
 | 
			
		||||
    }
 | 
			
		||||
@@ -42,9 +32,12 @@ public class FightData {
 | 
			
		||||
 | 
			
		||||
            bf.close();
 | 
			
		||||
 | 
			
		||||
          } catch (Exception e) {
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
     
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								src/Text/Line.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/Text/Line.java
									
									
									
									
									
										Normal 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;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@@ -12,7 +12,7 @@ public class SpeechData {
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public SpeechData(String name){
 | 
			
		||||
        file = new File("./resources/Battle/Fight/" + name + ".csv");
 | 
			
		||||
        file = new File("./resources/Battle/Speech/" + name + ".txt");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void readFile() {
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,16 @@ public class TextEnemy {
 | 
			
		||||
    public FightData fightData;
 | 
			
		||||
    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){
 | 
			
		||||
        //generate the vector of fight
 | 
			
		||||
@@ -20,33 +29,24 @@ public class TextEnemy {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void generateText(){
 | 
			
		||||
        int i =0;
 | 
			
		||||
        int i =1;
 | 
			
		||||
        //introduction line
 | 
			
		||||
        line.add(new Line(speechData.getSpeechs(i++), false));
 | 
			
		||||
 | 
			
		||||
        for(int j=0; i<4;i++){
 | 
			
		||||
        lines.add(new Line(speechData.getSpeechs(0), false));
 | 
			
		||||
        for(int j=0; j<4;j++){
 | 
			
		||||
        //attack and answer (number on vector : 1-4) 
 | 
			
		||||
            line.add(new Line(
 | 
			
		||||
            speechData.getSpeechs(i++) + fightData.getAttack(j).attack + "?  ("+fightData.getAttack(j).xp+ ") " + "\n" +
 | 
			
		||||
            fightData.getAttack(j).answer1 + "\n" +
 | 
			
		||||
            fightData.getAttack(j).answer2 + "\n" + 
 | 
			
		||||
            fightData.getAttack(j).answer3 + "\n" + 
 | 
			
		||||
            fightData.getAttack(j).answer4, true ));
 | 
			
		||||
            lines.add(new Line(
 | 
			
		||||
                speechData.getSpeechs(i++) + fightData.getAttack(j).attack + "?  ("+fightData.getAttack(j).xp+ ") " + "\n" +
 | 
			
		||||
                fightData.getAttack(j).answer1 + "\n" +
 | 
			
		||||
                fightData.getAttack(j).answer2 + "\n" + 
 | 
			
		||||
                fightData.getAttack(j).answer3 + "\n" + 
 | 
			
		||||
                fightData.getAttack(j).answer4, true));
 | 
			
		||||
            // TODO mélanger les attaques aléatoirement
 | 
			
		||||
        }
 | 
			
		||||
        //finish (win and death)
 | 
			
		||||
        line.add(new Line(speechData.getSpeechs(i++), false));
 | 
			
		||||
        line.add(new Line(speechData.getSpeechs(i++), false));
 | 
			
		||||
        lines.add(new Line(speechData.getSpeechs(5), 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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ public class testYann extends PortableApplication{
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    testYann(){
 | 
			
		||||
		super(800, 800);
 | 
			
		||||
		super( 800, 800);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -36,6 +36,13 @@ public class testYann extends PortableApplication{
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onGraphicRender(GdxGraphics g) {
 | 
			
		||||
        s.render(g);
 | 
			
		||||
        ((ScreenBattle) s.getActiveScreen()).manage(controller);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onDispose() {
 | 
			
		||||
        // TODO Auto-generated method stub
 | 
			
		||||
        super.onDispose();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user