feat: ajout de la gestion total de l'upgrade et l'unlock autrement que par une fenêtre de dialogue.

This commit is contained in:
Nicolas Hordé 2016-06-17 17:16:48 +02:00
parent 054b079026
commit 8bf3441a21
5 changed files with 82 additions and 76 deletions

View File

@ -224,10 +224,6 @@ public class Menu extends Actor {
return this.seltype;
}
public void upate() {
}
public void update() {
clearall();
if (worlds.isDebug())
@ -275,6 +271,8 @@ public class Menu extends Actor {
}
private void clearall() {
unSelect();
setPage(0);
for (int k=0;k<Transmuter.Class.values().length;k++)
for (int j=0;j<nbpages;j++){
map[j][k].getTileSets().addTileSet(AssetLoader.tileSet);

View File

@ -13,6 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
@ -27,6 +28,7 @@ public class Translist extends Actor{
Table table;
int whereis;
Color color;
ChangeEvent event;
public Translist(Array<Transmuter> transmuters,Color color) {
this.color=color;
@ -37,6 +39,7 @@ public class Translist extends Actor{
public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug("wirechem-Translist", "Previous transmuter");
previousTransmuter();
onchanged();
}
});
Next=new ImageButton(AssetLoader.Skin_level, "extend");
@ -45,6 +48,7 @@ public class Translist extends Actor{
public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug("wirechem-Translist", "Next transmuter");
nextTransmuter();
onchanged();
}
});
this.addListener(new ClickListener() {
@ -58,6 +62,15 @@ public class Translist extends Actor{
setTransmuters(transmuters);
}
public void onchanged() {
ChangeEvent event=new ChangeEvent();
event.setTarget(this);
event.setListenerActor(this);
event.setStage(this.getStage());
if (event.getStage()!=null)
this.fire(event);
}
public void setColor(Color color) {
this.color=color;
assignTransmuter(whereis);
@ -69,6 +82,7 @@ public class Translist extends Actor{
public void setTransmuters(Array<Transmuter> transmuters) {
this.transmuters=transmuters;
onchanged();
whereis=0;
if (transmuters!=null && transmuters.size>0)
assignTransmuter(whereis);

View File

@ -54,7 +54,7 @@ public class Worlds extends Actor {
public int ReadResearch() {
if (research==-2)
research=AssetLoader.Datahandler.user().getResearchpoint(0);
return research;
return research+5800;
}
public void SaveResearch() {

View File

@ -1,59 +0,0 @@
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

@ -26,6 +26,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
@ -74,7 +75,6 @@ import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Worlds;
import fr.evolving.dialogs.PrefWindow;
import fr.evolving.dialogs.SavingWindow;
import fr.evolving.dialogs.UpDialog;
import fr.evolving.dialogs.WarningDialog;
import fr.evolving.renderers.GameRenderer;
@ -88,11 +88,11 @@ public class GameScreen implements Screen {
public Level level;
private PrefWindow winOptions;
private SavingWindow winSave;
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_cycleval, nextpage, previouspage;
private ImageTextButton info_cout, info_tech, info_research, info_activation;
private TextButton info_choose;
private IconValue cycle, temp, nrj, rayon, cout, tech, research;
String[] tocreate;
private ButtonLevel buttonlevel;
@ -106,7 +106,7 @@ public class GameScreen implements Screen {
private TextArea info_desc, tooltip;
public boolean unroll;
public Worlds worlds;
public Translist translist;
public Translist info_upgrade;
public enum calling {
mouseover, mouseclick, mousedrag, longpress, tap, taptap, zoom, fling, pan, pinch
@ -318,20 +318,66 @@ public class GameScreen implements Screen {
menu.getTransmuter().Upgrade();
menu.update();
info_up.setVisible(false);
nextpage.setDisabled(menu.isNextEmpty());
previouspage.setDisabled(menu.isPreviousEmpty());
hideInfo();
}
});
info_choose = new TextButton(AssetLoader.language.get("[info_choose-gamescreen]"), AssetLoader.Skin_ui);
info_choose.setBounds(1575, AssetLoader.height-710, 290, 45);
info_choose.setVisible(false);
info_choose.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
worlds.ModResearch(-info_upgrade.getTransmuter().getResearch());
info_upgrade.getTransmuter().Unlock();
menu.update();
info_up2.setVisible(false);
nextpage.setDisabled(menu.isNextEmpty());
previouspage.setDisabled(menu.isPreviousEmpty());
hideInfo();
}
});
info_upgrade=new Translist(null, AssetLoader.Skin_level.getColor("grey"));
info_upgrade.setBounds(1590,AssetLoader.height-620,256,256);
info_upgrade.setVisible(false);
info_upgrade.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Gdx.app.debug("wirechem-GameScreen", "info_upgrade | Element changé");
Translist tranlist=(Translist)actor;
showInfo(tranlist.getTransmuter());
if (tranlist.getTransmuter().getResearch()>worlds.ReadResearch())
{
info_choose.setDisabled(true);
info_choose.setTouchable(Touchable.disabled);
tranlist.setColor(AssetLoader.Skin_level.getColor("red"));
}
else
{
info_choose.setDisabled(false);
info_choose.setTouchable(Touchable.enabled);
tranlist.setColor(AssetLoader.Skin_level.getColor("grey"));
}
}
});
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();
//info_upgrade.setTransmuters(AssetLoader.allTransmuter);
info_upgrade.setTransmuters(menu.getTransmuter().getUnlock());
info_up2.setVisible(false);
info_upgrade.setVisible(true);
info_choose.setVisible(true);
menu.setVisible(false);
vertibar.setVisible(false);
nextpage.setVisible(false);
previouspage.setVisible(false);
}
else
info_upgrade.setVisible(false);
}
});
Gdx.app.debug("wirechem-GameScreen", "Création d'une tilemap");
@ -404,7 +450,7 @@ public class GameScreen implements Screen {
public void map_transmuter(float realx, float realy, int x, int y, boolean alone,int button, calling call) {
if (!worlds.isDebug() && level.Cout<menu.getTransmuter().getPrice())
if (menu.getTransmuter()==null || (!worlds.isDebug() && level.Cout<menu.getTransmuter().getPrice()))
return;
if (call == calling.taptap && button == 0
|| (call == calling.mouseclick && button == 1)) {
@ -688,7 +734,6 @@ public class GameScreen implements Screen {
@Override
public void show() {
Gdx.app.debug("wirechem-GameScreen","Création des fenêtres");
updialog=new UpDialog();
winOptions = new PrefWindow();
stage.addActor(winOptions);
winSave = new SavingWindow(worlds);
@ -716,6 +761,8 @@ public class GameScreen implements Screen {
stage_info.addActor(info_up);
stage_info.addActor(info_up2);
stage_info.addActor(info_desc);
stage_info.addActor(info_upgrade);
stage_info.addActor(info_choose);
//stage_tooltip.addActor(tooltip);
stage.addActor(horizbar);
if (worlds.getInformations().Cout>0 || worlds.getInformations().Tech>=1 || worlds.isDebug()) {
@ -868,7 +915,7 @@ public class GameScreen implements Screen {
public void showInfo(Transmuter transmuter) {
if (transmuter == null)
return;
unroll = true;
unroll = true;
info_nom.setText(transmuter.getName());
info_desc.setText(transmuter.getDesc());
info_tech.setVisible(transmuter.getTechnology() > 0);
@ -903,12 +950,18 @@ public class GameScreen implements Screen {
AssetLoader.Atlas_level.findRegion("jauge"
+ transmuter.getUpgradeRayon()));
info_up_rayonval.setColor(AssetLoader.Levelcolors[2]);
info_up.setVisible(transmuter.isUpgradable(worlds.ReadResearch()));
info_up2.setVisible(true);
info_up.setVisible(!info_upgrade.isVisible() && transmuter.isUpgradable(worlds.ReadResearch()));
info_up2.setVisible(!info_upgrade.isVisible() && transmuter.isUnlockable(worlds.ReadResearch()));
}
public void hideInfo() {
info_upgrade.setVisible(false);
info_choose.setVisible(false);
menu.setVisible(true);
vertibar.setVisible(true);
nextpage.setVisible(true);
previouspage.setVisible(true);
unroll = false;
}