feat: ajout de la gestion de l'upgrade et du déblocage.

This commit is contained in:
Nicolas Hordé 2016-06-17 11:41:54 +02:00
parent f2f11a4bfe
commit b743bd62cc
6 changed files with 107 additions and 21 deletions

View File

@ -69,8 +69,13 @@ public class Translist extends Actor{
public void setTransmuters(Array<Transmuter> transmuters) { public void setTransmuters(Array<Transmuter> transmuters) {
this.transmuters=transmuters; this.transmuters=transmuters;
whereis=0; whereis=0;
assignTransmuter(whereis); if (transmuters!=null && transmuters.size>0)
assignTransmuter(whereis);
}
public Array<Transmuter> getTransmuters() {
return this.transmuters;
} }
public void assignTransmuter(int where) { public void assignTransmuter(int where) {
@ -116,7 +121,8 @@ public class Translist extends Actor{
} }
public void redraw() { public void redraw() {
Selected.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight()); if (Selected!=null)
Selected.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight());
table.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight()); table.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight());
table.clear(); table.clear();
table.add(Previous).left().pad(this.getWidth()/4).padTop(this.getHeight()).size(this.getWidth()/512*64, this.getHeight()/512*64); table.add(Previous).left().pad(this.getWidth()/4).padTop(this.getHeight()).size(this.getWidth()/512*64, this.getHeight()/512*64);
@ -154,7 +160,8 @@ public class Translist extends Actor{
@Override @Override
public void draw(Batch batch, float parentAlpha) { public void draw(Batch batch, float parentAlpha) {
Selected.draw(batch, parentAlpha); if (Selected!=null)
Selected.draw(batch, (float) 1.0);
table.draw(batch, parentAlpha); table.draw(batch, parentAlpha);
} }
} }

View File

@ -54,7 +54,12 @@ public class PrefWindow extends Window {
this.setVisible(false); this.setVisible(false);
this.pack(); this.pack();
this.setPosition(100, 250); this.setPosition(100, 250);
dialog = new WarningDialog(AssetLoader.Skin_ui); dialog = new WarningDialog();
}
public void show() {
if (dialog.getStage()==null)
this.getParent().getStage().addActor(dialog);
} }
public void refresh() { public void refresh() {
@ -202,7 +207,7 @@ public class PrefWindow extends Window {
private void onSaveClicked() { private void onSaveClicked() {
this.setVisible(false); this.setVisible(false);
writepref(); writepref();
dialog.Show(AssetLoader.language.get("[dialog-gamescreen-preference]"), this.getStage()); dialog.show(AssetLoader.language.get("[dialog-gamescreen-preference]"),this.getStage());
} }
private void onCancelClicked() { private void onCancelClicked() {

View File

@ -0,0 +1,59 @@
package fr.evolving.dialogs;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Container;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Array;
import fr.evolving.UI.Translist;
import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Transmuter;
public class UpDialog extends Dialog {
private Translist translist;
private Container<Translist> container;
public UpDialog() {
super(AssetLoader.language.get("[dialog-window]"), AssetLoader.Skin_ui);
translist=new Translist(AssetLoader.allTransmuter, new Color(0.5f,0.5f,0.5f,1f));
container=new Container<Translist>(translist);
this.getContentTable().add(container).left();
this.setModal(true);
this.button("Ok");
this.key(Input.Keys.ENTER, true);
}
public void setTransmuters(Array<Transmuter> transmuters) {
translist.setTransmuters(transmuters);
}
public Array<Transmuter> getTransmuters() {
return translist.getTransmuters();
}
public void draw(Batch batch, float parentAlpha)
{
super.draw(batch, parentAlpha);
this.getContentTable().draw(batch, parentAlpha);
//container.draw(batch, parentAlpha);
}
/*
public Actor hit(float x, float y, boolean touchable){
Actor actor=super.hit(x, y, touchable);
if (actor==null)
return translist.hit(x, y, touchable);
else
return actor;
}*/
}

View File

@ -12,12 +12,10 @@ import fr.evolving.assets.AssetLoader;
public class WarningDialog extends Dialog { public class WarningDialog extends Dialog {
Label thelabel; Label thelabel;
public WarningDialog(Skin skin) { public WarningDialog() {
super(AssetLoader.language.get("[dialog-window]"), skin); super(AssetLoader.language.get("[dialog-window]"), AssetLoader.Skin_ui);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
this.getContentTable() this.getContentTable().add(new ImageButton(AssetLoader.Skin_level, "Warnerbros")).left();
.add(new ImageButton(AssetLoader.Skin_level, "Warnerbros"))
.left();
thelabel = new Label("", AssetLoader.Skin_level); thelabel = new Label("", AssetLoader.Skin_level);
this.getContentTable().add(thelabel).right(); this.getContentTable().add(thelabel).right();
this.setModal(true); this.setModal(true);
@ -25,7 +23,7 @@ public class WarningDialog extends Dialog {
this.key(Input.Keys.ENTER, true); this.key(Input.Keys.ENTER, true);
} }
public void Show(String info, Stage stage) { public void show(String info, Stage stage) {
this.thelabel.setText(info); this.thelabel.setText(info);
this.show(stage); this.show(stage);
} }

View File

@ -74,6 +74,7 @@ import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Worlds; import fr.evolving.automata.Worlds;
import fr.evolving.dialogs.PrefWindow; import fr.evolving.dialogs.PrefWindow;
import fr.evolving.dialogs.SavingWindow; import fr.evolving.dialogs.SavingWindow;
import fr.evolving.dialogs.UpDialog;
import fr.evolving.dialogs.WarningDialog; import fr.evolving.dialogs.WarningDialog;
import fr.evolving.renderers.GameRenderer; import fr.evolving.renderers.GameRenderer;
@ -87,7 +88,8 @@ public class GameScreen implements Screen {
public Level level; public Level level;
private PrefWindow winOptions; private PrefWindow winOptions;
private SavingWindow winSave; private SavingWindow winSave;
private ImageButton info_up_nrj, info_up_temp, info_up, info_up_rayon, private UpDialog updialog;
private ImageButton info_up_nrj, info_up_temp, info_up, info_up2, info_up_rayon,
info_up_cycle, info_up_nrjval, info_up_tempval, info_up_rayonval, info_up_cycle, info_up_nrjval, info_up_tempval, info_up_rayonval,
info_up_cycleval, nextpage, previouspage; info_up_cycleval, nextpage, previouspage;
private ImageTextButton info_cout, info_tech, info_research, info_activation; private ImageTextButton info_cout, info_tech, info_research, info_activation;
@ -319,6 +321,19 @@ public class GameScreen implements Screen {
hideInfo(); hideInfo();
} }
}); });
info_up2=new ImageButton(AssetLoader.Skin_level,"evolution2");
info_up2.setPosition(1450, AssetLoader.height - 720);
info_up2.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
//updialog.setTransmuters(menu.getTransmuter().getUnlock());
updialog.show(stage);
if (menu.getTransmuter()!=null && menu.getTransmuter().isUnlockable(worlds.ReadResearch())) {
hideInfo();
}
}
});
Gdx.app.debug("wirechem-GameScreen", "Création d'une tilemap"); Gdx.app.debug("wirechem-GameScreen", "Création d'une tilemap");
map = new TouchMaptiles(worlds,level, 128, 128); map = new TouchMaptiles(worlds,level, 128, 128);
if (Preference.prefs.getBoolean("Grid")) if (Preference.prefs.getBoolean("Grid"))
@ -672,7 +687,8 @@ public class GameScreen implements Screen {
@Override @Override
public void show() { public void show() {
Gdx.app.debug("wirechem-GameScreen","Création de la fenêtre d'option"); Gdx.app.debug("wirechem-GameScreen","Création des fenêtres");
updialog=new UpDialog();
winOptions = new PrefWindow(); winOptions = new PrefWindow();
stage.addActor(winOptions); stage.addActor(winOptions);
winSave = new SavingWindow(worlds); winSave = new SavingWindow(worlds);
@ -698,6 +714,7 @@ public class GameScreen implements Screen {
stage_info.addActor(info_nom); stage_info.addActor(info_nom);
stage_info.addActor(info_cout); stage_info.addActor(info_cout);
stage_info.addActor(info_up); stage_info.addActor(info_up);
stage_info.addActor(info_up2);
stage_info.addActor(info_desc); stage_info.addActor(info_desc);
//stage_tooltip.addActor(tooltip); //stage_tooltip.addActor(tooltip);
stage.addActor(horizbar); stage.addActor(horizbar);
@ -887,6 +904,7 @@ public class GameScreen implements Screen {
+ transmuter.getUpgradeRayon())); + transmuter.getUpgradeRayon()));
info_up_rayonval.setColor(AssetLoader.Levelcolors[2]); info_up_rayonval.setColor(AssetLoader.Levelcolors[2]);
info_up.setVisible(transmuter.isUpgradable(worlds.ReadResearch())); info_up.setVisible(transmuter.isUpgradable(worlds.ReadResearch()));
info_up2.setVisible(true);
} }

View File

@ -53,8 +53,7 @@ public class LevelScreen implements Screen {
private ImageButton Previous, Next, Exit, logosmall, databaseSave, adder, signer; private ImageButton Previous, Next, Exit, logosmall, databaseSave, adder, signer;
public Image MenuSolo, MenuMulti, MenuScenario; public Image MenuSolo, MenuMulti, MenuScenario;
private ImageTextButton cout, tech, cycle, temp, rayon, nrj, up_cycle, up_temp, up_rayon, up_nrj, research, up; private ImageTextButton cout, tech, cycle, temp, rayon, nrj, up_cycle, up_temp, up_rayon, up_nrj, research, up;
private TextButton buttonConnect, buttonPlay, buttonStat, buttonSave, private TextButton buttonConnect, buttonPlay, buttonStat, buttonSave, buttonApply, buttonPlaythis;
buttonApply, buttonPlaythis;
private ServerList Statdata, Userdata, Gamedata; private ServerList Statdata, Userdata, Gamedata;
private Worldlist Worlddata; private Worldlist Worlddata;
private Label Statdatalabel, Userdatalabel, Gamedatalabel, Worlddatalabel; private Label Statdatalabel, Userdatalabel, Gamedatalabel, Worlddatalabel;
@ -314,7 +313,7 @@ public class LevelScreen implements Screen {
stage = new Stage(AssetLoader.viewport); stage = new Stage(AssetLoader.viewport);
table = new Table(); table = new Table();
Renderer = new LevelRenderer(this); Renderer = new LevelRenderer(this);
dialog = new WarningDialog(AssetLoader.Skin_ui); dialog = new WarningDialog();
Gdx.app.debug("wirechem-LevelScreen", "Mise en place du timer."); Gdx.app.debug("wirechem-LevelScreen", "Mise en place du timer.");
ScrollTimer = new Timer(); ScrollTimer = new Timer();
ScrollTask = new TimerTask() { ScrollTask = new TimerTask() {
@ -427,7 +426,7 @@ public class LevelScreen implements Screen {
AssetLoader.Datahandler.Attach(Gamedata.getModel(), AssetLoader.Datahandler.Attach(Gamedata.getModel(),
Gamedata.getUrl()); Gamedata.getUrl());
if (!AssetLoader.Datahandler.verifyall()) { if (!AssetLoader.Datahandler.verifyall()) {
dialog.Show(AssetLoader.language.get("[dialog-levelscreen-errorloading]"),stage); dialog.show(AssetLoader.language.get("[dialog-levelscreen-errorloading]"),stage);
initlevel(); initlevel();
} else } else
menu(); menu();
@ -456,7 +455,7 @@ public class LevelScreen implements Screen {
Preference.prefs.putString("gamedata", Gamedata.getUrl()); Preference.prefs.putString("gamedata", Gamedata.getUrl());
Preference.prefs.putString("statdata", Statdata.getUrl()); Preference.prefs.putString("statdata", Statdata.getUrl());
Preference.prefs.flush(); Preference.prefs.flush();
dialog.Show( dialog.show(
AssetLoader.language.get("[dialog-levelscreen-savedatabase]"),stage); AssetLoader.language.get("[dialog-levelscreen-savedatabase]"),stage);
} }
}); });
@ -490,10 +489,10 @@ public class LevelScreen implements Screen {
buttonPlaythis.addListener(new ClickListener() { buttonPlaythis.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (!AssetLoader.Datahandler.verifyall()) if (!AssetLoader.Datahandler.verifyall())
dialog.Show(AssetLoader.language.get("[dialog-levelscreen-errorlevels]"),stage); dialog.show(AssetLoader.language.get("[dialog-levelscreen-errorlevels]"),stage);
else { else {
if (Worlddata.getSelected() == null) if (Worlddata.getSelected() == null)
dialog.Show(AssetLoader.language.get("[dialog-levelscreen-errornoworld]"), stage); dialog.show(AssetLoader.language.get("[dialog-levelscreen-errornoworld]"), stage);
else { else {
worlds.set((String) Worlddata.getSelected()); worlds.set((String) Worlddata.getSelected());
Preference.prefs.flush(); Preference.prefs.flush();