mirror of
				https://github.com/Klagarge/PokeHES.git
				synced 2025-11-03 20:59:17 +00:00 
			
		
		
		
	@@ -10,6 +10,8 @@ import com.badlogic.gdx.Input;
 | 
				
			|||||||
import Control.Controller;
 | 
					import Control.Controller;
 | 
				
			||||||
import Entity.Enemy;
 | 
					import Entity.Enemy;
 | 
				
			||||||
import Entity.Entity;
 | 
					import Entity.Entity;
 | 
				
			||||||
 | 
					import Game.Battle;
 | 
				
			||||||
 | 
					import Screen.ScreenBattle;
 | 
				
			||||||
import Screen.ScreenMap;
 | 
					import Screen.ScreenMap;
 | 
				
			||||||
import Screen.ScreenPlayer;
 | 
					import Screen.ScreenPlayer;
 | 
				
			||||||
import ch.hevs.gdx2d.desktop.PortableApplication;
 | 
					import ch.hevs.gdx2d.desktop.PortableApplication;
 | 
				
			||||||
@@ -57,28 +59,29 @@ public class PokeMudry extends PortableApplication {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onGraphicRender(GdxGraphics g) {
 | 
					    public void onGraphicRender(GdxGraphics g) {
 | 
				
			||||||
        g.clear();
 | 
					        g.clear();
 | 
				
			||||||
		sp.p.manageEntity(sp.sm, controller);
 | 
					 | 
				
			||||||
        sp.sb.manage(controller);
 | 
					 | 
				
			||||||
        sp.render(g);
 | 
					 | 
				
			||||||
        //System.out.println(ScreenMap.class);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        boolean onMapScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class);
 | 
					        boolean onMapScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class);
 | 
				
			||||||
 | 
					        boolean onBattleScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenBattle.class);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
        if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
 | 
					        if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
 | 
				
			||||||
        sp.render(g);
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
		for (Entity entity : entities) {
 | 
					 | 
				
			||||||
            // Render only entities on the good map
 | 
					 | 
				
			||||||
            if (entity.getMap().equals(sp.sm.map) && onMapScreen)
 | 
					 | 
				
			||||||
                entity.graphicRender(g);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // Switch screen
 | 
					        // Switch screen
 | 
				
			||||||
        if (sp.p.frontOfEnemy && onMapScreen){
 | 
					        if (sp.p.frontOfEnemy && onMapScreen){
 | 
				
			||||||
            sp.e = sp.p.lastEnemy;
 | 
					            sp.e = sp.p.lastEnemy;
 | 
				
			||||||
            sp.screenManager.activateNextScreen();
 | 
					            //sp.screenManager.activateNextScreen();
 | 
				
			||||||
 | 
					            sp.sb = sp.screenManager.getScreenBattle();
 | 
				
			||||||
 | 
					            sp.b = new Battle(sp.e);
 | 
				
			||||||
            g.resetCamera();
 | 
					            g.resetCamera();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if(onBattleScreen) sp.sb.manage(controller, sp.b);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Graphics render
 | 
				
			||||||
 | 
					        sp.render(g);
 | 
				
			||||||
 | 
					        for (Entity entity : entities) {
 | 
				
			||||||
 | 
					            // Render only entities on the good map
 | 
				
			||||||
 | 
					            if (entity.getMap().equals(sp.sm.map) && onMapScreen)
 | 
				
			||||||
 | 
					            entity.graphicRender(g);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@ public class ScreenBattle extends RenderingScreen{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	private BitmapFont optimus40;
 | 
						private BitmapFont optimus40;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private Battle battle;
 | 
						private Battle b = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private Enemy enemy;
 | 
						private Enemy enemy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -38,7 +38,7 @@ public class ScreenBattle extends RenderingScreen{
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
	public void onInit() {
 | 
						public void onInit() {
 | 
				
			||||||
		//new battle game
 | 
							//new battle game
 | 
				
			||||||
		battle = new Battle(enemy);
 | 
							//battle = new Battle(enemy);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
        //display the question
 | 
					        //display the question
 | 
				
			||||||
		generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
 | 
							generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
 | 
				
			||||||
@@ -52,7 +52,7 @@ public class ScreenBattle extends RenderingScreen{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		displayDialog(g);
 | 
							displayDialog(g);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		System.out.println("render: " + battle.getLineSpeech());
 | 
							//System.out.println("render: " + battle.getLineSpeech());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -60,7 +60,13 @@ public class ScreenBattle extends RenderingScreen{
 | 
				
			|||||||
		optimus40.dispose();
 | 
							optimus40.dispose();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public void setBattle(Battle battle) {
 | 
				
			||||||
 | 
							this.b = battle;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void generateFont(String file, int height, Color c ){
 | 
						public void generateFont(String file, int height, Color c ){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Generate font with the file .ttf
 | 
							//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();
 | 
				
			||||||
@@ -77,7 +83,8 @@ public class ScreenBattle extends RenderingScreen{
 | 
				
			|||||||
		g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0);
 | 
							g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//dialog
 | 
							//dialog
 | 
				
			||||||
		g.drawString(15, 245 ,battle.getLine() , optimus40);
 | 
							
 | 
				
			||||||
 | 
							if(b != null) g.drawString(15, 245 ,b.getLine() , optimus40);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -95,7 +102,7 @@ public class ScreenBattle extends RenderingScreen{
 | 
				
			|||||||
		//TODO afficher le joueur                 
 | 
							//TODO afficher le joueur                 
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void manage(Controller c){
 | 
						public void manage(Controller c, Battle battle){
 | 
				
			||||||
		if(PokeMudry.front_montant){
 | 
							if(PokeMudry.front_montant){
 | 
				
			||||||
 	     	System.out.println("manage: " + battle.getLineSpeech());
 | 
					 	     	System.out.println("manage: " + battle.getLineSpeech());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,14 +2,16 @@ package Screen;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import Entity.Enemy;
 | 
					import Entity.Enemy;
 | 
				
			||||||
import Entity.Player;
 | 
					import Entity.Player;
 | 
				
			||||||
 | 
					import Game.Battle;
 | 
				
			||||||
import ch.hevs.gdx2d.lib.GdxGraphics;
 | 
					import ch.hevs.gdx2d.lib.GdxGraphics;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ScreenPlayer {
 | 
					public class ScreenPlayer {
 | 
				
			||||||
    public ManagerOfScreen screenManager = new ManagerOfScreen();
 | 
					    public ManagerOfScreen screenManager = new ManagerOfScreen();
 | 
				
			||||||
    public Player p;
 | 
					    public Player p = null;
 | 
				
			||||||
    public Enemy e;
 | 
					    public Enemy e = null;
 | 
				
			||||||
    public ScreenMap sm;
 | 
					    public Battle b = null;
 | 
				
			||||||
    public ScreenBattle sb;
 | 
					    public ScreenMap sm = null;
 | 
				
			||||||
 | 
					    public ScreenBattle sb = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void init(){
 | 
					    public void init(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -19,13 +21,18 @@ public class ScreenPlayer {
 | 
				
			|||||||
        // Create both type of screen and record for reuse
 | 
					        // Create both type of screen and record for reuse
 | 
				
			||||||
        screenManager.registerScreen(ScreenMap.class);
 | 
					        screenManager.registerScreen(ScreenMap.class);
 | 
				
			||||||
        screenManager.registerScreen(ScreenBattle.class);
 | 
					        screenManager.registerScreen(ScreenBattle.class);
 | 
				
			||||||
        sb = screenManager.getScreenBattle();
 | 
					 | 
				
			||||||
        sm = screenManager.getScreenMap();
 | 
					        sm = screenManager.getScreenMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void render(GdxGraphics g){
 | 
					    public void render(GdxGraphics g){
 | 
				
			||||||
        sb.setEnemy(e);
 | 
					 | 
				
			||||||
        sm.setPlayer(p);
 | 
					        sm.setPlayer(p);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if(sb != null){
 | 
				
			||||||
 | 
					            sb.setEnemy(e);
 | 
				
			||||||
 | 
					            sb.setBattle(b);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        screenManager.render(g);
 | 
					        screenManager.render(g);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user