feat: creation de l'actor objectif gestion des objectifs. avancement de l'interface

This commit is contained in:
Nicolas Hordé 2015-06-19 03:08:07 +02:00
parent 7c67731fc8
commit 77f1ff4659
5 changed files with 104 additions and 14 deletions

View File

@ -19,7 +19,6 @@ public class ButtonLevel extends ImageTextButton {
public Level level; public Level level;
public boolean Activated; public boolean Activated;
TextureRegion Finalled,Locked; TextureRegion Finalled,Locked;
private Color[] Levelcolors={AssetLoader.Skin_level.getColor("world1"),AssetLoader.Skin_level.getColor("world2"),AssetLoader.Skin_level.getColor("world3"),AssetLoader.Skin_level.getColor("world4"),AssetLoader.Skin_level.getColor("world5")};
Label Thelabel; Label Thelabel;
public ButtonLevel(Level level, boolean Activated) { public ButtonLevel(Level level, boolean Activated) {
@ -41,7 +40,7 @@ public class ButtonLevel extends ImageTextButton {
} }
public Color getLevelcolor() { public Color getLevelcolor() {
return Levelcolors[level.aWorld]; return AssetLoader.Levelcolors[level.aWorld];
} }
@Override @Override

View File

@ -25,12 +25,14 @@ import com.badlogic.gdx.utils.viewport.StretchViewport;
public class AssetLoader { public class AssetLoader {
public static Skin Skin_level; public static Skin Skin_level;
public static TextureAtlas Atlas_level; public static TextureAtlas Atlas_level;
public static TextureAtlas Atlas_game;
public static Texture Texture_fond; public static Texture Texture_fond;
public static Texture Texture_fond2; public static Texture Texture_fond2;
public static Texture Texture_logo; public static Texture Texture_logo;
public static Sound intro; public static Sound intro;
public static int width; public static int width;
public static Color[] Levelcolors;
public static Color[] Typecolors;
public static String[] Typenames;
public static int height; public static int height;
public static float ratio; public static float ratio;
public static boolean stretch=false; public static boolean stretch=false;
@ -73,7 +75,19 @@ public class AssetLoader {
addstyle(Atlas_level,"arrows"); addstyle(Atlas_level,"arrows");
addstyle(Atlas_level,"arrows2"); addstyle(Atlas_level,"arrows2");
addstyle(Atlas_level,"exit2"); addstyle(Atlas_level,"exit2");
addstyle(Atlas_level,"cout");
addstyle(Atlas_level,"tech");
addstyle(Atlas_level,"cycle");
addstyle(Atlas_level,"temp");
addstyle(Atlas_level,"nrj");
addstyle(Atlas_level,"rayon");
Skin_level = new Skin(Gdx.files.internal("textures/level.json"),Atlas_level); Skin_level = new Skin(Gdx.files.internal("textures/level.json"),Atlas_level);
Levelcolors=new Color[5];
Levelcolors=new Color[]{AssetLoader.Skin_level.getColor("world1"),AssetLoader.Skin_level.getColor("world2"),AssetLoader.Skin_level.getColor("world3"),AssetLoader.Skin_level.getColor("world4"),AssetLoader.Skin_level.getColor("world5")};
Typecolors=new Color[13];
Typecolors=new Color[]{new Color(0,0,1f,1),new Color(0,0.6f,0,1),new Color(0.196f,0.803f,0.196f,1),new Color(0.5f,0.5f,0.5f,1),new Color(0.8f,0.8f,0.8f,1),new Color(0.6f,0,0,1),new Color(1f,0,0,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0.294f,0.466f,0.615f,1),new Color(0.478f,0.192f,0.098f,1)};
Typenames=new String[13];
Typenames=new String[]{"E-","e-","Ph","e0","E0","e+","E+","K","L","M","N","n","p"};
} }
public static int setpref() { public static int setpref() {

View File

@ -38,8 +38,8 @@ public class main extends Game {
} }
public void debug() { public void debug() {
AssetLoader.prefs.putInteger("ResolutionX", 1024); AssetLoader.prefs.putInteger("ResolutionX", 1280);
AssetLoader.prefs.putInteger("ResolutionY", 768); AssetLoader.prefs.putInteger("ResolutionY", 720);
AssetLoader.prefs.putBoolean("Fullscreen", false); AssetLoader.prefs.putBoolean("Fullscreen", false);
AssetLoader.prefs.putBoolean("VSync", false); AssetLoader.prefs.putBoolean("VSync", false);
AssetLoader.prefs.putInteger("log", Gdx.app.LOG_DEBUG); AssetLoader.prefs.putInteger("log", Gdx.app.LOG_DEBUG);

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
@ -22,6 +23,7 @@ import com.badlogic.gdx.utils.viewport.StretchViewport;
import fr.evolving.worlds.LevelRenderer; import fr.evolving.worlds.LevelRenderer;
import fr.evolving.UI.ButtonLevel; import fr.evolving.UI.ButtonLevel;
import fr.evolving.UI.Objectives;
import fr.evolving.inputs.InputHandler; import fr.evolving.inputs.InputHandler;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
@ -39,12 +41,16 @@ public class LevelScreen implements Screen {
private TimerTask ScrollTask; private TimerTask ScrollTask;
private Stage stage; private Stage stage;
private Table table; private Table table;
private ImageButton Previous,Next,Exit,cout,tech; private ImageButton Previous,Next,Exit;
private ImageTextButton cout,tech,cycle,temp,rayon,nrj;
private TextButton buttonPlay,buttonExit; private TextButton buttonPlay,buttonExit;
private Level[] thelevels; private Level[] thelevels;
private TextArea TextDescriptive; private TextArea TextDescriptive;
public int World;
Objectives Victory;
public LevelScreen() { public LevelScreen() {
this.World=0;
Gdx.app.debug(getClass().getSimpleName(),"Création des boutons."); Gdx.app.debug(getClass().getSimpleName(),"Création des boutons.");
stage = new Stage(AssetLoader.viewport); stage = new Stage(AssetLoader.viewport);
table = new Table(); table = new Table();
@ -57,7 +63,51 @@ public class LevelScreen implements Screen {
buttonLevels[i].addListener(new ClickListener(){ buttonLevels[i].addListener(new ClickListener(){
@Override @Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
TextDescriptive.setText(((ButtonLevel)event.getListenerActor()).level.Description); ButtonLevel button = (ButtonLevel)event.getListenerActor();
System.out.println(button.getBackground());
TextDescriptive.setText(button.level.Description);
if (button.level.Maxcycle<99999 && button.level.Maxcycle>0) {
cycle.setText(String.valueOf(button.level.Maxcycle));
cycle.setVisible(true);
}
else
cycle.setVisible(false);
if (button.level.Maxtemp<99999 && button.level.Maxtemp>0) {
temp.setText(String.valueOf(button.level.Maxtemp));
temp.setVisible(true);
}
else
temp.setVisible(false);
if (button.level.Maxnrj<99999 && button.level.Maxnrj>0) {
nrj.setText(String.valueOf(button.level.Maxnrj));
nrj.setVisible(true);
}
else
nrj.setVisible(false);
if (button.level.Maxrayon<99999 && button.level.Maxrayon>0) {
rayon.setText(String.valueOf(button.level.Maxrayon));
rayon.setVisible(true);
}
else
rayon.setVisible(false);
if (button.level.Cout>0) {
cout.setText(String.valueOf(button.level.Cout));
cout.setVisible(true);
}
else
cout.setVisible(false);
if (button.level.Tech>=0) {
tech.setText(String.valueOf(button.level.Tech));
tech.setVisible(true);
}
else
tech.setVisible(false);
Victory.setVictory(button.level.Victory);
}
public void leave(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel button = (ButtonLevel)event.getListenerActor();
button.setBackground("leveler"+String.valueOf(World)+"_over");
} }
}); });
} }
@ -72,7 +122,7 @@ public class LevelScreen implements Screen {
}; };
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30); ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif"); TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif");
TextDescriptive.setBounds(15, 15, 1009, 130); TextDescriptive.setBounds(15, 15, 1185, 100);
buttonPlay = new TextButton("Connexions", AssetLoader.Skin_level,"Bouton"); buttonPlay = new TextButton("Connexions", AssetLoader.Skin_level,"Bouton");
buttonPlay.setPosition(1500, AssetLoader.height-40); buttonPlay.setPosition(1500, AssetLoader.height-40);
buttonExit = new TextButton("Statistiques", AssetLoader.Skin_level,"Bouton"); buttonExit = new TextButton("Statistiques", AssetLoader.Skin_level,"Bouton");
@ -89,10 +139,21 @@ public class LevelScreen implements Screen {
Next.setPosition(1030, 170); Next.setPosition(1030, 170);
Previous=new ImageButton(AssetLoader.Skin_level,"Previous"); Previous=new ImageButton(AssetLoader.Skin_level,"Previous");
Previous.setPosition(1110, 170); Previous.setPosition(1110, 170);
cout=new ImageButton(AssetLoader.Skin_level,"cout"); cout=new ImageTextButton("5",AssetLoader.Skin_level,"cout");
cout.setPosition(1250, 50); cout.setPosition(1250, 48);
tech=new ImageButton(AssetLoader.Skin_level,"tech"); tech=new ImageTextButton("10",AssetLoader.Skin_level,"tech");
tech.setPosition(1370, 50); tech.setPosition(1365, 48);
temp=new ImageTextButton("10",AssetLoader.Skin_level,"temp");
temp.setPosition(1365, 360);
cycle=new ImageTextButton("10",AssetLoader.Skin_level,"cycle");
cycle.setPosition(1250, 360);
nrj=new ImageTextButton("10",AssetLoader.Skin_level,"nrj");
nrj.setPosition(1365, 490);
rayon=new ImageTextButton("10",AssetLoader.Skin_level,"rayon");
rayon.setPosition(1250, 490);
Victory=new Objectives();
Victory.setVictory(new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
Victory.setPosition(1216, 185);
} }
@Override @Override
@ -125,6 +186,11 @@ public class LevelScreen implements Screen {
stage.addActor(Previous); stage.addActor(Previous);
stage.addActor(cout); stage.addActor(cout);
stage.addActor(tech); stage.addActor(tech);
stage.addActor(cycle);
stage.addActor(nrj);
stage.addActor(temp);
stage.addActor(rayon);
stage.addActor(Victory);
Gdx.input.setInputProcessor(stage); Gdx.input.setInputProcessor(stage);
} }

View File

@ -8,11 +8,13 @@ import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation; import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import fr.evolving.UI.Objectives;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
import fr.evolving.effects.Laser; import fr.evolving.effects.Laser;
import fr.evolving.inputs.InputHandler; import fr.evolving.inputs.InputHandler;
@ -30,6 +32,7 @@ public class LevelRenderer {
Laser Laser; Laser Laser;
TextureRegion Texture_logobig; TextureRegion Texture_logobig;
TextureRegion Texture_logosmall; TextureRegion Texture_logosmall;
BitmapFont font;
public LevelRenderer(LevelScreen LevelScreen) { public LevelRenderer(LevelScreen LevelScreen) {
this.LevelScreen=LevelScreen; this.LevelScreen=LevelScreen;
@ -42,6 +45,8 @@ public class LevelRenderer {
shapeRenderer = new ShapeRenderer(); shapeRenderer = new ShapeRenderer();
Laser=new Laser(); Laser=new Laser();
AssetLoader.viewport.apply(); AssetLoader.viewport.apply();
font=AssetLoader.Skin_level.getFont("OpenDyslexicAlta-22");
font.setColor(AssetLoader.Levelcolors[LevelScreen.World]);
} }
public void evolve() { public void evolve() {
@ -82,6 +87,12 @@ public class LevelRenderer {
Texture_logosmall=AssetLoader.Skin_level.getRegion("logo2"); Texture_logosmall=AssetLoader.Skin_level.getRegion("logo2");
batcher2.draw(Texture_logosmall,20, AssetLoader.height-Texture_logobig.getRegionHeight()+Texture_logosmall.getRegionHeight()/2); batcher2.draw(Texture_logosmall,20, AssetLoader.height-Texture_logobig.getRegionHeight()+Texture_logosmall.getRegionHeight()/2);
batcher2.draw(Texture_logobig,120, AssetLoader.height-Texture_logobig.getRegionHeight()); batcher2.draw(Texture_logobig,120, AssetLoader.height-Texture_logobig.getRegionHeight());
font.draw(batcher2, "Ressources", 1215, 145);
font.draw(batcher2, "Descriptif", 15, 145);
font.draw(batcher2, "Récompenses", 1215, AssetLoader.height-15);
font.draw(batcher2, "Objectifs", 1215, 295);
font.draw(batcher2, "Handicaps", 1215, 605);
font.draw(batcher2, "", 1215, 145);
batcher2.end(); batcher2.end();
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL20.GL_BLEND);
@ -92,8 +103,8 @@ public class LevelRenderer {
shapeRenderer.rect(1210, 10, 250, 140); shapeRenderer.rect(1210, 10, 250, 140);
shapeRenderer.rect(1210, 160,250, 140); shapeRenderer.rect(1210, 160,250, 140);
shapeRenderer.rect(1210, 310,250, 300); shapeRenderer.rect(1210, 310,250, 300);
shapeRenderer.rect(1210, 620,250, AssetLoader.height-620); shapeRenderer.rect(1210, 620,250, AssetLoader.height-630);
shapeRenderer.rect(1470, 10, 440, AssetLoader.height-10); shapeRenderer.rect(1470, 10, 440, AssetLoader.height-20);
shapeRenderer.end(); shapeRenderer.end();
for (int i=0;i<LevelScreen.buttonLevels.length;i++) { for (int i=0;i<LevelScreen.buttonLevels.length;i++) {